1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jabe\Engine\Impl\Util; |
4
|
|
|
|
5
|
|
|
use Jabe\Engine\ProcessEngineException; |
6
|
|
|
use Jabe\Engine\Delegate\VariableScopeInterface; |
7
|
|
|
use Jabe\Engine\Impl\Context\Context; |
8
|
|
|
use Jabe\Engine\Impl\Core\Model\BaseCallableElement; |
9
|
|
|
use Jabe\Engine\Impl\El\StartProcessVariableScope; |
10
|
|
|
use Jabe\Engine\Impl\Persistence\Deploy\Cache\DeploymentCache; |
11
|
|
|
use Jabe\Engine\Impl\Persistence\Entity\ProcessDefinitionEntity; |
12
|
|
|
use Jabe\Engine\Impl\Pvm\Process\ProcessDefinitionImpl; |
13
|
|
|
use Jabe\Engine\Repository\ProcessDefinitionInterface; |
14
|
|
|
|
15
|
|
|
class CallableElementUtil |
16
|
|
|
{ |
17
|
|
|
public static function getDeploymentCache(): DeploymentCache |
18
|
|
|
{ |
19
|
|
|
return Context::getProcessEngineConfiguration() |
20
|
|
|
->getDeploymentCache(); |
|
|
|
|
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public static function getProcessDefinitionToCall( |
24
|
|
|
VariableScopeInterface $execution, |
25
|
|
|
string $defaultTenantId, |
26
|
|
|
BaseCallableElement $callableElement |
27
|
|
|
): ProcessDefinitionImpl { |
28
|
|
|
$processDefinitionKey = $callableElement->getDefinitionKey($execution); |
29
|
|
|
$tenantId = $callableElement->getDefinitionTenantId($execution, $defaultTenantId); |
|
|
|
|
30
|
|
|
|
31
|
|
|
return self::getCalledProcessDefinition($execution, $callableElement, $processDefinitionKey, $tenantId); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public static function getStaticallyBoundProcessDefinition( |
35
|
|
|
string $callingProcessDefinitionId, |
|
|
|
|
36
|
|
|
string $activityId, |
|
|
|
|
37
|
|
|
BaseCallableElement $callableElement, |
38
|
|
|
?string $tenantId |
39
|
|
|
): ?ProcessDefinitionInterface { |
40
|
|
|
if ($callableElement->hasDynamicReferences()) { |
|
|
|
|
41
|
|
|
return null; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$emptyVariableScope = StartProcessVariableScope::getSharedInstance(); |
45
|
|
|
|
46
|
|
|
$targetTenantId = $callableElement->getDefinitionTenantId($emptyVariableScope, $tenantId); |
|
|
|
|
47
|
|
|
|
48
|
|
|
try { |
49
|
|
|
$processDefinitionKey = $callableElement->getDefinitionKey($emptyVariableScope); |
50
|
|
|
return self::getCalledProcessDefinition($emptyVariableScope, $callableElement, $processDefinitionKey, $targetTenantId); |
51
|
|
|
} catch (\Exception $e) { |
52
|
|
|
//UTIL_LOGGER.debugCouldNotResolveCallableElement(callingProcessDefinitionId, activityId, e); |
53
|
|
|
return null; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private static function getCalledProcessDefinition( |
58
|
|
|
VariableScopeInterface $execution, |
59
|
|
|
BaseCallableElement $callableElement, |
60
|
|
|
string $processDefinitionKey, |
61
|
|
|
string $tenantId |
62
|
|
|
): ProcessDefinitionEntity { |
63
|
|
|
|
64
|
|
|
$deploymentCache = getDeploymentCache(); |
|
|
|
|
65
|
|
|
|
66
|
|
|
$processDefinition = null; |
67
|
|
|
|
68
|
|
|
if ($callableElement->isLatestBinding()) { |
69
|
|
|
$processDefinition = $deploymentCache->findDeployedLatestProcessDefinitionByKeyAndTenantId($processDefinitionKey, $tenantId); |
70
|
|
|
} elseif ($callableElement->isDeploymentBinding()) { |
71
|
|
|
$deploymentId = $callableElement->getDeploymentId(); |
72
|
|
|
$processDefinition = $deploymentCache->findDeployedProcessDefinitionByDeploymentAndKey($deploymentId, $processDefinitionKey); |
73
|
|
|
} elseif ($callableElement->isVersionBinding()) { |
74
|
|
|
$version = $callableElement->getVersion($execution); |
75
|
|
|
$processDefinition = $deploymentCache->findDeployedProcessDefinitionByKeyVersionAndTenantId($processDefinitionKey, $version, $tenantId); |
76
|
|
|
} elseif ($callableElement->isVersionTagBinding()) { |
77
|
|
|
$versionTag = $callableElement->getVersionTag($execution); |
78
|
|
|
$processDefinition = $deploymentCache->findDeployedProcessDefinitionByKeyVersionTagAndTenantId($processDefinitionKey, $versionTag, $tenantId); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $processDefinition; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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.