FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ClearingEventBuilder.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2014-2018, Siemens AG
4  * Author: J.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 
21 
24 
26 {
28  private $eventId;
30  private $uploadTreeId;
32  private $timeStamp;
34  private $userId;
36  private $groupId;
38  private $eventType;
40  private $licenseRef;
42  private $removed;
44  private $reportinfo;
46  private $comment;
48  private $acknowledgement;
49 
50  public function __construct()
51  {
52  $this->eventId = 0;
53  $this->uploadTreeId = 0;
54  $this->timeStamp = null;
55  $this->userId = 1;
56  $this->groupId = 1;
57  $this->eventType = ClearingEventTypes::USER;
58  $this->licenseRef = null;
59  $this->removed = false;
60  $this->reportinfo = "";
61  $this->comment = "";
62  $this->acknowledgement = "";
63  }
64 
65  public static function create()
66  {
67  return new ClearingEventBuilder();
68  }
69 
73  public function build()
74  {
75  $clearingLicense = new ClearingLicense($this->licenseRef, $this->removed, $this->eventType, $this->reportinfo, $this->comment, $this->acknowledgement);
76  return new ClearingEvent($this->eventId, $this->uploadTreeId, $this->timeStamp?: time(), $this->userId, $this->groupId, $this->eventType, $clearingLicense);
77  }
78 
83  public function setComment($comment)
84  {
85  $this->comment = $comment;
86  return $this;
87  }
88 
93  public function setTimeStamp($timestamp)
94  {
95  $this->timeStamp = $timestamp;
96  return $this;
97  }
98 
103  public function setEventId($eventId)
104  {
105  $this->eventId = intval($eventId);
106  return $this;
107  }
108 
113  public function setEventType($eventType)
114  {
115  $this->eventType = $eventType;
116  return $this;
117  }
118 
123  public function setGroupId($groupId)
124  {
125  $this->groupId = intval($groupId);
126  return $this;
127  }
128 
133  public function setLicenseRef(LicenseRef $licenseRef)
134  {
135  $this->licenseRef = $licenseRef;
136  return $this;
137  }
138 
143  public function setRemoved($removed)
144  {
145  $this->removed = $removed;
146  return $this;
147  }
148 
153  public function setReportinfo($reportinfo)
154  {
155  $this->reportinfo = $reportinfo;
156  return $this;
157  }
158 
163  public function setAcknowledgement($acknowledgement)
164  {
165  $this->acknowledgement = $acknowledgement;
166  return $this;
167  }
172  public function setUploadTreeId($uploadTreeId)
173  {
174  $this->uploadTreeId = intval($uploadTreeId);
175  return $this;
176  }
177 
182  public function setUserId($userId)
183  {
184  $this->userId = intval($userId);
185  return $this;
186  }
187 }