FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
LicenseMainGetter.php
1 <?php
2 /*
3  Copyright (C) 2016-2017, Siemens AG
4  Author: Daniele Fognini, Shaheem Azmal M MD
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 
25 
27 {
29  private $clearingDao;
30 
32  private $licenseDao;
33 
34  public function __construct()
35  {
36  global $container;
37 
38  $this->clearingDao = $container->get('dao.clearing');
39  $this->licenseDao = $container->get('dao.license');
40 
41  parent::__construct($groupBy = 'text');
42  }
43 
44  protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null)
45  {
46  $dbManager = $GLOBALS['container']->get('db.manager');
47  $licenseMap = new LicenseMap($dbManager, $groupId, LicenseMap::REPORT, true);
48  $mainLicIds = $this->clearingDao->getMainLicenseIds($uploadId, $groupId);
49 
50  $allStatements = array();
51  foreach ($mainLicIds as $originLicenseId) {
52  $allLicenseCols = $this->licenseDao->getLicenseById($originLicenseId, $groupId);
53  $allStatements[] = array(
54  'licenseId' => $originLicenseId,
55  'risk' => $allLicenseCols->getRisk(),
56  'content' => $licenseMap->getProjectedShortname($originLicenseId),
57  'text' => $allLicenseCols->getText()
58  );
59  }
60  return $allStatements;
61  }
62 
63  public function getCleared($uploadId, $groupId=null, $extended=true, $agentcall=null, $isUnifiedReport=false, $objectAgent)
64  {
65  $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
66  $statements = $this->getStatements($uploadId, $uploadTreeTableName, $groupId);
67  if (!$extended) {
68  for ($i=0; $i<=count($statements); $i++) {
69  unset($statements[$i]['risk']);
70  }
71  }
72  return array("statements" => array_values($statements));
73  }
74 }
Wrapper class for license map.
Definition: LicenseMap.php:29