-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathjob.php
More file actions
49 lines (43 loc) · 1.84 KB
/
job.php
File metadata and controls
49 lines (43 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use DBA\Event;
use DBA\Factory;
class Job_API extends API {
public $patch_access = Auth_Library::A_PUBLIC;
/**
* @throws Exception
*/
public function patch() {
if (empty($this->get['id'])) {
throw new Exception('No id provided');
}
$auth = Auth_Library::getInstance();
$job = Factory::getJobFactory()->get($this->get['id']);
$evaluation = Factory::getEvaluationFactory()->get($job->getEvaluationId());
if (!$job) {
$this->setStatusCode(API::STATUS_NUM_JOB_DOES_NOT_EXIST);
throw new Exception('Job does not exist!');
}
if (isset($this->request['description'])) {
$job->setDescription($this->request['description']);
}
if (!empty($this->request['status'])) {
$oldStatus = $job->getStatus();
$job->setStatus($this->request['status']);
$event = new Event(0, "Job status changed", date('Y-m-d H:i:s'),
"Job of evaluation '" . $evaluation->getName() . "' running on deployment '" . $job->getEnvironment() . "' changed from " . Util::getStatusText($oldStatus) . " to " . Util::getStatusText($job->getStatus()) . ".",
Define::EVENT_JOB, $job->getId(), ($auth->isLoggedIn()) ? $auth->getUserID() : null);
Factory::getEventFactory()->save($event);
}
if (isset($this->request['progress'])) {
$job->setProgress($this->request['progress']);
}
if(isset($this->request['getLogalyzerResponse'])) {
$warning = -1;
$error = -1;
$mandatory = -1;
$string = json_encode('{"warning": ' . $warning .',"error": '. $error . ',"mandatory": '. $mandatory .'}');
$this->addData('response', $string);
}
Factory::getJobFactory()->update($job);
}
}