FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Job.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2017 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
12 namespace Fossology\UI\Api\Models;
13 
16 
22 class Job
23 {
28  private $id;
33  private $name;
38  private $queueDate;
43  private $uploadId;
48  private $userId;
53  private $groupId;
58  private $eta;
59 
68  private $status;
73  private $jobQueue;
74 
88  public function __construct($id, $name = "", $queueDate = "", $uploadId = 0,
89  $userId = 0, $groupId = 0, $eta = 0, $status = "", $jobQueue = [])
90  {
91  $this->id = intval($id);
92  $this->name = $name;
93  $this->queueDate = $queueDate;
94  $this->uploadId = intval($uploadId);
95  $this->userId = intval($userId);
96  $this->groupId = intval($groupId);
97  $this->eta = intval($eta);
98  $this->status = $status;
99  $this->jobQueue = $jobQueue;
100  }
101 
106  public function getJSON($version=ApiVersion::V1)
107  {
108  return json_encode($this->getArray($version));
109  }
110 
115  public function getArray($version = ApiVersion::V1)
116  {
117  if ($version == ApiVersion::V2) {
118 
120  $userDao = $GLOBALS['container']->get("dao.user");
121  return [
122  'id' => $this->id,
123  'name' => $this->name,
124  'queueDate' => $this->queueDate,
125  'uploadId' => $this->uploadId,
126  'userName' => $userDao->getUserName($this->userId),
127  'groupName' => $userDao->getGroupNameById($this->groupId),
128  'eta' => $this->eta,
129  'status' => $this->status,
130  'jobQueue' => $this->jobQueue
131  ];
132  } else {
133  return [
134  'id' => $this->id,
135  'name' => $this->name,
136  'queueDate' => $this->queueDate,
137  'uploadId' => $this->uploadId,
138  'userId' => $this->userId,
139  'groupId' => $this->groupId,
140  'eta' => $this->eta,
141  'status' => $this->status
142  ];
143  }
144  }
145 
150  public function getId()
151  {
152  return $this->id;
153  }
154 
159  public function getName()
160  {
161  return $this->name;
162  }
163 
168  public function getQueueDate()
169  {
170  return $this->queueDate;
171  }
172 
177  public function getUploadId()
178  {
179  return $this->uploadId;
180  }
181 
186  public function getUserId()
187  {
188  return $this->userId;
189  }
190 
195  public function getGroupId()
196  {
197  return $this->groupId;
198  }
199 
204  public function getEta()
205  {
206  return $this->eta;
207  }
208 
213  public function getStatus()
214  {
215  return $this->status;
216  }
217 
222  public function getJobQueue()
223  {
224  return $this->jobQueue;
225  }
226 
231  public function setName($name)
232  {
233  $this->name = $name;
234  }
235 
240  public function setQueueDate($queueDate)
241  {
242  $this->queueDate = $queueDate;
243  }
244 
249  public function setUploadId($uploadId)
250  {
251  $this->uploadId = $uploadId;
252  }
253 
258  public function setUserId($userId)
259  {
260  $this->userId = $userId;
261  }
262 
267  public function setGroupId($groupId)
268  {
269  $this->groupId = $groupId;
270  }
271 
276  public function setEta($eta)
277  {
278  $this->eta = $eta;
279  }
280 
285  public function setStatus($status)
286  {
287  $this->status = $status;
288  }
289 
294  public function setJobQueue($jobQueue)
295  {
296  $this->jobQueue = $jobQueue;
297  }
298 }
getJSON($version=ApiVersion::V1)
Definition: Job.php:106
setUploadId($uploadId)
Definition: Job.php:249
setJobQueue($jobQueue)
Definition: Job.php:294
setQueueDate($queueDate)
Definition: Job.php:240
__construct($id, $name="", $queueDate="", $uploadId=0, $userId=0, $groupId=0, $eta=0, $status="", $jobQueue=[])
Definition: Job.php:88