FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ClearingDecisionBuilder.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2018 Siemens AG
4  Author: Johannes Najjar
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 
43  function __construct()
44  {
45  $this->sameFolder = false;
46  $this->clearingEvents = array();
47  $this->clearingId = -1;
48  $this->uploadTreeId = -1;
49  $this->pfileId = -1;
50  $this->userName = "fossy";
51  $this->userId = -1;
52  $this->type = null;
53  $this->scope = DecisionScopes::ITEM;
54  $this->timeStamp = time();
55  }
56 
61  public function setClearingId($clearingId)
62  {
63  $this->clearingId = intval($clearingId);
64  return $this;
65  }
66 
71  public function setTimeStamp($timestamp)
72  {
73  $this->timeStamp = $timestamp;
74  return $this;
75  }
76 
81  public function setClearingEvents($events)
82  {
83  $this->clearingEvents = $events;
84  return $this;
85  }
86 
91  public function setPfileId($pfileId)
92  {
93  $this->pfileId = intval($pfileId);
94  return $this;
95  }
96 
101  public function setSameFolder($sameFolder)
102  {
103  $this->sameFolder = $sameFolder;
104  return $this;
105  }
106 
111  public function setType($type)
112  {
113  $this->type = $type;
114  return $this;
115  }
116 
121  public function setScope($scope)
122  {
123  $this->scope = $scope;
124  return $this;
125  }
126 
131  public function setUploadTreeId($uploadTreeId)
132  {
133  $this->uploadTreeId = $uploadTreeId;
134  return $this;
135  }
136 
141  public function setUserId($userId)
142  {
143  $this->userId = $userId;
144  return $this;
145  }
146 
151  public function setUserName($userName)
152  {
153  $this->userName = $userName;
154  return $this;
155  }
156 
160  public static function create()
161  {
162  return new ClearingDecisionBuilder();
163  }
164 
168  public function copy(ClearingDecision $clearingDecision)
169  {
170  $this->sameFolder = $clearingDecision->getSameFolder();
171  $this->clearingEvents = $clearingDecision->getClearingEvents();
172  $this->clearingId = $clearingDecision->getClearingId();
173  $this->uploadTreeId = $clearingDecision->getUploadTreeId();
174  $this->pfileId = $clearingDecision->getPfileId();
175  $this->userName = $clearingDecision->getUserName();
176  $this->userId = $clearingDecision->getUserId();
177  $this->type = $clearingDecision->getType();
178  $this->comment = $clearingDecision->getComment();
179  $this->reportinfo = $clearingDecision->getReportinfo();
180  $this->acknowledgement = $clearingDecision->getAcknowledgement();
181  $this->scope = $clearingDecision->getScope();
182  $this->timeStamp = $clearingDecision->getTimeStamp();
183  }
184 
189  public function build()
190  {
191  if ($this->type === null) {
192  throw new Exception("decision type should be set");
193  }
194 
195  return new ClearingDecision($this->sameFolder, $this->clearingId,
196  $this->uploadTreeId, $this->pfileId, $this->userName, $this->userId, $this->type, $this->scope,
197  $this->timeStamp, $this->clearingEvents, $this->reportinfo, $this->comment, $this->acknowledgement);
198  }
199 }
200 
copy(ClearingDecision $clearingDecision)
Fossology exception.
Definition: Exception.php:15