FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ClearingDecision.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2018 Siemens AG
4  Author: Johannes Najjar, Steffen Weber
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Data;
10 
13 
15 {
17  private $sameFolder;
19  private $clearingEvents;
21  private $clearingId;
23  private $uploadTreeId;
25  private $pfileId;
27  private $userName;
29  private $userId;
31  private $type;
33  private $comment;
35  private $reportinfo;
37  private $acknowledgement;
39  private $scope;
41  private $timeStamp;
42 
59  public function __construct($sameFolder, $clearingId, $uploadTreeId, $pfileId, $userName, $userId, $type, $scope, $ts_added, $clearingEvents, $comment = "", $reportinfo = "", $acknowledgement = "")
60  {
61  $this->sameFolder = $sameFolder;
62  $this->clearingId = $clearingId;
63  $this->uploadTreeId = $uploadTreeId;
64  $this->pfileId = $pfileId;
65  $this->userName = $userName;
66  $this->userId = $userId;
67  $this->type = $type;
68  $this->scope = $scope;
69  $this->timeStamp = $ts_added;
70  $this->comment = $comment;
71  $this->reportinfo = $reportinfo;
72  $this->acknowledgement = $acknowledgement;
73  $this->clearingEvents = $clearingEvents;
74  }
75 
79  public function getClearingId()
80  {
81  return $this->clearingId;
82  }
83 
87  public function getComment()
88  {
89  return $this->comment;
90  }
91 
95  public function getTimeStamp()
96  {
97  return $this->timeStamp;
98  }
99 
103  public function getClearingLicenses()
104  {
105  $clearingLicenses = array();
106  foreach ($this->clearingEvents as $clearingEvent) {
107  $clearingLicenses[] = $clearingEvent->getClearingLicense();
108  }
109  return $clearingLicenses;
110  }
111 
115  public function getPositiveLicenses()
116  {
117  $result = array();
118  foreach ($this->clearingEvents as $clearingEvent) {
119  $clearingLicense = $clearingEvent->getClearingLicense();
120  if (! $clearingLicense->isRemoved()) {
121  $result[] = $clearingLicense->getLicenseRef();
122  }
123  }
124 
125  return $result;
126  }
127 
131  public function getClearingEvents()
132  {
133  return $this->clearingEvents;
134  }
135 
139  public function getPfileId()
140  {
141  return $this->pfileId;
142  }
143 
147  public function getReportinfo()
148  {
149  return $this->reportinfo;
150  }
151 
155  public function getAcknowledgement()
156  {
157  return $this->acknowledgement;
158  }
159 
163  public function getSameFolder()
164  {
165  return $this->sameFolder;
166  }
167 
171  public function getScope()
172  {
173  return $this->scope;
174  }
175 
179  public function getType()
180  {
181  return $this->type;
182  }
183 
187  public function getUploadTreeId()
188  {
189  return $this->uploadTreeId;
190  }
191 
195  public function getUserId()
196  {
197  return $this->userId;
198  }
199 
203  public function getUserName()
204  {
205  return $this->userName;
206  }
207 
211  public function isInScope()
212  {
213  switch ($this->getScope()) {
214  case 'global':
215  return true;
216  case 'upload':
217  return $this->sameFolder;
218  }
219  return false;
220  }
221 
222  function __toString()
223  {
224  $output = "ClearingDecision(#" . $this->clearingId . ", ";
225 
226  $clearingLicenses = $this->getClearingLicenses();
227 
228  foreach ($clearingLicenses as $clearingLicense) {
229  $output .= ($clearingLicense->isRemoved() ? "-" : ""). $clearingLicense->getShortName() . ", ";
230  }
231 
232  return $output . $this->getUserName() . ")";
233  }
234 }
__construct($sameFolder, $clearingId, $uploadTreeId, $pfileId, $userName, $userId, $type, $scope, $ts_added, $clearingEvents, $comment="", $reportinfo="", $acknowledgement="")