|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Batch\Deletion; |
|
4
|
|
|
|
|
5
|
|
|
use Jabe\Engine\Batch\BatchInterface; |
|
6
|
|
|
use Jabe\Engine\Impl\ProcessInstanceQueryImpl; |
|
|
|
|
|
|
7
|
|
|
use Jabe\Engine\Impl\Batch\{ |
|
8
|
|
|
AbstractBatchJobHandler, |
|
|
|
|
|
|
9
|
|
|
BatchEntity, |
|
|
|
|
|
|
10
|
|
|
BatchJobConfiguration, |
|
|
|
|
|
|
11
|
|
|
BatchJobContext, |
|
|
|
|
|
|
12
|
|
|
BatchJobDeclaration, |
|
|
|
|
|
|
13
|
|
|
BatchElementConfiguration |
|
|
|
|
|
|
14
|
|
|
}; |
|
15
|
|
|
use Jabe\Engine\Impl\Cmd\DeleteProcessInstancesCmd; |
|
16
|
|
|
use Jabe\Engine\Impl\Interceptor\CommandContext; |
|
17
|
|
|
use Jabe\Engine\Impl\JobExecutor\{ |
|
18
|
|
|
JobDeclaration, |
|
19
|
|
|
JobHandlerConfigurationInterface |
|
20
|
|
|
}; |
|
21
|
|
|
use Jabe\Engine\Impl\Persistence\Entity\{ |
|
22
|
|
|
ByteArrayEntity, |
|
23
|
|
|
ExecutionEntity, |
|
24
|
|
|
MessageEntity |
|
25
|
|
|
}; |
|
26
|
|
|
|
|
27
|
|
|
class DeleteProcessInstancesJobHandler extends AbstractBatchJobHandler |
|
28
|
|
|
{ |
|
29
|
|
|
public static $JOB_DECLARATION; |
|
30
|
|
|
|
|
31
|
|
|
public function getType(): string |
|
32
|
|
|
{ |
|
33
|
|
|
return BatchInterface::TYPE_PROCESS_INSTANCE_DELETION; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function getJsonConverterInstance(): DeleteProcessInstanceBatchConfigurationJsonConverter |
|
37
|
|
|
{ |
|
38
|
|
|
return DeleteProcessInstanceBatchConfigurationJsonConverter::instance(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getJobDeclaration(): JobDeclaration |
|
42
|
|
|
{ |
|
43
|
|
|
if (self::$JOB_DECLARATION == null) { |
|
44
|
|
|
self::$JOB_DECLARATION = new BatchJobDeclaration(BatchInterface::TYPE_PROCESS_INSTANCE_DELETION); |
|
45
|
|
|
} |
|
46
|
|
|
return self::$JOB_DECLARATION; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function createJobConfiguration(DeleteProcessInstanceBatchConfiguration $configuration, array $processIdsForJob): DeleteProcessInstanceBatchConfiguration |
|
50
|
|
|
{ |
|
51
|
|
|
return new DeleteProcessInstanceBatchConfiguration($processIdsForJob, null, $configuration->getDeleteReason(), $configuration->isSkipCustomListeners(), $configuration->isSkipSubprocesses(), $configuration->isFailIfNotExists()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function execute(JobHandlerConfigurationInterface $configuration, ExecutionEntity $execution, CommandContext $commandContext, ?string $tenantId): void |
|
55
|
|
|
{ |
|
56
|
|
|
$configurationEntity = $commandContext |
|
57
|
|
|
->getDbEntityManager() |
|
58
|
|
|
->selectById(ByteArrayEntity::class, $configuration->getConfigurationByteArrayId()); |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
$batchConfiguration = $this->readConfiguration($configurationEntity->getBytes()); |
|
61
|
|
|
|
|
62
|
|
|
$commandContext->executeWithOperationLogPrevented( |
|
63
|
|
|
new DeleteProcessInstancesCmd( |
|
64
|
|
|
$batchConfiguration->getIds(), |
|
65
|
|
|
$batchConfiguration->getDeleteReason(), |
|
66
|
|
|
$batchConfiguration->isSkipCustomListeners(), |
|
67
|
|
|
true, |
|
68
|
|
|
$batchConfiguration->isSkipSubprocesses(), |
|
69
|
|
|
$batchConfiguration->isFailIfNotExists() |
|
70
|
|
|
) |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
$commandContext->getByteArrayManager()->delete($configurationEntity); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
protected function createJobEntities(BatchEntity $batch, DeleteProcessInstanceBatchConfiguration $configuration, ?string $deploymentId, array $processIds, int $invocationsPerBatchJob): void |
|
77
|
|
|
{ |
|
78
|
|
|
// handle legacy batch entities (no up-front deployment mapping has been done) |
|
79
|
|
|
if ($deploymentId == null && ($configuration->getIdMappings() == null || $configuration->getIdMappings()->isEmpty())) { |
|
|
|
|
|
|
80
|
|
|
// create deployment mappings for the ids to process |
|
81
|
|
|
$elementConfiguration = new BatchElementConfiguration(); |
|
82
|
|
|
$query = new ProcessInstanceQueryImpl(); |
|
83
|
|
|
$query->processInstanceIds($configuration->getIds()); |
|
84
|
|
|
$elementConfiguration->addDeploymentMappings($query->listDeploymentIdMappings(), $configuration->getIds()); |
|
85
|
|
|
// create jobs by deployment id |
|
86
|
|
|
$parent = parent; |
|
|
|
|
|
|
87
|
|
|
$elementConfiguration->getMappings()->forEach(function ($mapping) use ($parent, $batch, $configuration, $processIds, $invocationsPerBatchJob) { |
|
88
|
|
|
$parent->createJobEntities( |
|
89
|
|
|
$batch, |
|
90
|
|
|
$configuration, |
|
91
|
|
|
$mapping->getDeploymentId(), |
|
92
|
|
|
$mapping->getIds($processIds), |
|
93
|
|
|
$invocationsPerBatchJob |
|
94
|
|
|
); |
|
95
|
|
|
}); |
|
96
|
|
|
} else { |
|
97
|
|
|
parent::createJobEntities($batch, $configuration, $deploymentId, $processIds, $invocationsPerBatchJob); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths