FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ClearingEventBuilder.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2018 Siemens AG
4  Author: J.Najjar
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Data\Clearing;
10 
13 
15 {
17  private $eventId;
19  private $uploadTreeId;
21  private $timeStamp;
23  private $userId;
25  private $groupId;
27  private $eventType;
29  private $licenseRef;
31  private $removed;
33  private $reportinfo;
35  private $comment;
37  private $acknowledgement;
38 
39  public function __construct()
40  {
41  $this->eventId = 0;
42  $this->uploadTreeId = 0;
43  $this->timeStamp = null;
44  $this->userId = 1;
45  $this->groupId = 1;
46  $this->eventType = ClearingEventTypes::USER;
47  $this->licenseRef = null;
48  $this->removed = false;
49  $this->reportinfo = "";
50  $this->comment = "";
51  $this->acknowledgement = "";
52  }
53 
54  public static function create()
55  {
56  return new ClearingEventBuilder();
57  }
58 
62  public function build()
63  {
64  $clearingLicense = new ClearingLicense($this->licenseRef, $this->removed, $this->eventType, $this->reportinfo, $this->comment, $this->acknowledgement);
65  return new ClearingEvent($this->eventId, $this->uploadTreeId, $this->timeStamp?: time(), $this->userId, $this->groupId, $this->eventType, $clearingLicense);
66  }
67 
72  public function setComment($comment)
73  {
74  $this->comment = $comment;
75  return $this;
76  }
77 
82  public function setTimeStamp($timestamp)
83  {
84  $this->timeStamp = $timestamp;
85  return $this;
86  }
87 
92  public function setEventId($eventId)
93  {
94  $this->eventId = intval($eventId);
95  return $this;
96  }
97 
102  public function setEventType($eventType)
103  {
104  $this->eventType = $eventType;
105  return $this;
106  }
107 
112  public function setGroupId($groupId)
113  {
114  $this->groupId = intval($groupId);
115  return $this;
116  }
117 
122  public function setLicenseRef(LicenseRef $licenseRef)
123  {
124  $this->licenseRef = $licenseRef;
125  return $this;
126  }
127 
132  public function setRemoved($removed)
133  {
134  $this->removed = $removed;
135  return $this;
136  }
137 
142  public function setReportinfo($reportinfo)
143  {
144  $this->reportinfo = $reportinfo;
145  return $this;
146  }
147 
152  public function setAcknowledgement($acknowledgement)
153  {
154  $this->acknowledgement = $acknowledgement;
155  return $this;
156  }
161  public function setUploadTreeId($uploadTreeId)
162  {
163  $this->uploadTreeId = intval($uploadTreeId);
164  return $this;
165  }
166 
171  public function setUserId($userId)
172  {
173  $this->userId = intval($userId);
174  return $this;
175  }
176 }