|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Batch\RemovalTime; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Engine\Batch\BatchInterface; |
|
6
|
|
|
use Jabe\Engine\Impl\UpdateProcessInstancesSuspensionStateBuilderImpl; |
|
7
|
|
|
use Jabe\Engine\Impl\Batch\{ |
|
8
|
|
|
AbstractBatchJobHandler, |
|
9
|
|
|
BatchJobConfiguration, |
|
10
|
|
|
BatchJobContext, |
|
11
|
|
|
BatchJobDeclaration |
|
12
|
|
|
}; |
|
13
|
|
|
use Jabe\Engine\Impl\Cmd\UpdateProcessInstancesSuspendStateCmd; |
|
14
|
|
|
use Jabe\Engine\Impl\Interceptor\{ |
|
15
|
|
|
CommandContext, |
|
16
|
|
|
CommandExecutorInterface |
|
17
|
|
|
}; |
|
18
|
|
|
use Jabe\Engine\Impl\JobExecutor\JobDeclaration; |
|
19
|
|
|
use Jabe\Engine\Impl\Json\JsonObjectConverter; |
|
20
|
|
|
use Jabe\Engine\Impl\Persistence\Entity\{ |
|
21
|
|
|
ByteArrayEntity, |
|
22
|
|
|
ExecutionEntity, |
|
23
|
|
|
MessageEntity |
|
24
|
|
|
}; |
|
25
|
|
|
|
|
26
|
|
|
class UpdateProcessInstancesSuspendStateJobHandler extends AbstractBatchJobHandler |
|
27
|
|
|
{ |
|
28
|
|
|
public static $JOB_DECLARATION; |
|
29
|
|
|
|
|
30
|
|
|
public function getType(): string |
|
31
|
|
|
{ |
|
32
|
|
|
return BatchInterface::TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function getJsonConverterInstance(): JsonObjectConverter |
|
36
|
|
|
{ |
|
37
|
|
|
return UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter::instance(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getJobDeclaration(): JobDeclaration |
|
41
|
|
|
{ |
|
42
|
|
|
if (self::$JOB_DECLARATION === null) { |
|
43
|
|
|
self::$JOB_DECLARATION = new BatchJobDeclaration(BatchInterface::TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE); |
|
44
|
|
|
} |
|
45
|
|
|
return self::$JOB_DECLARATION; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function createJobConfiguration(BatchConfiguration $configuration, array $processIdsForJob): BatchConfiguration |
|
49
|
|
|
{ |
|
50
|
|
|
return new UpdateProcessInstancesSuspendStateBatchConfiguration($processIdsForJob, $configuration->getSuspended()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function execute(BatchJobConfiguration $configuration, ExecutionEntity $execution, CommandContext $commandContext, string $tenantId = null) |
|
54
|
|
|
{ |
|
55
|
|
|
$configurationEntity = $commandContext |
|
56
|
|
|
->getDbEntityManager() |
|
57
|
|
|
->selectById(ByteArrayEntity::class, $configuration->getConfigurationByteArrayId()); |
|
58
|
|
|
|
|
59
|
|
|
$batchConfiguration = $this->readConfiguration($configurationEntity->getBytes()); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
$commandExecutor = $commandContext->getProcessEngineConfiguration() |
|
62
|
|
|
->getCommandExecutorTxRequired(); |
|
|
|
|
|
|
63
|
|
|
$commandContext->executeWithOperationLogPrevented( |
|
64
|
|
|
new UpdateProcessInstancesSuspendStateCmd( |
|
65
|
|
|
$commandExecutor, |
|
66
|
|
|
new UpdateProcessInstancesSuspensionStateBuilderImpl($batchConfiguration->getIds()), |
|
67
|
|
|
$batchConfiguration->getSuspended() |
|
|
|
|
|
|
68
|
|
|
) |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|