FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
LicenseIrrelevantGetter.php
1 <?php
2 /*
3  Copyright (C) 2017, Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 namespace Fossology\Lib\Report;
20 
22 
24 {
26  private $clearingDao;
27 
29  private $irreleavntFilesOnly;
30 
31  public function __construct($irreleavntFilesOnly=true)
32  {
33  $this->clearingDao = $GLOBALS['container']->get('dao.clearing');
34  $this->irreleavntFilesOnly = $irreleavntFilesOnly;
35  parent::__construct($groupBy = 'text');
36  }
37 
44  protected function getStatements($uploadId, $uploadTreeTableName, $groupId=null)
45  {
46  $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId,$uploadTreeTableName);
47  return $this->clearingDao->getFilesForDecisionTypeFolderLevel($itemTreeBounds, $groupId);
48  }
49 
55  protected function groupStatements($ungrupedStatements, $extended, $agentcall, $isUnifiedReport, $objectAgent)
56  {
57  $statements = array();
58  foreach ($ungrupedStatements as $statement) {
59  $fileName = $statement['fileName'];
60  $dirName = dirname($statement['fileName']);
61  $baseName = basename($statement['fileName']);
62  $comment = $statement['comment'];
63  $licenseName = $statement['shortname'];
64  if ($this->irreleavntFilesOnly) {
65  if (array_key_exists($fileName, $statements)) {
66  $currentLics = &$statements[$fileName]["licenses"];
67  if (! in_array($licenseName, $currentLics)) {
68  $currentLics[] = $licenseName;
69  }
70  } else {
71  $statements[$fileName] = array(
72  "content" => convertToUTF8($dirName, false),
73  "fileName" => $baseName,
74  "licenses" => array($licenseName)
75  );
76  }
77  } else {
78  if ($comment) {
79  $statements[] = array(
80  "content" => $licenseName,
81  "text" => $comment,
82  "files" => array($fileName)
83  );
84  }
85  }
86  $objectAgent->heartbeat(1);
87  }
88  return array("statements" => array_values($statements));
89  }
90 }
groupStatements($ungrupedStatements, $extended, $agentcall, $isUnifiedReport, $objectAgent)
if(!defined('ENT_SUBSTITUTE')) convertToUTF8($content, $toHTML=true)
getStatements($uploadId, $uploadTreeTableName, $groupId=null)