FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ClearingDecisionBuilder.php
1 <?php
2 /*
3 Copyright (C) 2014-2018, Siemens AG
4 Author: Johannes Najjar
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 
54  function __construct()
55  {
56  $this->sameFolder = false;
57  $this->clearingEvents = array();
58  $this->clearingId = -1;
59  $this->uploadTreeId = -1;
60  $this->pfileId = -1;
61  $this->userName = "fossy";
62  $this->userId = -1;
63  $this->type = null;
64  $this->scope = DecisionScopes::ITEM;
65  $this->timeStamp = time();
66  }
67 
72  public function setClearingId($clearingId)
73  {
74  $this->clearingId = intval($clearingId);
75  return $this;
76  }
77 
82  public function setTimeStamp($timestamp)
83  {
84  $this->timeStamp = $timestamp;
85  return $this;
86  }
87 
92  public function setClearingEvents($events)
93  {
94  $this->clearingEvents = $events;
95  return $this;
96  }
97 
102  public function setPfileId($pfileId)
103  {
104  $this->pfileId = intval($pfileId);
105  return $this;
106  }
107 
112  public function setSameFolder($sameFolder)
113  {
114  $this->sameFolder = $sameFolder;
115  return $this;
116  }
117 
122  public function setType($type)
123  {
124  $this->type = $type;
125  return $this;
126  }
127 
132  public function setScope($scope)
133  {
134  $this->scope = $scope;
135  return $this;
136  }
137 
142  public function setUploadTreeId($uploadTreeId)
143  {
144  $this->uploadTreeId = $uploadTreeId;
145  return $this;
146  }
147 
152  public function setUserId($userId)
153  {
154  $this->userId = $userId;
155  return $this;
156  }
157 
162  public function setUserName($userName)
163  {
164  $this->userName = $userName;
165  return $this;
166  }
167 
171  public static function create()
172  {
173  return new ClearingDecisionBuilder();
174  }
175 
179  public function copy(ClearingDecision $clearingDecision)
180  {
181  $this->sameFolder = $clearingDecision->getSameFolder();
182  $this->clearingEvents = $clearingDecision->getClearingEvents();
183  $this->clearingId = $clearingDecision->getClearingId();
184  $this->uploadTreeId = $clearingDecision->getUploadTreeId();
185  $this->pfileId = $clearingDecision->getPfileId();
186  $this->userName = $clearingDecision->getUserName();
187  $this->userId = $clearingDecision->getUserId();
188  $this->type = $clearingDecision->getType();
189  $this->comment = $clearingDecision->getComment();
190  $this->reportinfo = $clearingDecision->getReportinfo();
191  $this->acknowledgement = $clearingDecision->getAcknowledgement();
192  $this->scope = $clearingDecision->getScope();
193  $this->timeStamp = $clearingDecision->getTimeStamp();
194  }
195 
200  public function build()
201  {
202  if ($this->type === null) {
203  throw new Exception("decision type should be set");
204  }
205 
206  return new ClearingDecision($this->sameFolder, $this->clearingId,
207  $this->uploadTreeId, $this->pfileId, $this->userName, $this->userId, $this->type, $this->scope,
208  $this->timeStamp, $this->clearingEvents, $this->reportinfo, $this->comment, $this->acknowledgement);
209  }
210 }
211 
copy(ClearingDecision $clearingDecision)
Fossology exception.
Definition: Exception.php:25