FOSSology  4.4.0
Open Source License Compliance by Open Source Software
XpClearedGetter.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2017 Siemens AG
4  Author: Daniele Fognini
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Report;
10 
14 
16 {
18  private $copyrightDao;
19 
20  protected $tableName;
21  protected $type;
22  protected $getOnlyCleared;
23  protected $extrawhere;
24 
25  public function __construct($tableName, $type=null, $getOnlyCleared=false, $extraWhere=null)
26  {
27  global $container;
28 
29  $this->copyrightDao = $container->get('dao.copyright');
30 
31  $this->getOnlyCleared = $getOnlyCleared;
32  $this->type = $type;
33  $this->tableName = $tableName;
34  $this->extrawhere = $extraWhere;
35  parent::__construct();
36  }
37 
38  protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null)
39  {
40  $agentName = $this->tableName;
41  $scanJobProxy = new ScanJobProxy($GLOBALS['container']->get('dao.agent'), $uploadId);
42  if ($agentName == "copyright") {
43  $scanJobProxy->createAgentStatus(array($agentName, 'reso'));
44  } else {
45  $scanJobProxy->createAgentStatus(array($agentName));
46  }
47  $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
48  if (!array_key_exists($agentName, $selectedScanners)) {
49  return array();
50  }
51  $latestXpAgentId[] = $selectedScanners[$agentName];
52  if (array_key_exists('reso', $selectedScanners)) {
53  $latestXpAgentId[] = $selectedScanners['reso'];
54  }
55  $ids = implode(',', $latestXpAgentId);
56  if (!empty($this->extrawhere)) {
57  $this->extrawhere .= ' AND';
58  }
59  $this->extrawhere .= ' agent_fk IN ('.$ids.')';
60 
61  $result = $this->copyrightDao->getAllEntriesReport($this->tableName, $uploadId, $uploadTreeTableName, $this->type, $this->getOnlyCleared, DecisionTypes::IDENTIFIED, $this->extrawhere, $groupId);
62  $this->extrawhere = null;
63  return $result;
64  }
65 }
getStatements($uploadId, $uploadTreeTableName, $groupId=null)