FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
BulkMatchesGetter.php
1 <?php
2 /*
3  Copyright (C) 2014-2017, Siemens AG
4  Author: Daniele Fognini
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 namespace Fossology\Lib\Report;
21 
23 
25 {
27  private $clearingDao;
28 
29  public function __construct()
30  {
31  global $container;
32  $this->clearingDao = $container->get('dao.clearing');
33  parent::__construct($groupBy = "bulkId");
34  }
35 
36  protected function getStatements($uploadId, $uploadTreeTableName, $groupId=0)
37  {
38  $result = array();
39 
40  $parentTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
41  $bulkHistory = $this->clearingDao->getBulkHistory($parentTreeBounds, $groupId, false);
42 
43  foreach ($bulkHistory as $bulk) {
44  $allLicenses = "";
45  $bulkId = $bulk['bulkId'];
46  foreach ($bulk['removedLicenses'] as $removedLics) {
47  $allLicenses .= ($removedLics ? "[remove] " : "") . $removedLics.', ';
48  }
49  foreach ($bulk['addedLicenses'] as $addedLics) {
50  $allLicenses .= ($addedLics ? "[add] " : "") . $addedLics.', ';
51  }
52  $allLicenses = trim($allLicenses, ', ');
53  $content = $bulk['text'];
54 
55  foreach ($this->clearingDao->getBulkMatches($bulkId, $groupId) as $bulkMatch) {
56  $uploadTreeId = $bulkMatch['itemid'];
57 
58  $result[] = array(
59  'bulkId' => $bulkId,
60  'content' => $content,
61  'textfinding' => $allLicenses,
62  'description' => $content,
63  'uploadtree_pk' => $uploadTreeId
64  );
65  }
66  }
67 
68  return $result;
69  }
70 }
71 
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695