FOSSology  4.4.0
Open Source License Compliance by Open Source Software
LicenseMainGetter.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2016-2017 Siemens AG
4  Author: Daniele Fognini, Shaheem Azmal M MD
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Report;
10 
14 
16 {
18  private $clearingDao;
19 
21  private $licenseDao;
22 
23  public function __construct()
24  {
25  global $container;
26 
27  $this->clearingDao = $container->get('dao.clearing');
28  $this->licenseDao = $container->get('dao.license');
29 
30  parent::__construct($groupBy = 'text');
31  }
32 
33  protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null)
34  {
35  $dbManager = $GLOBALS['container']->get('db.manager');
36  $licenseMap = new LicenseMap($dbManager, $groupId, LicenseMap::REPORT, true);
37  $mainLicIds = $this->clearingDao->getMainLicenseIds($uploadId, $groupId);
38 
39  $allStatements = array();
40  foreach ($mainLicIds as $originLicenseId) {
41  $allLicenseCols = $this->licenseDao->getLicenseById($originLicenseId, $groupId);
42  $allStatements[] = array(
43  'licenseId' => $originLicenseId,
44  'risk' => $allLicenseCols->getRisk(),
45  'content' => $licenseMap->getProjectedSpdxId($originLicenseId),
46  'text' => $allLicenseCols->getText(),
47  'name' => $licenseMap->getProjectedShortname($originLicenseId,
48  $allLicenseCols->getShortName())
49  );
50  }
51  return $allStatements;
52  }
53 
54  public function getCleared($uploadId, $objectAgent, $groupId=null, $extended=true, $agentcall=null, $isUnifiedReport=false)
55  {
56  $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
57  $statements = $this->getStatements($uploadId, $uploadTreeTableName, $groupId);
58  if (!$extended) {
59  for ($i=0; $i<=count($statements); $i++) {
60  unset($statements[$i]['risk']);
61  unset($statements[$i]['licenseId']);
62  }
63  }
64  return array("statements" => array_values($statements));
65  }
66 }
Wrapper class for license map.
Definition: LicenseMap.php:19
getStatements($uploadId, $uploadTreeTableName, $groupId=null)