|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pheanstalk\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Pheanstalk\Structure\JobInstance; |
|
7
|
|
|
use Pheanstalk\Structure\TaskInstance; |
|
8
|
|
|
use Pheanstalk\Structure\Workflow; |
|
9
|
|
|
use Pheanstalk\Structure\WorkflowInstance; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* The 'GetWorkflow' command. |
|
13
|
|
|
* |
|
14
|
|
|
* Retrieve a workflow by its id, if there is no workflow for the id given in the construct, returns false |
|
15
|
|
|
* |
|
16
|
|
|
* @author Valentin Corre |
|
17
|
|
|
* @package Pheanstalk |
|
18
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php |
|
19
|
|
|
*/ |
|
20
|
|
|
class GetWorkflowInstancesDetailCommand extends GetWorkflowInstancesCommand |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var WorkflowInstance $workflowInstance */ |
|
23
|
|
|
private $workflowInstance; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* GetWorkflowCommand constructor. |
|
27
|
|
|
* |
|
28
|
|
|
* @param Workflow $workflow |
|
29
|
|
|
*/ |
|
30
|
4 |
|
public function __construct(WorkflowInstance $workflowInstance) |
|
31
|
|
|
{ |
|
32
|
4 |
|
$this->workflowInstance = $workflowInstance; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @inheritDoc |
|
37
|
|
|
*/ |
|
38
|
4 |
|
public function getGroup(): string |
|
39
|
|
|
{ |
|
40
|
4 |
|
return 'instance'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @inheritDoc |
|
45
|
|
|
*/ |
|
46
|
4 |
|
public function getAction(): string |
|
47
|
|
|
{ |
|
48
|
4 |
|
return 'query'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritDoc |
|
53
|
|
|
*/ |
|
54
|
4 |
|
public function getFilters(): array |
|
55
|
|
|
{ |
|
56
|
|
|
$filters = [ |
|
57
|
4 |
|
'id' => $this->workflowInstance->getId(), |
|
58
|
|
|
]; |
|
59
|
|
|
|
|
60
|
4 |
|
return $filters; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @inheritDoc |
|
65
|
|
|
*/ |
|
66
|
4 |
|
public function getResponseParser() |
|
67
|
|
|
{ |
|
68
|
4 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @inheritDoc |
|
73
|
|
|
*/ |
|
74
|
4 |
|
public function parseResponse($responseLine, $responseData) |
|
75
|
|
|
{ |
|
76
|
4 |
|
$subjobs = $responseData['workflow']['subjobs']; |
|
77
|
4 |
|
$jobInstances = new ArrayCollection([]); |
|
78
|
4 |
|
foreach ($subjobs as $subjob) { |
|
79
|
4 |
|
$taskInstances = new ArrayCollection([]); |
|
80
|
4 |
|
foreach ($subjob['tasks'] as $tasks) { |
|
81
|
4 |
|
$task = $tasks['@attributes']; |
|
82
|
|
|
|
|
83
|
4 |
|
if (isset($task['execution_time'])) { |
|
84
|
4 |
|
$task['execution_time'] = new \DateTime($task['execution_time']); |
|
85
|
|
|
} |
|
86
|
4 |
|
foreach ($task as $key => $val) { |
|
87
|
4 |
|
if (ctype_digit($val)) { |
|
88
|
4 |
|
$task[$key] = (int) $task[$key]; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
4 |
|
$taskInstances[] = new TaskInstance($task); |
|
92
|
|
|
} |
|
93
|
4 |
|
$jobInstances[] = new JobInstance($taskInstances); |
|
94
|
|
|
} |
|
95
|
4 |
|
$this->workflowInstance->setJobInstances($jobInstances); |
|
96
|
|
|
|
|
97
|
4 |
|
return $this->workflowInstance; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|