|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Management; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Engine\Impl\ProcessEngineLogger; |
|
6
|
|
|
use Jabe\Engine\Impl\Cmd\{ |
|
7
|
|
|
ActivateJobCmd, |
|
8
|
|
|
CommandLogger, |
|
9
|
|
|
SuspendJobCmd |
|
10
|
|
|
}; |
|
11
|
|
|
use Jabe\Engine\Impl\Interceptor\CommandExecutorInterface; |
|
12
|
|
|
use Jabe\Engine\Impl\Util\EnsureUtil; |
|
13
|
|
|
use Jabe\Engine\Management\{ |
|
14
|
|
|
UpdateJobSuspensionStateBuilderInterface, |
|
15
|
|
|
UpdateJobSuspensionStateSelectBuilderInterface, |
|
16
|
|
|
UpdateJobSuspensionStateTenantBuilderInterface |
|
17
|
|
|
}; |
|
18
|
|
|
|
|
19
|
|
|
class UpdateJobSuspensionStateBuilderImpl implements UpdateJobSuspensionStateBuilderInterface, UpdateJobSuspensionStateSelectBuilderInterface, UpdateJobSuspensionStateTenantBuilderInterface |
|
20
|
|
|
{ |
|
21
|
|
|
//private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; |
|
22
|
|
|
|
|
23
|
|
|
protected $commandExecutor; |
|
24
|
|
|
|
|
25
|
|
|
protected $jobId; |
|
26
|
|
|
protected $jobDefinitionId; |
|
27
|
|
|
|
|
28
|
|
|
protected $processInstanceId; |
|
29
|
|
|
|
|
30
|
|
|
protected $processDefinitionKey; |
|
31
|
|
|
protected $processDefinitionId; |
|
32
|
|
|
|
|
33
|
|
|
protected $processDefinitionTenantId; |
|
34
|
|
|
protected $isProcessDefinitionTenantIdSet = false; |
|
35
|
|
|
|
|
36
|
|
|
public function __construct(CommandExecutorInterface $commandExecutor = null) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->commandExecutor = $commandExecutor; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function byJobId(string $jobId): UpdateJobSuspensionStateBuilderImpl |
|
42
|
|
|
{ |
|
43
|
|
|
EnsureUtil::ensureNotNull("jobId", "jobId)", $jobId); |
|
44
|
|
|
$this->jobId = $jobId; |
|
45
|
|
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function byJobDefinitionId(string $jobDefinitionId): UpdateJobSuspensionStateBuilderImpl |
|
49
|
|
|
{ |
|
50
|
|
|
EnsureUtil::ensureNotNull("jobDefinitionId", "jobDefinitionId", $jobDefinitionId); |
|
51
|
|
|
$this->jobDefinitionId = $jobDefinitionId; |
|
52
|
|
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function byProcessInstanceId(string $processInstanceId): UpdateJobSuspensionStateBuilderImpl |
|
56
|
|
|
{ |
|
57
|
|
|
EnsureUtil::ensureNotNull("processInstanceId", "processInstanceId", $processInstanceId); |
|
58
|
|
|
$this->processInstanceId = $processInstanceId; |
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function byProcessDefinitionId(string $processDefinitionId): UpdateJobSuspensionStateBuilderImpl |
|
63
|
|
|
{ |
|
64
|
|
|
EnsureUtil::ensureNotNull("processDefinitionId", "processDefinitionId", $processDefinitionId); |
|
65
|
|
|
$this->processDefinitionId = $processDefinitionId; |
|
66
|
|
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function byProcessDefinitionKey(string $processDefinitionKey): UpdateJobSuspensionStateBuilderImpl |
|
70
|
|
|
{ |
|
71
|
|
|
EnsureUtil::ensureNotNull("processDefinitionKey", "processDefinitionKey", $processDefinitionKey); |
|
72
|
|
|
$this->processDefinitionKey = $processDefinitionKey; |
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function processDefinitionWithoutTenantId(): UpdateJobSuspensionStateBuilderImpl |
|
77
|
|
|
{ |
|
78
|
|
|
$this->processDefinitionTenantId = null; |
|
79
|
|
|
$this->isProcessDefinitionTenantIdSet = true; |
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function processDefinitionTenantId(string $tenantId): UpdateJobSuspensionStateBuilderImpl |
|
84
|
|
|
{ |
|
85
|
|
|
EnsureUtil::ensureNotNull("tenantId", "tenantId", $tenantId); |
|
86
|
|
|
|
|
87
|
|
|
$this->processDefinitionTenantId = $tenantId; |
|
88
|
|
|
$this->isProcessDefinitionTenantIdSet = true; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function activate(): void |
|
93
|
|
|
{ |
|
94
|
|
|
$this->validateParameters(); |
|
95
|
|
|
$command = new ActivateJobCmd($this); |
|
96
|
|
|
$this->commandExecutor->execute($command); |
|
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function suspend(): void |
|
100
|
|
|
{ |
|
101
|
|
|
$this->validateParameters(); |
|
102
|
|
|
$command = new SuspendJobCmd($this); |
|
103
|
|
|
$this->commandExecutor->execute($command); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
protected function validateParameters(): void |
|
107
|
|
|
{ |
|
108
|
|
|
EnsureUtil::ensureOnlyOneNotNull( |
|
109
|
|
|
"Need to specify either a job id, a job definition id, a process instance id, a process definition id or a process definition key.", |
|
110
|
|
|
$this->jobId, |
|
111
|
|
|
$this->jobDefinitionId, |
|
112
|
|
|
$this->processInstanceId, |
|
113
|
|
|
$this->processDefinitionId, |
|
114
|
|
|
$this->processDefinitionKey |
|
115
|
|
|
); |
|
116
|
|
|
|
|
117
|
|
|
if ($this->isProcessDefinitionTenantIdSet && ($this->jobId !== null || $this->jobDefinitionId !== null || $this->processInstanceId !== null || $this->processDefinitionId !== null)) { |
|
118
|
|
|
//throw LOG.exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey(); |
|
119
|
|
|
throw new \Exception("exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey"); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
EnsureUtil::ensureNotNull("commandExecutor", "commandExecutor", $commandExecutor); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function getProcessDefinitionKey(): string |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->processDefinitionKey; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
public function getProcessDefinitionId(): string |
|
131
|
|
|
{ |
|
132
|
|
|
return $this->processDefinitionId; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
public function getProcessDefinitionTenantId(): string |
|
136
|
|
|
{ |
|
137
|
|
|
return $this->processDefinitionTenantId; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function isProcessDefinitionTenantIdSet(): bool |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->isProcessDefinitionTenantIdSet; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function getJobId(): string |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->jobId; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function getJobDefinitionId(): string |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->jobDefinitionId; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function getProcessInstanceId(): string |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->processInstanceId; |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.