|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Impl\Persistence\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Application\{ |
|
6
|
|
|
InvocationContext, |
|
7
|
|
|
ProcessApplicationReferenceInterface |
|
8
|
|
|
}; |
|
9
|
|
|
use Jabe\Delegate\VariableScopeInterface; |
|
10
|
|
|
use Jabe\Impl\ProcessEngineLogger; |
|
11
|
|
|
use Jabe\Impl\Context\{ |
|
12
|
|
|
Context, |
|
13
|
|
|
ProcessApplicationContextUtil |
|
14
|
|
|
}; |
|
15
|
|
|
use Jabe\Impl\Core\Variable\CoreVariableInstanceInterface; |
|
16
|
|
|
use Jabe\Impl\Db\{ |
|
17
|
|
|
DbEntityInterface, |
|
18
|
|
|
DbEntityLifecycleAwareInterface, |
|
19
|
|
|
EnginePersistenceLogger, |
|
20
|
|
|
HasDbReferencesInterface, |
|
21
|
|
|
HasDbRevisionInterface |
|
22
|
|
|
}; |
|
23
|
|
|
use Jabe\Impl\Persistence\Entity\Util\{ |
|
24
|
|
|
ByteArrayField, |
|
25
|
|
|
TypedValueField, |
|
26
|
|
|
TypedValueUpdateListenerInterface |
|
27
|
|
|
}; |
|
28
|
|
|
use Jabe\Impl\Variable\Serializer\{ |
|
29
|
|
|
TypedValueSerializerInterface, |
|
30
|
|
|
ValueFieldsInterface |
|
31
|
|
|
}; |
|
32
|
|
|
use Jabe\Repository\ResourceTypes; |
|
33
|
|
|
use Jabe\Runtime\VariableInstanceInterface; |
|
34
|
|
|
use Jabe\Variable\Value\TypedValueInterface; |
|
35
|
|
|
use Jabe\Impl\Util\ClassNameUtil; |
|
36
|
|
|
|
|
37
|
|
|
class VariableInstanceEntity implements VariableInstanceInterface, CoreVariableInstanceInterface, ValueFieldsInterface, DbEntityInterface, DbEntityLifecycleAwareInterface, TypedValueUpdateListenerInterface, HasDbRevisionInterface, HasDbReferencesInterface, \Serializable |
|
38
|
|
|
{ |
|
39
|
|
|
//protected static final EnginePersistenceLogger LOG = ProcessEngineLogger.PERSISTENCE_LOGGER; |
|
40
|
|
|
|
|
41
|
|
|
protected $id; |
|
42
|
|
|
protected $revision; |
|
43
|
|
|
|
|
44
|
|
|
protected $name; |
|
45
|
|
|
|
|
46
|
|
|
protected $processDefinitionId; |
|
47
|
|
|
protected $processInstanceId; |
|
48
|
|
|
protected $executionId; |
|
49
|
|
|
protected $taskId; |
|
50
|
|
|
protected $batchId; |
|
51
|
|
|
/*protected $caseInstanceId; |
|
52
|
|
|
protected $caseExecutionId;*/ |
|
53
|
|
|
protected $activityInstanceId; |
|
54
|
|
|
protected $tenantId; |
|
55
|
|
|
|
|
56
|
|
|
protected $longValue; |
|
57
|
|
|
protected $doubleValue; |
|
58
|
|
|
protected $textValue; |
|
59
|
|
|
protected $textValue2; |
|
60
|
|
|
protected $variableScopeId; |
|
61
|
|
|
|
|
62
|
|
|
protected $byteArrayField; |
|
63
|
|
|
|
|
64
|
|
|
protected $typedValueField; |
|
65
|
|
|
|
|
66
|
|
|
protected $forcedUpdate; |
|
67
|
|
|
|
|
68
|
|
|
protected $configuration; |
|
69
|
|
|
|
|
70
|
|
|
protected $sequenceCounter = 1; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* <p>Determines whether this variable is supposed to be a local variable |
|
74
|
|
|
* in case of concurrency in its scope. This affects |
|
75
|
|
|
* </p> |
|
76
|
|
|
* |
|
77
|
|
|
* <ul> |
|
78
|
|
|
* <li>tree expansion (not evaluated yet by the engine) |
|
79
|
|
|
* <li>activity instance IDs of variable instances: concurrentLocal |
|
80
|
|
|
* variables always receive the activity instance id of their execution |
|
81
|
|
|
* (which may not be the scope execution), while non-concurrentLocal variables |
|
82
|
|
|
* always receive the activity instance id of their scope (which is set in the |
|
83
|
|
|
* parent execution) |
|
84
|
|
|
* </ul> |
|
85
|
|
|
* |
|
86
|
|
|
* <p> |
|
87
|
|
|
* In the future, this field could be used for restoring the variable distribution |
|
88
|
|
|
* when the tree is expanded/compacted multiple times. |
|
89
|
|
|
* On expansion, the goal would be to keep concurrentLocal variables always with |
|
90
|
|
|
* their concurrent replacing executions while non-concurrentLocal variables |
|
91
|
|
|
* stay in the scope execution |
|
92
|
|
|
* </p> |
|
93
|
|
|
*/ |
|
94
|
|
|
protected $isConcurrentLocal = false; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Determines whether this variable is stored in the data base. |
|
98
|
|
|
*/ |
|
99
|
|
|
protected $isTransient = false; |
|
100
|
|
|
|
|
101
|
|
|
// transient properties |
|
102
|
|
|
protected $execution; |
|
103
|
|
|
|
|
104
|
|
|
public function __construct(string $name, TypedValueInterface $value, bool $isTransient) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->byteArrayField = new ByteArrayField($this, ResourceTypes::runtime()); |
|
107
|
|
|
$this->typedValueField = new TypedValueField($this, true); |
|
108
|
|
|
|
|
109
|
|
|
$this->typedValueField->addImplicitUpdateListener($this); |
|
110
|
|
|
$this->name = $name; |
|
111
|
|
|
$this->isTransient = $isTransient; |
|
112
|
|
|
$this->typedValueField->setValue($value); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public static function createAndInsert(string $name, TypedValueInterface $value): VariableInstanceEntity |
|
116
|
|
|
{ |
|
117
|
|
|
$variableInstance = self::create($name, $value, $value->isTransient()); |
|
118
|
|
|
self::insert($variableInstance); |
|
119
|
|
|
return $variableInstance; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public static function insert(VariableInstanceEntity $variableInstance): void |
|
123
|
|
|
{ |
|
124
|
|
|
if (!$variableInstance->isTransient()) { |
|
125
|
|
|
Context::getCommandContext() |
|
126
|
|
|
->getDbEntityManager() |
|
127
|
|
|
->insert($variableInstance); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public static function create(string $name, TypedValueInterface $value, bool $isTransient): VariableInstanceEntity |
|
132
|
|
|
{ |
|
133
|
|
|
return new VariableInstanceEntity($name, $value, $isTransient); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function delete(): void |
|
137
|
|
|
{ |
|
138
|
|
|
|
|
139
|
|
|
if (!$this->isTransient()) { |
|
140
|
|
|
$this->typedValueField->notifyImplicitValueUpdate(); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
// clear value |
|
144
|
|
|
$this->clearValueFields(); |
|
145
|
|
|
|
|
146
|
|
|
if (!$this->isTransient) { |
|
147
|
|
|
// delete variable |
|
148
|
|
|
Context::getCommandContext()->getDbEntityManager()->delete($this); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function getPersistentState() |
|
153
|
|
|
{ |
|
154
|
|
|
$persistentState = []; |
|
155
|
|
|
if ($this->typedValueField->getSerializerName() !== null) { |
|
|
|
|
|
|
156
|
|
|
$persistentState["serializerName"] = $this->typedValueField->getSerializerName(); |
|
157
|
|
|
} |
|
158
|
|
|
if ($this->longValue !== null) { |
|
159
|
|
|
$persistentState["longValue"] = $this->longValue; |
|
160
|
|
|
} |
|
161
|
|
|
if ($this->doubleValue !== null) { |
|
162
|
|
|
$persistentState["doubleValue"] = $this->doubleValue; |
|
163
|
|
|
} |
|
164
|
|
|
if ($this->textValue !== null) { |
|
165
|
|
|
$persistentState["textValue"] = $this->textValue; |
|
166
|
|
|
} |
|
167
|
|
|
if ($this->textValue2 !== null) { |
|
168
|
|
|
$persistentState["textValue2"] = $this->textValue2; |
|
169
|
|
|
} |
|
170
|
|
|
if ($this->byteArrayField->getByteArrayId() !== null) { |
|
|
|
|
|
|
171
|
|
|
$persistentState["byteArrayValueId"] = $this->byteArrayField->getByteArrayId(); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
$persistentState["sequenceCounter"] = $this->getSequenceCounter(); |
|
175
|
|
|
$persistentState["concurrentLocal"] = $this->isConcurrentLocal; |
|
176
|
|
|
$persistentState["executionId"] = $this->executionId; |
|
177
|
|
|
$persistentState["taskId"] = $this->taskId; |
|
178
|
|
|
//$persistentState["caseExecutionId", caseExecutionId); |
|
179
|
|
|
//$persistentState["caseInstanceId", caseInstanceId); |
|
180
|
|
|
$persistentState["tenantId"] = $this->tenantId; |
|
181
|
|
|
$persistentState["processInstanceId"] = $this->processInstanceId; |
|
182
|
|
|
$persistentState["processDefinitionId"] = $this->processDefinitionId; |
|
183
|
|
|
|
|
184
|
|
|
return $persistentState; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function getRevisionNext(): int |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->revision + 1; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
// lazy initialized relations /////////////////////////////////////////////// |
|
193
|
|
|
|
|
194
|
|
|
public function setProcessInstanceId(string $processInstanceId): void |
|
195
|
|
|
{ |
|
196
|
|
|
$this->processInstanceId = $processInstanceId; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public function setProcessDefinitionId(string $processDefinitionId): void |
|
200
|
|
|
{ |
|
201
|
|
|
$this->processDefinitionId = $processDefinitionId; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
public function setExecutionId(string $executionId): void |
|
205
|
|
|
{ |
|
206
|
|
|
$this->executionId = $executionId; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/*public void setCaseInstanceId(string $caseInstanceId) { |
|
210
|
|
|
$this->caseInstanceId = caseInstanceId; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
public void setCaseExecutionId(string $caseExecutionId) { |
|
214
|
|
|
$this->caseExecutionId = caseExecutionId; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public void setCaseExecution(CaseExecutionEntity caseExecution) { |
|
218
|
|
|
if (caseExecution !== null) { |
|
219
|
|
|
$this->caseInstanceId = caseExecution->getCaseInstanceId(); |
|
220
|
|
|
$this->caseExecutionId = caseExecution->getId(); |
|
221
|
|
|
$this->tenantId = caseExecution->getTenantId(); |
|
222
|
|
|
} else { |
|
223
|
|
|
$this->caseInstanceId = null; |
|
224
|
|
|
$this->caseExecutionId = null; |
|
225
|
|
|
$this->tenantId = null; |
|
226
|
|
|
} |
|
227
|
|
|
}*/ |
|
228
|
|
|
|
|
229
|
|
|
// byte array value ///////////////////////////////////////////////////////// |
|
230
|
|
|
|
|
231
|
|
|
// i couldn't find a easy readable way to extract the common byte array value logic |
|
232
|
|
|
// into a common class. therefor it's duplicated in VariableInstanceEntity, |
|
233
|
|
|
// HistoricVariableInstance and HistoricDetailVariableInstanceUpdateEntity |
|
234
|
|
|
|
|
235
|
|
|
public function getByteArrayValueId(): string |
|
236
|
|
|
{ |
|
237
|
|
|
return $this->byteArrayField->getByteArrayId(); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function setByteArrayValueId(string $byteArrayValueId): void |
|
241
|
|
|
{ |
|
242
|
|
|
$this->byteArrayField->setByteArrayId($byteArrayValueId); |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function getByteArrayValue(): string |
|
246
|
|
|
{ |
|
247
|
|
|
return $this->byteArrayField->getByteArrayValue(); |
|
|
|
|
|
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
public function setByteArrayValue(string $bytes): void |
|
251
|
|
|
{ |
|
252
|
|
|
$this->byteArrayField->setByteArrayValue($bytes, $this->isTransient); |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
protected function deleteByteArrayValue(): void |
|
256
|
|
|
{ |
|
257
|
|
|
$this->byteArrayField->deleteByteArrayValue(); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
// type ///////////////////////////////////////////////////////////////////// |
|
261
|
|
|
|
|
262
|
|
|
public function getValue() |
|
263
|
|
|
{ |
|
264
|
|
|
return $this->typedValueField->getValue(); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function getTypedValue(?bool $deserializeValue = null): TypedValueInterface |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->typedValueField->getTypedValue($deserializeValue ?? true, $this->isTransient); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
public function setValue(TypedValueInterface $value): void |
|
273
|
|
|
{ |
|
274
|
|
|
// clear value fields |
|
275
|
|
|
$this->clearValueFields(); |
|
276
|
|
|
|
|
277
|
|
|
$this->typedValueField->setValue($value); |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
public function clearValueFields(): void |
|
281
|
|
|
{ |
|
282
|
|
|
$this->longValue = null; |
|
283
|
|
|
$this->doubleValue = null; |
|
284
|
|
|
$this->textValue = null; |
|
285
|
|
|
$this->textValue2 = null; |
|
286
|
|
|
$this->typedValueField->clear(); |
|
287
|
|
|
|
|
288
|
|
|
if ($this->byteArrayField->getByteArrayId() !== null) { |
|
|
|
|
|
|
289
|
|
|
$this->deleteByteArrayValue(); |
|
290
|
|
|
$this->setByteArrayValueId(null); |
|
|
|
|
|
|
291
|
|
|
} |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
public function getTypeName(): string |
|
295
|
|
|
{ |
|
296
|
|
|
return $this->typedValueField->getTypeName(); |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
// entity lifecycle ///////////////////////////////////////////////////////// |
|
300
|
|
|
|
|
301
|
|
|
public function postLoad(): void |
|
302
|
|
|
{ |
|
303
|
|
|
// make sure the serializer is initialized |
|
304
|
|
|
$this->typedValueField->postLoad(); |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
// execution //////////////////////////////////////////////////////////////// |
|
308
|
|
|
|
|
309
|
|
|
protected function ensureExecutionInitialized(): void |
|
310
|
|
|
{ |
|
311
|
|
|
if ($this->execution === null && $this->executionId !== null) { |
|
312
|
|
|
$this->execution = Context::getCommandContext() |
|
313
|
|
|
->getExecutionManager() |
|
314
|
|
|
->findExecutionById($this->executionId); |
|
315
|
|
|
} |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
public function getExecution(): ExecutionEntity |
|
319
|
|
|
{ |
|
320
|
|
|
$this->ensureExecutionInitialized(); |
|
321
|
|
|
return $this->execution; |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
public function setExecution(ExecutionEntity $execution): void |
|
325
|
|
|
{ |
|
326
|
|
|
$this->execution = $execution; |
|
327
|
|
|
if ($this->execution === null) { |
|
328
|
|
|
$this->executionId = null; |
|
329
|
|
|
$this->processInstanceId = null; |
|
330
|
|
|
$this->processDefinitionId = null; |
|
331
|
|
|
$this->tenantId = null; |
|
332
|
|
|
} else { |
|
333
|
|
|
$this->setExecutionId($execution->getId()); |
|
334
|
|
|
$this->processDefinitionId = $execution->getProcessDefinitionId(); |
|
335
|
|
|
$this->processInstanceId = $execution->getProcessInstanceId(); |
|
336
|
|
|
$this->tenantId = $execution->getTenantId(); |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
// case execution /////////////////////////////////////////////////////////// |
|
341
|
|
|
|
|
342
|
|
|
/*public CaseExecutionEntity getCaseExecution() { |
|
343
|
|
|
if (caseExecutionId !== null) { |
|
344
|
|
|
return Context |
|
345
|
|
|
->getCommandContext() |
|
346
|
|
|
->getCaseExecutionManager() |
|
347
|
|
|
.findCaseExecutionById(caseExecutionId); |
|
348
|
|
|
} |
|
349
|
|
|
return null; |
|
350
|
|
|
}*/ |
|
351
|
|
|
|
|
352
|
|
|
// getters and setters ////////////////////////////////////////////////////// |
|
353
|
|
|
|
|
354
|
|
|
public function getId(): ?string |
|
355
|
|
|
{ |
|
356
|
|
|
return $this->id; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
public function setId(string $id): void |
|
360
|
|
|
{ |
|
361
|
|
|
$this->id = $id; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
public function getTextValue(): string |
|
365
|
|
|
{ |
|
366
|
|
|
return $this->textValue; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
public function getProcessInstanceId(): string |
|
370
|
|
|
{ |
|
371
|
|
|
return $this->processInstanceId; |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
public function getProcessDefinitionId(): string |
|
375
|
|
|
{ |
|
376
|
|
|
return $this->processDefinitionId; |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
public function getExecutionId(): string |
|
380
|
|
|
{ |
|
381
|
|
|
return $this->executionId; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/*public String getCaseInstanceId() { |
|
385
|
|
|
return caseInstanceId; |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
public String getCaseExecutionId() { |
|
389
|
|
|
return caseExecutionId; |
|
390
|
|
|
}*/ |
|
391
|
|
|
|
|
392
|
|
|
public function getLongValue(): int |
|
393
|
|
|
{ |
|
394
|
|
|
return $this->longValue; |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
public function setLongValue(int $longValue): void |
|
398
|
|
|
{ |
|
399
|
|
|
$this->longValue = $longValue; |
|
400
|
|
|
} |
|
401
|
|
|
|
|
402
|
|
|
public function getDoubleValue(): float |
|
403
|
|
|
{ |
|
404
|
|
|
return $this->doubleValue; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
public function setDoubleValue(float $doubleValue): void |
|
408
|
|
|
{ |
|
409
|
|
|
$this->doubleValue = $doubleValue; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
public function setName(string $name): void |
|
413
|
|
|
{ |
|
414
|
|
|
$this->name = $name; |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
public function setTextValue(string $textValue): void |
|
418
|
|
|
{ |
|
419
|
|
|
$this->textValue = $textValue; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
public function getName(): string |
|
423
|
|
|
{ |
|
424
|
|
|
return $this->name; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
public function getRevision(): int |
|
428
|
|
|
{ |
|
429
|
|
|
return $this->revision; |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
public function setRevision(int $revision): void |
|
433
|
|
|
{ |
|
434
|
|
|
$this->revision = $revision; |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
public function setSerializer(TypedValueSerializerInterface $serializer): void |
|
438
|
|
|
{ |
|
439
|
|
|
$this->typedValueField->setSerializerName($serializer->getName()); |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
public function setSerializerName(string $type): void |
|
443
|
|
|
{ |
|
444
|
|
|
$this->typedValueField->setSerializerName($type); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
public function getSerializer(): TypedValueSerializerInterface |
|
448
|
|
|
{ |
|
449
|
|
|
return $this->typedValueField->getSerializer(); |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
public function getTextValue2(): string |
|
453
|
|
|
{ |
|
454
|
|
|
return $this->textValue2; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
public function setTextValue2(string $textValue2): void |
|
458
|
|
|
{ |
|
459
|
|
|
$this->textValue2 = $textValue2; |
|
460
|
|
|
} |
|
461
|
|
|
|
|
462
|
|
|
public function getTaskId(): string |
|
463
|
|
|
{ |
|
464
|
|
|
return $this->taskId; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
public function setTaskId(string $taskId): void |
|
468
|
|
|
{ |
|
469
|
|
|
$this->taskId = $taskId; |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
public function getBatchId(): string |
|
473
|
|
|
{ |
|
474
|
|
|
return $this->batchId; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
public function setBatchId(string $batchId): void |
|
478
|
|
|
{ |
|
479
|
|
|
$this->batchId = $batchId; |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
public function setTask(TaskEntity $task): void |
|
483
|
|
|
{ |
|
484
|
|
|
if ($task !== null) { |
|
485
|
|
|
$this->taskId = $task->getId(); |
|
486
|
|
|
$this->tenantId = $task->getTenantId(); |
|
487
|
|
|
|
|
488
|
|
|
if ($task->getExecution() !== null) { |
|
489
|
|
|
$this->setExecution($task->getExecution()); |
|
490
|
|
|
} |
|
491
|
|
|
/*if ($task->getCaseExecution() !== null) { |
|
492
|
|
|
setCaseExecution(task->getCaseExecution()); |
|
493
|
|
|
}*/ |
|
494
|
|
|
} else { |
|
495
|
|
|
$this->taskId = null; |
|
496
|
|
|
$this->tenantId = null; |
|
497
|
|
|
$this->setExecution(null); |
|
|
|
|
|
|
498
|
|
|
//setCaseExecution(null); |
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
public function getActivityInstanceId(): string |
|
503
|
|
|
{ |
|
504
|
|
|
return $this->activityInstanceId; |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
public function setActivityInstanceId(string $activityInstanceId): void |
|
508
|
|
|
{ |
|
509
|
|
|
$this->activityInstanceId = $activityInstanceId; |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
public function getSerializerName(): string |
|
513
|
|
|
{ |
|
514
|
|
|
return $this->typedValueField->getSerializerName(); |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
public function getErrorMessage(): string |
|
518
|
|
|
{ |
|
519
|
|
|
return $this->typedValueField->getErrorMessage(); |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
public function getVariableScopeId(): ?string |
|
523
|
|
|
{ |
|
524
|
|
|
if ($this->variableScopeId !== null) { |
|
525
|
|
|
return $this->variableScopeId; |
|
526
|
|
|
} |
|
527
|
|
|
|
|
528
|
|
|
if ($this->taskId !== null) { |
|
529
|
|
|
return $this->taskId; |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
|
|
if ($this->executionId !== null) { |
|
533
|
|
|
return $this->executionId; |
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
//return caseExecutionId; |
|
537
|
|
|
} |
|
538
|
|
|
|
|
539
|
|
|
public function setVariableScopeId(string $variableScopeId): void |
|
540
|
|
|
{ |
|
541
|
|
|
$this->variableScopeId = $variableScopeId; |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
|
|
protected function getVariableScope(): ?VariableScopeInterface |
|
545
|
|
|
{ |
|
546
|
|
|
if ($this->taskId !== null) { |
|
547
|
|
|
return $this->getTask(); |
|
548
|
|
|
} elseif ($this->executionId !== null) { |
|
549
|
|
|
return $this->getExecution(); |
|
550
|
|
|
} else { |
|
551
|
|
|
return null; |
|
552
|
|
|
} |
|
553
|
|
|
/*elseif (caseExecutionId !== null) { |
|
554
|
|
|
return getCaseExecution(); |
|
555
|
|
|
}*/ |
|
556
|
|
|
} |
|
557
|
|
|
|
|
558
|
|
|
protected function getTask(): ?TaskEntity |
|
559
|
|
|
{ |
|
560
|
|
|
if ($this->taskId !== null) { |
|
561
|
|
|
return Context::getCommandContext()->getTaskManager()->findTaskById($this->taskId); |
|
562
|
|
|
} else { |
|
563
|
|
|
return null; |
|
564
|
|
|
} |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
//sequence counter /////////////////////////////////////////////////////////// |
|
568
|
|
|
|
|
569
|
|
|
public function getSequenceCounter(): int |
|
570
|
|
|
{ |
|
571
|
|
|
return $this->sequenceCounter; |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
public function setSequenceCounter(int $sequenceCounter): void |
|
575
|
|
|
{ |
|
576
|
|
|
$this->sequenceCounter = $sequenceCounter; |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
public function incrementSequenceCounter(): void |
|
580
|
|
|
{ |
|
581
|
|
|
$this->sequenceCounter += 1; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
|
|
585
|
|
|
public function isConcurrentLocal(): bool |
|
586
|
|
|
{ |
|
587
|
|
|
return $this->isConcurrentLocal; |
|
588
|
|
|
} |
|
589
|
|
|
|
|
590
|
|
|
public function setConcurrentLocal(bool $isConcurrentLocal): void |
|
591
|
|
|
{ |
|
592
|
|
|
$this->isConcurrentLocal = $isConcurrentLocal; |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
public function onImplicitValueUpdate(TypedValueInterface $updatedValue): void |
|
596
|
|
|
{ |
|
597
|
|
|
// note: this implementation relies on the |
|
598
|
|
|
// behavior that the variable scope |
|
599
|
|
|
// of variable value can never become null |
|
600
|
|
|
|
|
601
|
|
|
$targetProcessApplication = getContextProcessApplication(); |
|
|
|
|
|
|
602
|
|
|
if ($targetProcessApplication !== null) { |
|
603
|
|
|
$scope = $this; |
|
604
|
|
|
Context::executeWithinProcessApplication( |
|
605
|
|
|
function () use ($scope, $updatedValue) { |
|
606
|
|
|
$scope->getVariableScope()->setVariableLocal($scope->name, $updatedValue); |
|
607
|
|
|
return null; |
|
608
|
|
|
}, |
|
609
|
|
|
$targetProcessApplication, |
|
610
|
|
|
new InvocationContext($this->getExecution()) |
|
611
|
|
|
); |
|
612
|
|
|
} else { |
|
613
|
|
|
if (!$this->isTransient) { |
|
614
|
|
|
$this->getVariableScope()->setVariableLocal($this->name, $updatedValue); |
|
615
|
|
|
} |
|
616
|
|
|
} |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
protected function getContextProcessApplication(): ?ProcessApplicationReferenceInterface |
|
620
|
|
|
{ |
|
621
|
|
|
if ($this->taskId !== null) { |
|
622
|
|
|
return ProcessApplicationContextUtil::getTargetProcessApplication($this->getTask()); |
|
623
|
|
|
} elseif ($this->executionId !== null) { |
|
624
|
|
|
return ProcessApplicationContextUtil::getTargetProcessApplication($this->getExecution()); |
|
625
|
|
|
} else { |
|
626
|
|
|
return null; |
|
627
|
|
|
} |
|
628
|
|
|
/*elseif (caseExecutionId !== null) { |
|
629
|
|
|
return ProcessApplicationContextUtil->getTargetProcessApplication(getCaseExecution()); |
|
630
|
|
|
} */ |
|
631
|
|
|
} |
|
632
|
|
|
|
|
633
|
|
|
public function serialize() |
|
634
|
|
|
{ |
|
635
|
|
|
return json_encode([ |
|
636
|
|
|
'id' => $this->id, |
|
637
|
|
|
'revision' => $this->revision, |
|
638
|
|
|
'name' => $this->name, |
|
639
|
|
|
'processDefinitionId' => $this->processDefinitionId, |
|
640
|
|
|
'processInstanceId' => $this->processInstanceId, |
|
641
|
|
|
'executionId' => $this->executionId, |
|
642
|
|
|
'taskId' => $this->taskId, |
|
643
|
|
|
'activityInstanceId' => $this->activityInstanceId, |
|
644
|
|
|
'tenantId' => $this->tenantId, |
|
645
|
|
|
'longValue' => $this->longValue, |
|
646
|
|
|
'doubleValue' => $this->doubleValue, |
|
647
|
|
|
'textValue' => $this->textValue, |
|
648
|
|
|
'textValue2' => $this->textValue2, |
|
649
|
|
|
'byteArrayValueId' => $this->byteArrayValueId, |
|
650
|
|
|
'configuration' => $this->configuration, |
|
651
|
|
|
'isConcurrentLocal' => $this->isConcurrentLocal |
|
652
|
|
|
]); |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
public function unserialize($data) |
|
656
|
|
|
{ |
|
657
|
|
|
$json = json_decode($data); |
|
658
|
|
|
$this->id = $json->id; |
|
659
|
|
|
$this->revision = $json->revision; |
|
660
|
|
|
$this->name = $json->name; |
|
661
|
|
|
$this->processDefinitionId = $json->processDefinitionId; |
|
662
|
|
|
$this->processInstanceId = $json->processInstanceId; |
|
663
|
|
|
$this->executionId = $json->executionId; |
|
664
|
|
|
$this->taskId = $json->taskId; |
|
665
|
|
|
$this->activityInstanceId = $json->activityInstanceId; |
|
666
|
|
|
$this->tenantId = $json->tenantId; |
|
667
|
|
|
$this->longValue = $json->longValue; |
|
668
|
|
|
$this->doubleValue = $json->doubleValue; |
|
669
|
|
|
$this->textValue = $json->textValue; |
|
670
|
|
|
$this->textValue2 = $json->textValue2; |
|
671
|
|
|
$this->byteArrayValueId = $json->byteArrayValueId; |
|
|
|
|
|
|
672
|
|
|
$this->configuration = $json->configuration; |
|
673
|
|
|
$this->isConcurrentLocal = $json->isConcurrentLocal; |
|
674
|
|
|
} |
|
675
|
|
|
|
|
676
|
|
|
public function __toString() |
|
677
|
|
|
{ |
|
678
|
|
|
$className = ClassNameUtil::getClassNameWithoutPackage(get_class($this)); |
|
679
|
|
|
return $className |
|
680
|
|
|
. "[id=" . $this->id |
|
681
|
|
|
. ", revision=" . $this->revision |
|
682
|
|
|
. ", name=" . $this->name |
|
683
|
|
|
. ", processDefinitionId=" . $this->processDefinitionId |
|
684
|
|
|
. ", processInstanceId=" . $this->processInstanceId |
|
685
|
|
|
. ", executionId=" . $this->executionId |
|
686
|
|
|
//. ", caseInstanceId=" . caseInstanceId |
|
687
|
|
|
//. ", caseExecutionId=" . caseExecutionId |
|
688
|
|
|
. ", taskId=" . $this->taskId |
|
689
|
|
|
. ", activityInstanceId=" . $this->activityInstanceId |
|
690
|
|
|
. ", tenantId=" . $this->tenantId |
|
691
|
|
|
. ", longValue=" . $this->longValue |
|
692
|
|
|
. ", doubleValue=" . $this->doubleValue |
|
693
|
|
|
. ", textValue=" . $this->textValue |
|
694
|
|
|
. ", textValue2=" . $this->textValue2 |
|
695
|
|
|
. ", byteArrayValueId=" . $this->getByteArrayValueId() |
|
696
|
|
|
. ", configuration=" . $this->configuration |
|
697
|
|
|
. ", isConcurrentLocal=" . $this->isConcurrentLocal |
|
698
|
|
|
. "]"; |
|
699
|
|
|
} |
|
700
|
|
|
|
|
701
|
|
|
public function equals($obj): bool |
|
702
|
|
|
{ |
|
703
|
|
|
if ($this == $obj) { |
|
704
|
|
|
return true; |
|
705
|
|
|
} |
|
706
|
|
|
if ($obj === null) { |
|
707
|
|
|
return false; |
|
708
|
|
|
} |
|
709
|
|
|
if (get_class($this) != get_class($obj)) { |
|
710
|
|
|
return false; |
|
711
|
|
|
} |
|
712
|
|
|
if ($this->id === null) { |
|
713
|
|
|
if ($obj->id !== null) { |
|
714
|
|
|
return false; |
|
715
|
|
|
} |
|
716
|
|
|
} elseif ($this->id != $obj->id) { |
|
717
|
|
|
return false; |
|
718
|
|
|
} |
|
719
|
|
|
return true; |
|
720
|
|
|
} |
|
721
|
|
|
|
|
722
|
|
|
/** |
|
723
|
|
|
* @param isTransient |
|
724
|
|
|
* <code>true</code>, if the variable is not stored in the data base. |
|
725
|
|
|
* Default is <code>false</code>. |
|
726
|
|
|
*/ |
|
727
|
|
|
public function setTransient(bool $isTransient): void |
|
728
|
|
|
{ |
|
729
|
|
|
$this->isTransient = $isTransient; |
|
730
|
|
|
} |
|
731
|
|
|
|
|
732
|
|
|
/** |
|
733
|
|
|
* @return bool true, if the variable is transient. A transient |
|
734
|
|
|
* variable is not stored in the data base. |
|
735
|
|
|
*/ |
|
736
|
|
|
public function isTransient(): bool |
|
737
|
|
|
{ |
|
738
|
|
|
return $this->isTransient; |
|
739
|
|
|
} |
|
740
|
|
|
|
|
741
|
|
|
public function getTenantId(): ?string |
|
742
|
|
|
{ |
|
743
|
|
|
return $this->tenantId; |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
public function setTenantId(?string $tenantId): void |
|
747
|
|
|
{ |
|
748
|
|
|
$this->tenantId = $tenantId; |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
public function getReferencedEntityIds(): array |
|
752
|
|
|
{ |
|
753
|
|
|
$referencedEntityIds = []; |
|
754
|
|
|
return $referencedEntityIds; |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
public function getReferencedEntitiesIdAndClass(): array |
|
758
|
|
|
{ |
|
759
|
|
|
$referenceIdAndClass = []; |
|
760
|
|
|
|
|
761
|
|
|
if ($this->processInstanceId !== null) { |
|
762
|
|
|
$referenceIdAndClass[$this->processInstanceId] = ExecutionEntity::class; |
|
763
|
|
|
} |
|
764
|
|
|
if ($this->executionId !== null) { |
|
765
|
|
|
$referenceIdAndClass[$this->executionId] = ExecutionEntity::class; |
|
766
|
|
|
} |
|
767
|
|
|
/*if (caseInstanceId !== null){ |
|
768
|
|
|
referenceIdAndClass.put(caseInstanceId, CaseExecutionEntity::class); |
|
769
|
|
|
} |
|
770
|
|
|
if (caseExecutionId !== null){ |
|
771
|
|
|
referenceIdAndClass.put(caseExecutionId, CaseExecutionEntity::class); |
|
772
|
|
|
}*/ |
|
773
|
|
|
if ($this->getByteArrayValueId() !== null) { |
|
|
|
|
|
|
774
|
|
|
$referenceIdAndClass[$this->getByteArrayValueId()] = ByteArrayEntity::class; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
return $referenceIdAndClass; |
|
778
|
|
|
} |
|
779
|
|
|
} |
|
780
|
|
|
|