FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
XpClearedGetter.php
1 <?php
2 /*
3  Copyright (C) 2014-2017, Siemens AG
4  Author: Daniele Fognini
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 $copyrightDao;
30 
31  protected $tableName;
32  protected $type;
33  protected $getOnlyCleared;
34  protected $extrawhere;
35 
36  public function __construct($tableName, $type=null, $getOnlyCleared=false, $extraWhere=null)
37  {
38  global $container;
39 
40  $this->copyrightDao = $container->get('dao.copyright');
41 
42  $this->getOnlyCleared = $getOnlyCleared;
43  $this->type = $type;
44  $this->tableName = $tableName;
45  $this->extrawhere = $extraWhere;
46  parent::__construct();
47  }
48 
49  protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null)
50  {
51  $agentName = $this->tableName;
52  $scanJobProxy = new ScanJobProxy($GLOBALS['container']->get('dao.agent'), $uploadId);
53  $scanJobProxy->createAgentStatus(array($agentName));
54  $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
55  if (!array_key_exists($agentName, $selectedScanners)) {
56  return array();
57  }
58  $latestXpAgentId = $selectedScanners[$agentName];
59  if (!empty($this->extrawhere)) {
60  $this->extrawhere .= ' AND';
61  }
62  $this->extrawhere .= ' agent_fk='.$latestXpAgentId;
63 
64  return $this->copyrightDao->getAllEntriesReport($this->tableName, $uploadId, $uploadTreeTableName, $this->type, $this->getOnlyCleared, DecisionTypes::IDENTIFIED, $this->extrawhere, $groupId);
65  }
66 }
67