FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ClearingDecision.php
1 <?php
2 /*
3 Copyright (C) 2014-2018, Siemens AG
4 Author: Johannes Najjar, Steffen Weber
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\Data;
21 
24 
26 {
28  private $sameFolder;
30  private $clearingEvents;
32  private $clearingId;
34  private $uploadTreeId;
36  private $pfileId;
38  private $userName;
40  private $userId;
42  private $type;
44  private $comment;
46  private $reportinfo;
48  private $acknowledgement;
50  private $scope;
52  private $timeStamp;
53 
70  public function __construct($sameFolder, $clearingId, $uploadTreeId, $pfileId, $userName, $userId, $type, $scope, $ts_added, $clearingEvents, $comment = "", $reportinfo = "", $acknowledgement = "")
71  {
72  $this->sameFolder = $sameFolder;
73  $this->clearingId = $clearingId;
74  $this->uploadTreeId = $uploadTreeId;
75  $this->pfileId = $pfileId;
76  $this->userName = $userName;
77  $this->userId = $userId;
78  $this->type = $type;
79  $this->scope = $scope;
80  $this->timeStamp = $ts_added;
81  $this->comment = $comment;
82  $this->reportinfo = $reportinfo;
83  $this->acknowledgement = $acknowledgement;
84  $this->clearingEvents = $clearingEvents;
85  }
86 
90  public function getClearingId()
91  {
92  return $this->clearingId;
93  }
94 
98  public function getComment()
99  {
100  return $this->comment;
101  }
102 
106  public function getTimeStamp()
107  {
108  return $this->timeStamp;
109  }
110 
114  public function getClearingLicenses()
115  {
116  $clearingLicenses = array();
117  foreach ($this->clearingEvents as $clearingEvent) {
118  $clearingLicenses[] = $clearingEvent->getClearingLicense();
119  }
120  return $clearingLicenses;
121  }
122 
126  public function getPositiveLicenses()
127  {
128  $result = array();
129  foreach ($this->clearingEvents as $clearingEvent) {
130  $clearingLicense = $clearingEvent->getClearingLicense();
131  if (! $clearingLicense->isRemoved()) {
132  $result[] = $clearingLicense->getLicenseRef();
133  }
134  }
135 
136  return $result;
137  }
138 
142  public function getClearingEvents()
143  {
144  return $this->clearingEvents;
145  }
146 
150  public function getPfileId()
151  {
152  return $this->pfileId;
153  }
154 
158  public function getReportinfo()
159  {
160  return $this->reportinfo;
161  }
162 
166  public function getAcknowledgement()
167  {
168  return $this->acknowledgement;
169  }
170 
174  public function getSameFolder()
175  {
176  return $this->sameFolder;
177  }
178 
182  public function getScope()
183  {
184  return $this->scope;
185  }
186 
190  public function getType()
191  {
192  return $this->type;
193  }
194 
198  public function getUploadTreeId()
199  {
200  return $this->uploadTreeId;
201  }
202 
206  public function getUserId()
207  {
208  return $this->userId;
209  }
210 
214  public function getUserName()
215  {
216  return $this->userName;
217  }
218 
222  public function isInScope()
223  {
224  switch ($this->getScope()) {
225  case 'global':
226  return true;
227  case 'upload':
228  return $this->sameFolder;
229  }
230  return false;
231  }
232 
233  function __toString()
234  {
235  $output = "ClearingDecision(#" . $this->clearingId . ", ";
236 
237  foreach ($this->clearingLicenses as $clearingLicense) {
238  $output .= ($clearingLicense->isRemoved() ? "-" : ""). $clearingLicense->getShortName() . ", ";
239  }
240 
241  return $output . $this->getUserName() . ")";
242  }
243 }
__construct($sameFolder, $clearingId, $uploadTreeId, $pfileId, $userName, $userId, $type, $scope, $ts_added, $clearingEvents, $comment="", $reportinfo="", $acknowledgement="")