Issues (2551)

UpdateJobDefinitionSuspensionStateBuilderImpl.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Jabe\Impl\Management;
4
5
use Jabe\Impl\ProcessEngineLogger;
6
use Jabe\Impl\Cmd\{
7
    ActivateJobDefinitionCmd,
8
    CommandLogger,
9
    SuspendJobDefinitionCmd
10
};
11
use Jabe\Impl\Interceptor\CommandExecutorInterface;
12
use Jabe\Impl\Util\EnsureUtil;
13
use Jabe\Management\{
14
    UpdateJobDefinitionSuspensionStateBuilderInterface,
15
    UpdateJobDefinitionSuspensionStateSelectBuilderInterface,
16
    UpdateJobDefinitionSuspensionStateTenantBuilderInterface
17
};
18
19
class UpdateJobDefinitionSuspensionStateBuilderImpl implements UpdateJobDefinitionSuspensionStateBuilderInterface, UpdateJobDefinitionSuspensionStateSelectBuilderInterface, UpdateJobDefinitionSuspensionStateTenantBuilderInterface
20
{
21
    //private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER;
22
23
    protected $commandExecutor;
24
25
    protected $jobDefinitionId;
26
27
    protected $processDefinitionKey;
28
    protected $processDefinitionId;
29
30
    protected $processDefinitionTenantId;
31
    protected $isProcessDefinitionTenantIdSet = false;
32
33
    protected $includeJobs = false;
34
    protected $executionDate;
35
36
    public function __construct(CommandExecutorInterface $commandExecutor = null)
37
    {
38
        $this->commandExecutor = $commandExecutor;
39
    }
40
41
    public function byJobDefinitionId(string $jobDefinitionId): UpdateJobDefinitionSuspensionStateBuilderImpl
42
    {
43
        EnsureUtil::ensureNotNull("jobDefinitionId", "jobDefinitionId", $jobDefinitionId);
44
        $this->jobDefinitionId = $jobDefinitionId;
45
        return $this;
46
    }
47
48
    public function byProcessDefinitionId(string $processDefinitionId): UpdateJobDefinitionSuspensionStateBuilderImpl
49
    {
50
        EnsureUtil::ensureNotNull("processDefinitionId", "processDefinitionId", $processDefinitionId);
51
        $this->processDefinitionId = $processDefinitionId;
52
        return $this;
53
    }
54
55
    public function byProcessDefinitionKey(string $processDefinitionKey): UpdateJobDefinitionSuspensionStateBuilderImpl
56
    {
57
        EnsureUtil::ensureNotNull("processDefinitionKey", "processDefinitionKey", $processDefinitionKey);
58
        $this->processDefinitionKey = $processDefinitionKey;
59
        return $this;
60
    }
61
62
    public function processDefinitionWithoutTenantId(): UpdateJobDefinitionSuspensionStateBuilderImpl
63
    {
64
        $this->processDefinitionTenantId = null;
65
        $this->isProcessDefinitionTenantIdSet = true;
66
        return $this;
67
    }
68
69
    public function processDefinitionTenantId(string $tenantId): UpdateJobDefinitionSuspensionStateBuilderImpl
70
    {
71
        EnsureUtil::ensureNotNull("tenantId", "tenantId", $tenantId);
72
        $this->processDefinitionTenantId = $tenantId;
73
        $this->isProcessDefinitionTenantIdSet = true;
74
        return $this;
75
    }
76
77
    public function includeJobs(bool $includeJobs): UpdateJobDefinitionSuspensionStateBuilderImpl
78
    {
79
        $this->includeJobs = $includeJobs;
80
        return $this;
81
    }
82
83
    public function executionDate(string $executionDate): UpdateJobDefinitionSuspensionStateBuilderImpl
84
    {
85
        $this->executionDate = $executionDate;
86
        return $this;
87
    }
88
89
    public function activate(): void
90
    {
91
        $this->validateParameters();
92
        $command = new ActivateJobDefinitionCmd($this);
93
        $this->commandExecutor->execute($command);
0 ignored issues
show
The method execute() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

93
        $this->commandExecutor->/** @scrutinizer ignore-call */ 
94
                                execute($command);

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.

Loading history...
94
    }
95
96
    public function suspend(): void
97
    {
98
        $this->validateParameters();
99
        $command = new SuspendJobDefinitionCmd($this);
100
        $this->commandExecutor->execute($command);
101
    }
102
103
    protected function validateParameters(): void
104
    {
105
        EnsureUtil::ensureOnlyOneNotNull(
106
            "Need to specify either a job definition id, a process definition id or a process definition key.",
107
            $this->jobDefinitionId,
108
            $this->processDefinitionId,
109
            $this->processDefinitionKey
110
        );
111
112
        if ($this->isProcessDefinitionTenantIdSet && ($this->jobDefinitionId !== null || $this->processDefinitionId !== null)) {
113
            //throw LOG.exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey();
114
            throw new \Exception("exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey");
115
        }
116
117
        EnsureUtil::ensureNotNull("commandExecutor", "commandExecutor", $this->commandExecutor);
118
    }
119
120
    public function getProcessDefinitionKey(): string
121
    {
122
        return $this->processDefinitionKey;
123
    }
124
125
    public function getProcessDefinitionId(): string
126
    {
127
        return $this->processDefinitionId;
128
    }
129
130
    public function getProcessDefinitionTenantId(): string
131
    {
132
        return $this->processDefinitionTenantId;
133
    }
134
135
    public function isProcessDefinitionTenantIdSet(): bool
136
    {
137
        return $this->isProcessDefinitionTenantIdSet;
138
    }
139
140
    public function getJobDefinitionId(): string
141
    {
142
        return $this->jobDefinitionId;
143
    }
144
145
    public function isIncludeJobs(): bool
146
    {
147
        return $this->includeJobs;
148
    }
149
150
    public function getExecutionDate(): string
151
    {
152
        return $this->executionDate;
153
    }
154
}
155