FOSSology  4.4.0
Open Source License Compliance by Open Source Software
BulkMatchesGetter.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2017 Siemens AG
4  Author: Daniele Fognini
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Report;
9 
11 
13 {
15  private $clearingDao;
16 
17  public function __construct()
18  {
19  global $container;
20  $this->clearingDao = $container->get('dao.clearing');
21  parent::__construct($groupBy = "bulkId");
22  }
23 
24  protected function getStatements($uploadId, $uploadTreeTableName, $groupId=0)
25  {
26  $result = array();
27 
28  $parentTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
29  $bulkHistory = $this->clearingDao->getBulkHistory($parentTreeBounds, $groupId, false);
30 
31  foreach ($bulkHistory as $bulk) {
32  $allLicenses = "";
33  $bulkId = $bulk['bulkId'];
34  foreach ($bulk['removedLicenses'] as $removedLics) {
35  $allLicenses .= ($removedLics ? "[remove] " : "") . $removedLics.', ';
36  }
37  foreach ($bulk['addedLicenses'] as $addedLics) {
38  $allLicenses .= ($addedLics ? "[add] " : "") . $addedLics.', ';
39  }
40  $allLicenses = trim($allLicenses, ', ');
41  $content = $bulk['text'];
42 
43  foreach ($this->clearingDao->getBulkMatches($bulkId, $groupId) as $bulkMatch) {
44  $uploadTreeId = $bulkMatch['itemid'];
45 
46  $result[] = array(
47  'bulkId' => $bulkId,
48  'content' => $content,
49  'textfinding' => $allLicenses,
50  'description' => $content,
51  'uploadtree_pk' => $uploadTreeId
52  );
53  }
54  }
55 
56  return $result;
57  }
58 }
59 
getStatements($uploadId, $uploadTreeTableName, $groupId=0)
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690