1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Repository; |
4
|
|
|
|
5
|
|
|
use Jabe\Engine\Impl\Cmd\{ |
6
|
|
|
DeleteProcessDefinitionsByIdsCmd, |
7
|
|
|
DeleteProcessDefinitionsByKeyCmd |
8
|
|
|
}; |
9
|
|
|
use Jabe\Engine\Impl\Interceptor\{ |
10
|
|
|
CommandInterface, |
11
|
|
|
CommandExecutorInterface |
12
|
|
|
}; |
13
|
|
|
use Jabe\Engine\Impl\Util\EnsureUtil; |
14
|
|
|
use Jabe\Engine\Repository\{ |
15
|
|
|
DeleteProcessDefinitionsBuilderInterface, |
16
|
|
|
DeleteProcessDefinitionsSelectBuilderInterface, |
17
|
|
|
DeleteProcessDefinitionsTenantBuilderInterface |
18
|
|
|
}; |
19
|
|
|
|
20
|
|
|
class DeleteProcessDefinitionsBuilderImpl implements DeleteProcessDefinitionsBuilderInterface, DeleteProcessDefinitionsSelectBuilderInterface, DeleteProcessDefinitionsTenantBuilderInterface |
21
|
|
|
{ |
22
|
|
|
private $commandExecutor; |
23
|
|
|
|
24
|
|
|
private $processDefinitionKey; |
25
|
|
|
private $processDefinitionIds = []; |
26
|
|
|
|
27
|
|
|
private $cascade; |
28
|
|
|
private $tenantId; |
29
|
|
|
private $isTenantIdSet; |
30
|
|
|
private $skipCustomListeners; |
31
|
|
|
protected $skipIoMappings; |
32
|
|
|
|
33
|
|
|
public function __construct(CommandExecutorInterface $commandExecutor) |
34
|
|
|
{ |
35
|
|
|
$this->commandExecutor = $commandExecutor; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function byIds(array $processDefinitionIds): DeleteProcessDefinitionsBuilderImpl |
39
|
|
|
{ |
40
|
|
|
if (!empty($processDefinitionId)) { |
|
|
|
|
41
|
|
|
$this->processDefinitionIds = array_merge($this->processDefinitionIds, $processDefinitionIds); |
42
|
|
|
} |
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function byKey(string $processDefinitionKey): DeleteProcessDefinitionsBuilderImpl |
47
|
|
|
{ |
48
|
|
|
$this->processDefinitionKey = $processDefinitionKey; |
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function withoutTenantId(): DeleteProcessDefinitionsBuilderImpl |
53
|
|
|
{ |
54
|
|
|
$this->isTenantIdSet = true; |
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function withTenantId(string $tenantId): DeleteProcessDefinitionsBuilderImpl |
59
|
|
|
{ |
60
|
|
|
EnsureUtil::ensureNotNull("tenantId", "tenantId", $tenantId); |
61
|
|
|
$this->isTenantIdSet = true; |
62
|
|
|
$this->tenantId = $tenantId; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function cascade(): DeleteProcessDefinitionsBuilderImpl |
67
|
|
|
{ |
68
|
|
|
$this->cascade = true; |
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function skipCustomListeners(): DeleteProcessDefinitionsBuilderImpl |
73
|
|
|
{ |
74
|
|
|
$this->skipCustomListeners = true; |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function skipIoMappings(): DeleteProcessDefinitionsBuilderImpl |
79
|
|
|
{ |
80
|
|
|
$this->skipIoMappings = true; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function delete(): void |
85
|
|
|
{ |
86
|
|
|
EnsureUtil::ensureOnlyOneNotNull("'processDefinitionKey' or 'processDefinitionIds' cannot be null", $this->processDefinitionKey, $this->processDefinitionIds); |
87
|
|
|
|
88
|
|
|
$command = null; |
89
|
|
|
if ($this->processDefinitionKey !== null) { |
90
|
|
|
$command = new DeleteProcessDefinitionsByKeyCmd($this->processDefinitionKey, $this->cascade, $this->skipCustomListeners, $this->skipIoMappings, $this->tenantId, $this->isTenantIdSet); |
91
|
|
|
} elseif (!empty($this->processDefinitionIds)) { |
92
|
|
|
$command = new DeleteProcessDefinitionsByIdsCmd($this->processDefinitionIds, $this->cascade, $this->skipCustomListeners, $this->skipIoMappings); |
93
|
|
|
} else { |
94
|
|
|
return; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
$this->commandExecutor->execute($command); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|