Total Complexity | 204 |
Total Lines | 1121 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like HistoricTaskInstanceQueryImpl often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use HistoricTaskInstanceQueryImpl, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | class HistoricTaskInstanceQueryImpl extends AbstractQuery implements HistoricTaskInstanceQueryInterface |
||
23 | { |
||
24 | protected $processDefinitionId; |
||
25 | protected $processDefinitionKey; |
||
26 | protected $processDefinitionName; |
||
27 | protected $processInstanceId; |
||
28 | protected $processInstanceBusinessKey; |
||
29 | protected $processInstanceBusinessKeys = []; |
||
30 | protected $processInstanceBusinessKeyLike; |
||
31 | protected $executionId; |
||
32 | protected $activityInstanceIds = []; |
||
33 | protected $taskId; |
||
34 | protected $taskName; |
||
35 | protected $taskNameLike; |
||
36 | protected $taskParentTaskId; |
||
37 | protected $taskDescription; |
||
38 | protected $taskDescriptionLike; |
||
39 | protected $taskDeleteReason; |
||
40 | protected $taskDeleteReasonLike; |
||
41 | protected $taskOwner; |
||
42 | protected $taskOwnerLike; |
||
43 | protected $assigned; |
||
44 | protected $unassigned; |
||
45 | protected $taskAssignee; |
||
46 | protected $taskAssigneeLike; |
||
47 | protected $taskDefinitionKeys = []; |
||
48 | protected $taskInvolvedUser; |
||
49 | protected $taskInvolvedGroup; |
||
50 | protected $taskHadCandidateUser; |
||
51 | protected $taskHadCandidateGroup; |
||
52 | protected $withCandidateGroups; |
||
53 | protected $withoutCandidateGroups; |
||
54 | protected $taskPriority; |
||
55 | protected $finished; |
||
56 | protected $unfinished; |
||
57 | protected $processFinished; |
||
58 | protected $processUnfinished; |
||
59 | protected $variables = []; |
||
60 | protected $variableNamesIgnoreCase; |
||
61 | protected $variableValuesIgnoreCase; |
||
62 | |||
63 | protected $dueDate; |
||
64 | protected $dueAfter; |
||
65 | protected $dueBefore; |
||
66 | protected $isWithoutTaskDueDate; |
||
67 | |||
68 | protected $followUpDate; |
||
69 | protected $followUpBefore; |
||
70 | protected $followUpAfter; |
||
71 | |||
72 | protected $tenantIds = []; |
||
73 | protected $isTenantIdSet; |
||
74 | |||
75 | protected $caseDefinitionId; |
||
76 | protected $caseDefinitionKey; |
||
77 | protected $caseDefinitionName; |
||
78 | protected $caseInstanceId; |
||
79 | protected $caseExecutionId; |
||
80 | |||
81 | protected $finishedAfter; |
||
82 | protected $finishedBefore; |
||
83 | protected $startedAfter; |
||
84 | protected $startedBefore; |
||
85 | |||
86 | protected $queries = []; |
||
87 | protected $isOrQueryActive = false; |
||
88 | |||
89 | public function __construct(CommandExecutorInterface $commandExecutor) |
||
90 | { |
||
91 | parent::__construct($commandExecutor); |
||
92 | $this->queries[] = $this; |
||
93 | } |
||
94 | |||
95 | public function executeCount(CommandContext $commandContext): int |
||
96 | { |
||
97 | $this->ensureVariablesInitialized(); |
||
98 | $this->checkQueryOk(); |
||
99 | return $commandContext |
||
100 | ->getHistoricTaskInstanceManager() |
||
101 | ->findHistoricTaskInstanceCountByQueryCriteria($this); |
||
102 | } |
||
103 | |||
104 | public function executeList(CommandContext $commandContext, Page $page): array |
||
105 | { |
||
106 | $this->ensureVariablesInitialized(); |
||
107 | $this->checkQueryOk(); |
||
108 | return $commandContext |
||
109 | ->getHistoricTaskInstanceManager() |
||
110 | ->findHistoricTaskInstancesByQueryCriteria($this, $page); |
||
111 | } |
||
112 | |||
113 | public function processInstanceId(string $processInstanceId): HistoricTaskInstanceQueryImpl |
||
114 | { |
||
115 | $this->processInstanceId = $processInstanceId; |
||
116 | return $this; |
||
117 | } |
||
118 | |||
119 | public function processInstanceBusinessKey(string $processInstanceBusinessKey): HistoricTaskInstanceQueryInterface |
||
120 | { |
||
121 | $this->processInstanceBusinessKey = $processInstanceBusinessKey; |
||
122 | return $this; |
||
123 | } |
||
124 | |||
125 | public function processInstanceBusinessKeyIn(array $processInstanceBusinessKeys): HistoricTaskInstanceQueryInterface |
||
126 | { |
||
127 | EnsureUtil::ensureNotNull("processInstanceBusinessKeys", "processInstanceBusinessKeys", $processInstanceBusinessKeys); |
||
128 | $this->processInstanceBusinessKeys = $processInstanceBusinessKeys; |
||
129 | return $this; |
||
130 | } |
||
131 | |||
132 | public function processInstanceBusinessKeyLike(string $processInstanceBusinessKey): HistoricTaskInstanceQueryInterface |
||
133 | { |
||
134 | $this->processInstanceBusinessKeyLike = $processInstanceBusinessKey; |
||
135 | return $this; |
||
136 | } |
||
137 | |||
138 | public function executionId(string $executionId): HistoricTaskInstanceQueryImpl |
||
139 | { |
||
140 | $this->executionId = $executionId; |
||
141 | return $this; |
||
142 | } |
||
143 | |||
144 | public function activityInstanceIdIn(array $activityInstanceIds): HistoricTaskInstanceQueryInterface |
||
145 | { |
||
146 | EnsureUtil::ensureNotNull("activityInstanceIds", "activityInstanceIds", $activityInstanceIds); |
||
147 | $this->activityInstanceIds = $activityInstanceIds; |
||
148 | return $this; |
||
149 | } |
||
150 | |||
151 | public function processDefinitionId(string $processDefinitionId): HistoricTaskInstanceQueryImpl |
||
152 | { |
||
153 | $this->processDefinitionId = $processDefinitionId; |
||
154 | return $this; |
||
155 | } |
||
156 | |||
157 | public function processDefinitionKey(string $processDefinitionKey): HistoricTaskInstanceQueryInterface |
||
158 | { |
||
159 | $this->processDefinitionKey = $processDefinitionKey; |
||
160 | return $this; |
||
161 | } |
||
162 | |||
163 | public function processDefinitionName(string $processDefinitionName): HistoricTaskInstanceQueryInterface |
||
164 | { |
||
165 | $this->processDefinitionName = $processDefinitionName; |
||
166 | return $this; |
||
167 | } |
||
168 | |||
169 | public function taskId(string $taskId): HistoricTaskInstanceQueryInterface |
||
170 | { |
||
171 | $this->taskId = $taskId; |
||
172 | return $this; |
||
173 | } |
||
174 | |||
175 | public function taskName(string $taskName): HistoricTaskInstanceQueryImpl |
||
176 | { |
||
177 | $this->taskName = $taskName; |
||
178 | return $this; |
||
179 | } |
||
180 | |||
181 | public function taskNameLike(string $taskNameLike): HistoricTaskInstanceQueryImpl |
||
182 | { |
||
183 | $this->taskNameLike = $taskNameLike; |
||
184 | return $this; |
||
185 | } |
||
186 | |||
187 | public function taskParentTaskId(string $parentTaskId): HistoricTaskInstanceQueryInterface |
||
188 | { |
||
189 | $this->taskParentTaskId = $parentTaskId; |
||
190 | return $this; |
||
191 | } |
||
192 | |||
193 | public function taskDescription(string $taskDescription): HistoricTaskInstanceQueryImpl |
||
194 | { |
||
195 | $this->taskDescription = $taskDescription; |
||
196 | return $this; |
||
197 | } |
||
198 | |||
199 | public function taskDescriptionLike(string $taskDescriptionLike): HistoricTaskInstanceQueryImpl |
||
200 | { |
||
201 | $this->taskDescriptionLike = $taskDescriptionLike; |
||
202 | return $this; |
||
203 | } |
||
204 | |||
205 | public function taskDeleteReason(string $taskDeleteReason): HistoricTaskInstanceQueryImpl |
||
206 | { |
||
207 | $this->taskDeleteReason = $taskDeleteReason; |
||
208 | return $this; |
||
209 | } |
||
210 | |||
211 | public function taskDeleteReasonLike(string $taskDeleteReasonLike): HistoricTaskInstanceQueryImpl |
||
212 | { |
||
213 | $this->taskDeleteReasonLike = $taskDeleteReasonLike; |
||
214 | return $this; |
||
215 | } |
||
216 | |||
217 | public function taskAssigned(): HistoricTaskInstanceQueryImpl |
||
218 | { |
||
219 | $this->assigned = true; |
||
220 | return $this; |
||
221 | } |
||
222 | |||
223 | public function taskUnassigned(): HistoricTaskInstanceQueryImpl |
||
224 | { |
||
225 | $this->unassigned = true; |
||
226 | return $this; |
||
227 | } |
||
228 | |||
229 | public function taskAssignee(string $taskAssignee): HistoricTaskInstanceQueryImpl |
||
230 | { |
||
231 | $this->taskAssignee = $taskAssignee; |
||
232 | return $this; |
||
233 | } |
||
234 | |||
235 | public function taskAssigneeLike(string $taskAssigneeLike): HistoricTaskInstanceQueryImpl |
||
236 | { |
||
237 | $this->taskAssigneeLike = $taskAssigneeLike; |
||
238 | return $this; |
||
239 | } |
||
240 | |||
241 | public function taskOwner(string $taskOwner): HistoricTaskInstanceQueryImpl |
||
242 | { |
||
243 | $this->taskOwner = $taskOwner; |
||
244 | return $this; |
||
245 | } |
||
246 | |||
247 | public function taskOwnerLike(string $taskOwnerLike): HistoricTaskInstanceQueryImpl |
||
248 | { |
||
249 | $this->taskOwnerLike = $taskOwnerLike; |
||
250 | return $this; |
||
251 | } |
||
252 | |||
253 | /*public HistoricTaskInstanceQueryInterface caseDefinitionId(string $caseDefinitionId) { |
||
254 | $this->caseDefinitionId = caseDefinitionId; |
||
255 | return $this; |
||
256 | } |
||
257 | |||
258 | public HistoricTaskInstanceQueryInterface caseDefinitionKey(string $caseDefinitionKey) { |
||
259 | $this->caseDefinitionKey = caseDefinitionKey; |
||
260 | return $this; |
||
261 | } |
||
262 | |||
263 | public HistoricTaskInstanceQueryInterface caseDefinitionName(string $caseDefinitionName) { |
||
264 | $this->caseDefinitionName = caseDefinitionName; |
||
265 | return $this; |
||
266 | } |
||
267 | |||
268 | public HistoricTaskInstanceQueryInterface caseInstanceId(string $caseInstanceId) { |
||
269 | $this->caseInstanceId = caseInstanceId; |
||
270 | return $this; |
||
271 | } |
||
272 | |||
273 | public HistoricTaskInstanceQueryInterface caseExecutionId(string $caseExecutionId) { |
||
274 | $this->caseExecutionId = caseExecutionId; |
||
275 | return $this; |
||
276 | }*/ |
||
277 | |||
278 | public function finished(): HistoricTaskInstanceQueryImpl |
||
279 | { |
||
280 | $this->finished = true; |
||
281 | return $this; |
||
282 | } |
||
283 | |||
284 | public function unfinished(): HistoricTaskInstanceQueryImpl |
||
285 | { |
||
286 | $this->unfinished = true; |
||
287 | return $this; |
||
288 | } |
||
289 | |||
290 | public function matchVariableNamesIgnoreCase(): HistoricTaskInstanceQueryInterface |
||
291 | { |
||
292 | $this->variableNamesIgnoreCase = true; |
||
293 | foreach ($this->variables as $variable) { |
||
294 | $variable->setVariableNameIgnoreCase(true); |
||
295 | } |
||
296 | return $this; |
||
297 | } |
||
298 | |||
299 | public function matchVariableValuesIgnoreCase(): HistoricTaskInstanceQueryInterface |
||
300 | { |
||
301 | $this->variableValuesIgnoreCase = true; |
||
302 | foreach ($this->variables as $variable) { |
||
303 | $variable->setVariableValueIgnoreCase(true); |
||
304 | } |
||
305 | return $this; |
||
306 | } |
||
307 | |||
308 | public function taskVariableValueEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryImpl |
||
309 | { |
||
310 | $this->addVariable($variableName, $variableValue, QueryOperator::EQUALS, true, false); |
||
311 | return $this; |
||
312 | } |
||
313 | |||
314 | public function processVariableValueEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
315 | { |
||
316 | $this->addVariable($variableName, $variableValue, QueryOperator::EQUALS, false, true); |
||
317 | return $this; |
||
318 | } |
||
319 | |||
320 | public function processVariableValueNotEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
321 | { |
||
322 | $this->addVariable($variableName, $variableValue, QueryOperator::NOT_EQUALS, false, true); |
||
323 | return $this; |
||
324 | } |
||
325 | |||
326 | public function processVariableValueLike(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
327 | { |
||
328 | $this->addVariable($variableName, $variableValue, QueryOperator::LIKE, false, true); |
||
329 | return $this; |
||
330 | } |
||
331 | |||
332 | public function processVariableValueNotLike(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
333 | { |
||
334 | $this->addVariable($variableName, $variableValue, QueryOperator::NOT_LIKE, false, true); |
||
335 | return $this; |
||
336 | } |
||
337 | |||
338 | public function processVariableValueGreaterThan(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
339 | { |
||
340 | $this->addVariable($variableName, $variableValue, QueryOperator::GREATER_THAN, false, true); |
||
341 | return $this; |
||
342 | } |
||
343 | |||
344 | public function processVariableValueGreaterThanOrEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
345 | { |
||
346 | $this->addVariable($variableName, $variableValue, QueryOperator::GREATER_THAN_OR_EQUAL, false, true); |
||
347 | return $this; |
||
348 | } |
||
349 | |||
350 | public function processVariableValueLessThan(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
351 | { |
||
352 | $this->addVariable($variableName, $variableValue, QueryOperator::LESS_THAN, false, true); |
||
353 | return $this; |
||
354 | } |
||
355 | |||
356 | public function processVariableValueLessThanOrEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface |
||
357 | { |
||
358 | $this->addVariable($variableName, $variableValue, QueryOperator::LESS_THAN_OR_EQUAL, false, true); |
||
359 | return $this; |
||
360 | } |
||
361 | |||
362 | public function taskDefinitionKey(string $taskDefinitionKey): HistoricTaskInstanceQueryInterface |
||
363 | { |
||
364 | return $this->taskDefinitionKeyIn($taskDefinitionKey); |
||
|
|||
365 | } |
||
366 | |||
367 | public function taskDefinitionKeyIn(array $taskDefinitionKeys): HistoricTaskInstanceQueryInterface |
||
368 | { |
||
369 | EnsureUtil::ensureNotNull(NotValidException::class, "taskDefinitionKeys", $taskDefinitionKeys); |
||
370 | $this->taskDefinitionKeys = $taskDefinitionKeys; |
||
371 | return $this; |
||
372 | } |
||
373 | |||
374 | public function taskPriority(int $taskPriority): HistoricTaskInstanceQueryInterface |
||
375 | { |
||
376 | $this->taskPriority = $taskPriority; |
||
377 | return $this; |
||
378 | } |
||
379 | |||
380 | public function processFinished(): HistoricTaskInstanceQueryInterface |
||
381 | { |
||
382 | $this->processFinished = true; |
||
383 | return $this; |
||
384 | } |
||
385 | |||
386 | public function taskInvolvedUser(string $userId): HistoricTaskInstanceQueryInterface |
||
387 | { |
||
388 | $this->taskInvolvedUser = $userId; |
||
389 | return $this; |
||
390 | } |
||
391 | |||
392 | public function taskInvolvedGroup(string $groupId): HistoricTaskInstanceQueryInterface |
||
393 | { |
||
394 | $this->taskInvolvedGroup = $groupId; |
||
395 | return $this; |
||
396 | } |
||
397 | |||
398 | public function taskHadCandidateUser(string $userId): HistoricTaskInstanceQueryInterface |
||
399 | { |
||
400 | $this->taskHadCandidateUser = $userId; |
||
401 | return $this; |
||
402 | } |
||
403 | |||
404 | public function taskHadCandidateGroup(string $groupId): HistoricTaskInstanceQueryInterface |
||
405 | { |
||
406 | $this->taskHadCandidateGroup = $groupId; |
||
407 | return $this; |
||
408 | } |
||
409 | |||
410 | public function withCandidateGroups(): HistoricTaskInstanceQueryInterface |
||
411 | { |
||
412 | if ($this->isOrQueryActive) { |
||
413 | throw new ProcessEngineException("Invalid query usage: cannot set withCandidateGroups() within 'or' query"); |
||
414 | } |
||
415 | |||
416 | $this->withCandidateGroups = true; |
||
417 | return $this; |
||
418 | } |
||
419 | |||
420 | public function withoutCandidateGroups(): HistoricTaskInstanceQueryInterface |
||
421 | { |
||
422 | if ($this->isOrQueryActive) { |
||
423 | throw new ProcessEngineException("Invalid query usage: cannot set withoutCandidateGroups() within 'or' query"); |
||
424 | } |
||
425 | |||
426 | $this->withoutCandidateGroups = true; |
||
427 | return $this; |
||
428 | } |
||
429 | |||
430 | public function processUnfinished(): HistoricTaskInstanceQueryInterface |
||
431 | { |
||
432 | $this->processUnfinished = true; |
||
433 | return $this; |
||
434 | } |
||
435 | |||
436 | protected function ensureVariablesInitialized(): void |
||
437 | { |
||
438 | $processEngineConfiguration = Context::getProcessEngineConfiguration(); |
||
439 | $variableSerializers = $processEngineConfiguration->getVariableSerializers(); |
||
440 | $dbType = $processEngineConfiguration->getDatabaseType(); |
||
441 | foreach ($this->variables as $var) { |
||
442 | $var->initialize($variableSerializers, $dbType); |
||
443 | } |
||
444 | |||
445 | if (!empty($this->queries)) { |
||
446 | foreach ($this->queries as $orQuery) { |
||
447 | foreach ($orQuery->variables as $var) { |
||
448 | $var->initialize($variableSerializers, $dbType); |
||
449 | } |
||
450 | } |
||
451 | } |
||
452 | } |
||
453 | |||
454 | public function addVariable($nameOrValue, $value = null, string $operator = null, bool $isTaskVariable = null, bool $isProcessInstanceVariable = null): void |
||
455 | { |
||
456 | if ($nameOrValue instanceof TaskQueryVariableValue) { |
||
457 | $this->variables[] = $nameOrValue; |
||
458 | } else { |
||
459 | EnsureUtil::ensureNotNull("name", "name", $nameOrValue); |
||
460 | if ($value === null || $this->isBoolean($value)) { |
||
461 | // Null-values and booleans can only be used in EQUALS and NOT_EQUALS |
||
462 | switch ($operator) { |
||
463 | case QueryOperator::GREATER_THAN: |
||
464 | throw new ProcessEngineException("Booleans and null cannot be used in 'greater than' condition"); |
||
465 | case QueryOperator::LESS_THAN: |
||
466 | throw new ProcessEngineException("Booleans and null cannot be used in 'less than' condition"); |
||
467 | case QueryOperator::GREATER_THAN_OR_EQUAL: |
||
468 | throw new ProcessEngineException("Booleans and null cannot be used in 'greater than or equal' condition"); |
||
469 | case QueryOperator::LESS_THAN_OR_EQUAL: |
||
470 | throw new ProcessEngineException("Booleans and null cannot be used in 'less than or equal' condition"); |
||
471 | case QueryOperator::LIKE: |
||
472 | throw new ProcessEngineException("Booleans and null cannot be used in 'like' condition"); |
||
473 | case QueryOperator::NOT_LIKE: |
||
474 | throw new ProcessEngineException("Booleans and null cannot be used in 'not like' condition"); |
||
475 | default: |
||
476 | break; |
||
477 | } |
||
478 | } |
||
479 | $shouldMatchVariableValuesIgnoreCase = $this->variableValuesIgnoreCase && $value !== null && is_string($value); |
||
480 | $shouldMatchVariableNamesIgnoreCase = $this->variableNamesIgnoreCase; |
||
481 | $this->addVariable( |
||
482 | new TaskQueryVariableValue($name, $value, $operator, $isTaskVariable, $isProcessInstanceVariable, $shouldMatchVariableNamesIgnoreCase, $shouldMatchVariableValuesIgnoreCase) |
||
483 | ); |
||
484 | } |
||
485 | } |
||
486 | |||
487 | private function isBoolean($value): bool |
||
488 | { |
||
489 | if ($value === null) { |
||
490 | return false; |
||
491 | } |
||
492 | return is_bool($value) || strtolower($value) === "true" || strtolower($value) === "false"; |
||
493 | } |
||
494 | |||
495 | public function taskDueDate(string $dueDate): HistoricTaskInstanceQueryInterface |
||
496 | { |
||
497 | // The taskDueDate filter can't be used in an AND query with |
||
498 | // the withoutTaskDueDate filter. They can be combined in an OR query |
||
499 | if (!$this->isOrQueryActive) { |
||
500 | if ($this->isWithoutTaskDueDate) { |
||
501 | throw new ProcessEngineException("Invalid query usage: cannot set both taskDueDate and withoutTaskDueDate filters."); |
||
502 | } |
||
503 | } |
||
504 | |||
505 | $this->dueDate = $dueDate; |
||
506 | return $this; |
||
507 | } |
||
508 | |||
509 | public function taskDueAfter(string $dueAfter): HistoricTaskInstanceQueryInterface |
||
510 | { |
||
511 | // The taskDueAfter filter can't be used in an AND query with |
||
512 | // the withoutTaskDueDate filter. They can be combined in an OR query |
||
513 | if (!$this->isOrQueryActive) { |
||
514 | if ($this->isWithoutTaskDueDate) { |
||
515 | throw new ProcessEngineException("Invalid query usage: cannot set both taskDueAfter and withoutTaskDueDate filters."); |
||
516 | } |
||
517 | } |
||
518 | |||
519 | $this->dueAfter = $dueAfter; |
||
520 | return $this; |
||
521 | } |
||
522 | |||
523 | public function taskDueBefore(string $dueBefore): HistoricTaskInstanceQueryInterface |
||
524 | { |
||
525 | // The taskDueBefore filter can't be used in an AND query with |
||
526 | // the withoutTaskDueDate filter. They can be combined in an OR query |
||
527 | if (!$this->isOrQueryActive) { |
||
528 | if ($this->isWithoutTaskDueDate) { |
||
529 | throw new ProcessEngineException("Invalid query usage: cannot set both taskDueBefore and withoutTaskDueDate filters."); |
||
530 | } |
||
531 | } |
||
532 | |||
533 | $this->dueBefore = $dueBefore; |
||
534 | return $this; |
||
535 | } |
||
536 | |||
537 | public function withoutTaskDueDate(): HistoricTaskInstanceQueryInterface |
||
538 | { |
||
539 | // The due date filters can't be used in an AND query with |
||
540 | // the withoutTaskDueDate filter. They can be combined in an OR query |
||
541 | if (!$this->isOrQueryActive) { |
||
542 | if ($this->dueAfter !== null || $this->dueBefore !== null || $this->dueDate !== null) { |
||
543 | throw new ProcessEngineException("Invalid query usage: cannot set both task due date (equal to, before, or after) and withoutTaskDueDate filters."); |
||
544 | } |
||
545 | } |
||
546 | |||
547 | $this->isWithoutTaskDueDate = true; |
||
548 | return $this; |
||
549 | } |
||
550 | |||
551 | public function taskFollowUpDate(string $followUpDate): HistoricTaskInstanceQueryInterface |
||
552 | { |
||
553 | $this->followUpDate = $followUpDate; |
||
554 | return $this; |
||
555 | } |
||
556 | |||
557 | public function taskFollowUpBefore(string $followUpBefore): HistoricTaskInstanceQueryInterface |
||
558 | { |
||
559 | $this->followUpBefore = $followUpBefore; |
||
560 | return $this; |
||
561 | } |
||
562 | |||
563 | public function taskFollowUpAfter(string $followUpAfter): HistoricTaskInstanceQueryInterface |
||
564 | { |
||
565 | $this->followUpAfter = $followUpAfter; |
||
566 | return $this; |
||
567 | } |
||
568 | |||
569 | public function tenantIdIn(array $tenantIds): HistoricTaskInstanceQueryInterface |
||
570 | { |
||
571 | EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds); |
||
572 | $this->tenantIds = $tenantIds; |
||
573 | $this->isTenantIdSet = true; |
||
574 | return $this; |
||
575 | } |
||
576 | |||
577 | public function withoutTenantId(): HistoricTaskInstanceQueryInterface |
||
578 | { |
||
579 | $this->tenantIds = null; |
||
580 | $this->isTenantIdSet = true; |
||
581 | return $this; |
||
582 | } |
||
583 | |||
584 | public function finishedAfter(string $date): HistoricTaskInstanceQueryInterface |
||
585 | { |
||
586 | $this->finishedAfter = $date; |
||
587 | return $this; |
||
588 | } |
||
589 | |||
590 | public function finishedBefore(string $date): HistoricTaskInstanceQueryInterface |
||
591 | { |
||
592 | $this->finishedBefore = $date; |
||
593 | return $this; |
||
594 | } |
||
595 | |||
596 | public function startedAfter(string $date): HistoricTaskInstanceQueryInterface |
||
597 | { |
||
598 | $this->startedAfter = $date; |
||
599 | return $this; |
||
600 | } |
||
601 | |||
602 | public function startedBefore(string $date): HistoricTaskInstanceQueryInterface |
||
603 | { |
||
604 | $this->startedBefore = $date; |
||
605 | return $this; |
||
606 | } |
||
607 | |||
608 | protected function hasExcludingConditions(): bool |
||
609 | { |
||
610 | return parent::hasExcludingConditions() |
||
611 | || ($this->finished && $this->unfinished) |
||
612 | || ($this->processFinished && $this->processUnfinished) |
||
613 | || CompareUtil::areNotInAscendingOrder($this->startedAfter, $this->startedBefore) |
||
614 | || CompareUtil::areNotInAscendingOrder($this->finishedAfter, $this->finishedBefore) |
||
615 | || CompareUtil::areNotInAscendingOrder($this->dueAfter, $this->dueDate, $this->dueBefore) |
||
616 | || CompareUtil::areNotInAscendingOrder($this->followUpAfter, $this->followUpDate, $this->followUpBefore) |
||
617 | || CompareUtil::elementIsNotContainedInArray($this->processInstanceBusinessKey, $this->processInstanceBusinessKeys); |
||
618 | } |
||
619 | |||
620 | public function orderByTaskId(): HistoricTaskInstanceQueryImpl |
||
621 | { |
||
622 | if ($this->isOrQueryActive) { |
||
623 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskId() within 'or' query"); |
||
624 | } |
||
625 | |||
626 | $this->orderBy(HistoricTaskInstanceQueryProperty::historicTaskInstanceId()); |
||
627 | return $this; |
||
628 | } |
||
629 | |||
630 | public function orderByHistoricActivityInstanceId(): HistoricTaskInstanceQueryImpl |
||
631 | { |
||
632 | if ($this->isOrQueryActive) { |
||
633 | throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceId() within 'or' query"); |
||
634 | } |
||
635 | |||
636 | $this->orderBy(HistoricTaskInstanceQueryProperty::activityInstanceId()); |
||
637 | return $this; |
||
638 | } |
||
639 | |||
640 | public function orderByProcessDefinitionId(): HistoricTaskInstanceQueryImpl |
||
641 | { |
||
642 | if ($this->isOrQueryActive) { |
||
643 | throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionId() within 'or' query"); |
||
644 | } |
||
645 | |||
646 | $this->orderBy(HistoricTaskInstanceQueryProperty::processDefinitionId()); |
||
647 | return $this; |
||
648 | } |
||
649 | |||
650 | public function orderByProcessInstanceId(): HistoricTaskInstanceQueryImpl |
||
651 | { |
||
652 | if ($this->isOrQueryActive) { |
||
653 | throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceId() within 'or' query"); |
||
654 | } |
||
655 | |||
656 | $this->orderBy(HistoricTaskInstanceQueryProperty::processInstanceId()); |
||
657 | return $this; |
||
658 | } |
||
659 | |||
660 | public function orderByExecutionId(): HistoricTaskInstanceQueryImpl |
||
661 | { |
||
662 | if ($this->isOrQueryActive) { |
||
663 | throw new ProcessEngineException("Invalid query usage: cannot set orderByExecutionId() within 'or' query"); |
||
664 | } |
||
665 | |||
666 | $this->orderBy(HistoricTaskInstanceQueryProperty::executionId()); |
||
667 | return $this; |
||
668 | } |
||
669 | |||
670 | public function orderByHistoricTaskInstanceDuration(): HistoricTaskInstanceQueryImpl |
||
671 | { |
||
672 | if ($this->isOrQueryActive) { |
||
673 | throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceDuration() within 'or' query"); |
||
674 | } |
||
675 | |||
676 | $this->orderBy(HistoricTaskInstanceQueryProperty::duration()); |
||
677 | return $this; |
||
678 | } |
||
679 | |||
680 | public function orderByHistoricTaskInstanceEndTime(): HistoricTaskInstanceQueryImpl |
||
681 | { |
||
682 | if ($this->isOrQueryActive) { |
||
683 | throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceEndTime() within 'or' query"); |
||
684 | } |
||
685 | |||
686 | $this->orderBy(HistoricTaskInstanceQueryProperty::end()); |
||
687 | return $this; |
||
688 | } |
||
689 | |||
690 | public function orderByHistoricActivityInstanceStartTime(): HistoricTaskInstanceQueryImpl |
||
691 | { |
||
692 | if ($this->isOrQueryActive) { |
||
693 | throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceStartTime() within 'or' query"); |
||
694 | } |
||
695 | |||
696 | $this->orderBy(HistoricTaskInstanceQueryProperty::start()); |
||
697 | return $this; |
||
698 | } |
||
699 | |||
700 | public function orderByTaskName(): HistoricTaskInstanceQueryImpl |
||
701 | { |
||
702 | if ($this->isOrQueryActive) { |
||
703 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskName() within 'or' query"); |
||
704 | } |
||
705 | |||
706 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskName()); |
||
707 | return $this; |
||
708 | } |
||
709 | |||
710 | public function orderByTaskDescription(): HistoricTaskInstanceQueryImpl |
||
711 | { |
||
712 | if ($this->isOrQueryActive) { |
||
713 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDescription() within 'or' query"); |
||
714 | } |
||
715 | |||
716 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskDescription()); |
||
717 | return $this; |
||
718 | } |
||
719 | |||
720 | public function orderByTaskAssignee(): HistoricTaskInstanceQueryInterface |
||
721 | { |
||
722 | if ($this->isOrQueryActive) { |
||
723 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskAssignee() within 'or' query"); |
||
724 | } |
||
725 | |||
726 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskAssignee()); |
||
727 | return $this; |
||
728 | } |
||
729 | |||
730 | public function orderByTaskOwner(): HistoricTaskInstanceQueryInterface |
||
731 | { |
||
732 | if ($this->isOrQueryActive) { |
||
733 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskOwner() within 'or' query"); |
||
734 | } |
||
735 | |||
736 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskOwner()); |
||
737 | return $this; |
||
738 | } |
||
739 | |||
740 | public function orderByTaskDueDate(): HistoricTaskInstanceQueryInterface |
||
741 | { |
||
742 | if ($this->isOrQueryActive) { |
||
743 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDueDate() within 'or' query"); |
||
744 | } |
||
745 | |||
746 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskDueDate()); |
||
747 | return $this; |
||
748 | } |
||
749 | |||
750 | public function orderByTaskFollowUpDate(): HistoricTaskInstanceQueryInterface |
||
751 | { |
||
752 | if ($this->isOrQueryActive) { |
||
753 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskFollowUpDate() within 'or' query"); |
||
754 | } |
||
755 | |||
756 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskFollowUpDate()); |
||
757 | return $this; |
||
758 | } |
||
759 | |||
760 | public function orderByDeleteReason(): HistoricTaskInstanceQueryImpl |
||
761 | { |
||
762 | if ($this->isOrQueryActive) { |
||
763 | throw new ProcessEngineException("Invalid query usage: cannot set orderByDeleteReason() within 'or' query"); |
||
764 | } |
||
765 | |||
766 | $this->orderBy(HistoricTaskInstanceQueryProperty::deleteReason()); |
||
767 | return $this; |
||
768 | } |
||
769 | |||
770 | public function orderByTaskDefinitionKey(): HistoricTaskInstanceQueryInterface |
||
771 | { |
||
772 | if ($this->isOrQueryActive) { |
||
773 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDefinitionKey() within 'or' query"); |
||
774 | } |
||
775 | |||
776 | $this->orderBy(HistoricTaskInstanceQueryProperty::taskDefinitionKey()); |
||
777 | return $this; |
||
778 | } |
||
779 | |||
780 | public function orderByTaskPriority(): HistoricTaskInstanceQueryInterface |
||
781 | { |
||
782 | if ($this->isOrQueryActive) { |
||
783 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskPriority() within 'or' query"); |
||
784 | } |
||
785 | |||
786 | $this->orderBy(HistoricTaskInstanceQueryProperty:: taskPriority()); |
||
787 | return $this; |
||
788 | } |
||
789 | |||
790 | /*public HistoricTaskInstanceQueryInterface orderByCaseDefinitionId() { |
||
791 | if ($this->isOrQueryActive) { |
||
792 | throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseDefinitionId() within 'or' query"); |
||
793 | } |
||
794 | |||
795 | $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_DEFINITION_ID); |
||
796 | return $this; |
||
797 | } |
||
798 | |||
799 | public HistoricTaskInstanceQueryInterface orderByCaseInstanceId() { |
||
800 | if ($this->isOrQueryActive) { |
||
801 | throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseInstanceId() within 'or' query"); |
||
802 | } |
||
803 | |||
804 | $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_INSTANCE_ID); |
||
805 | return $this; |
||
806 | } |
||
807 | |||
808 | public function orderByCaseExecutionId(): HistoricTaskInstanceQueryInterface |
||
809 | { |
||
810 | if ($this->isOrQueryActive) { |
||
811 | throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseExecutionId() within 'or' query"); |
||
812 | } |
||
813 | $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_EXECUTION_ID); |
||
814 | return $this; |
||
815 | }*/ |
||
816 | |||
817 | public function orderByTenantId(): HistoricTaskInstanceQueryInterface |
||
818 | { |
||
819 | if ($this->isOrQueryActive) { |
||
820 | throw new ProcessEngineException("Invalid query usage: cannot set orderByTenantId() within 'or' query"); |
||
821 | } |
||
822 | return $this->orderBy(HistoricTaskInstanceQueryProperty::tenantId()); |
||
823 | } |
||
824 | |||
825 | // getters and setters ////////////////////////////////////////////////////// |
||
826 | |||
827 | public function getProcessInstanceId(): string |
||
828 | { |
||
829 | return $this->processInstanceId; |
||
830 | } |
||
831 | |||
832 | public function getProcessInstanceBusinessKey(): string |
||
833 | { |
||
834 | return $this->processInstanceBusinessKey; |
||
835 | } |
||
836 | |||
837 | public function getProcessInstanceBusinessKeys(): array |
||
838 | { |
||
839 | return $this->processInstanceBusinessKeys; |
||
840 | } |
||
841 | |||
842 | public function getProcessInstanceBusinessKeyLike(): string |
||
843 | { |
||
844 | return $this->processInstanceBusinessKeyLike; |
||
845 | } |
||
846 | |||
847 | public function getProcessDefinitionKey(): string |
||
848 | { |
||
849 | return $this->processDefinitionKey; |
||
850 | } |
||
851 | |||
852 | public function getProcessDefinitionName(): string |
||
853 | { |
||
854 | return $this->processDefinitionName; |
||
855 | } |
||
856 | |||
857 | public function getExecutionId(): string |
||
858 | { |
||
859 | return $this->executionId; |
||
860 | } |
||
861 | |||
862 | public function getActivityInstanceIds(): array |
||
863 | { |
||
864 | return $this->activityInstanceIds; |
||
865 | } |
||
866 | |||
867 | public function getProcessDefinitionId(): string |
||
868 | { |
||
869 | return $this->processDefinitionId; |
||
870 | } |
||
871 | |||
872 | public function isAssigned(): bool |
||
873 | { |
||
874 | return $this->assigned; |
||
875 | } |
||
876 | |||
877 | public function isUnassigned(): bool |
||
878 | { |
||
879 | return $this->unassigned; |
||
880 | } |
||
881 | |||
882 | public function isWithCandidateGroups(): bool |
||
883 | { |
||
884 | return $this->withCandidateGroups; |
||
885 | } |
||
886 | |||
887 | public function isWithoutCandidateGroups(): bool |
||
888 | { |
||
889 | return $this->withoutCandidateGroups; |
||
890 | } |
||
891 | |||
892 | public function isFinished(): bool |
||
893 | { |
||
894 | return $this->finished; |
||
895 | } |
||
896 | |||
897 | public function isProcessFinished(): bool |
||
898 | { |
||
899 | return $this->processFinished; |
||
900 | } |
||
901 | |||
902 | public function isUnfinished(): bool |
||
903 | { |
||
904 | return $this->unfinished; |
||
905 | } |
||
906 | |||
907 | public function isProcessUnfinished(): bool |
||
908 | { |
||
909 | return $this->processUnfinished; |
||
910 | } |
||
911 | |||
912 | public function getDueDate(): string |
||
913 | { |
||
914 | return $this->dueDate; |
||
915 | } |
||
916 | |||
917 | public function getDueBefore(): string |
||
918 | { |
||
919 | return $this->dueBefore; |
||
920 | } |
||
921 | |||
922 | public function getDueAfter(): string |
||
923 | { |
||
924 | return $this->dueAfter; |
||
925 | } |
||
926 | |||
927 | public function isWithoutTaskDueDate(): bool |
||
928 | { |
||
929 | return $this->isWithoutTaskDueDate; |
||
930 | } |
||
931 | |||
932 | public function getFollowUpDate(): string |
||
933 | { |
||
934 | return $this->followUpDate; |
||
935 | } |
||
936 | |||
937 | public function getFollowUpBefore(): string |
||
938 | { |
||
939 | return $this->followUpBefore; |
||
940 | } |
||
941 | |||
942 | public function getFollowUpAfter(): string |
||
943 | { |
||
944 | return $this->followUpAfter; |
||
945 | } |
||
946 | |||
947 | public function getTaskName(): string |
||
948 | { |
||
949 | return $this->taskName; |
||
950 | } |
||
951 | |||
952 | public function getTaskNameLike(): string |
||
953 | { |
||
954 | return $this->taskNameLike; |
||
955 | } |
||
956 | |||
957 | public function getTaskDescription(): string |
||
958 | { |
||
959 | return $this->taskDescription; |
||
960 | } |
||
961 | |||
962 | public function getTaskDescriptionLike(): string |
||
963 | { |
||
964 | return $this->taskDescriptionLike; |
||
965 | } |
||
966 | |||
967 | public function getTaskDeleteReason(): string |
||
968 | { |
||
969 | return $this->taskDeleteReason; |
||
970 | } |
||
971 | |||
972 | public function getTaskDeleteReasonLike(): string |
||
973 | { |
||
974 | return $this->taskDeleteReasonLike; |
||
975 | } |
||
976 | |||
977 | public function getTaskAssignee(): string |
||
978 | { |
||
979 | return $this->taskAssignee; |
||
980 | } |
||
981 | |||
982 | public function getTaskAssigneeLike(): string |
||
983 | { |
||
984 | return $this->taskAssigneeLike; |
||
985 | } |
||
986 | |||
987 | public function getTaskId(): string |
||
988 | { |
||
989 | return $this->taskId; |
||
990 | } |
||
991 | |||
992 | public function getTaskInvolvedGroup(): string |
||
993 | { |
||
994 | return $this->taskInvolvedGroup; |
||
995 | } |
||
996 | |||
997 | public function getTaskInvolvedUser(): string |
||
998 | { |
||
999 | return $this->taskInvolvedUser; |
||
1000 | } |
||
1001 | |||
1002 | public function getTaskHadCandidateGroup(): string |
||
1003 | { |
||
1004 | return $this->taskHadCandidateGroup; |
||
1005 | } |
||
1006 | |||
1007 | public function getTaskHadCandidateUser(): string |
||
1008 | { |
||
1009 | return $this->taskHadCandidateUser; |
||
1010 | } |
||
1011 | |||
1012 | public function getTaskDefinitionKeys(): array |
||
1015 | } |
||
1016 | |||
1017 | public function getVariables(): array |
||
1018 | { |
||
1019 | return $this->variables; |
||
1020 | } |
||
1021 | |||
1022 | public function getVariableNamesIgnoreCase(): bool |
||
1023 | { |
||
1024 | return $this->variableNamesIgnoreCase; |
||
1025 | } |
||
1026 | |||
1027 | public function getVariableValuesIgnoreCase(): bool |
||
1028 | { |
||
1029 | return $this->variableValuesIgnoreCase; |
||
1030 | } |
||
1031 | |||
1032 | public function getTaskOwnerLike(): string |
||
1033 | { |
||
1034 | return $this->taskOwnerLike; |
||
1035 | } |
||
1036 | |||
1037 | public function getTaskOwner(): string |
||
1038 | { |
||
1039 | return $this->taskOwner; |
||
1040 | } |
||
1041 | |||
1042 | public function getTaskPriority(): int |
||
1043 | { |
||
1044 | return $this->taskPriority; |
||
1045 | } |
||
1046 | |||
1047 | public function getTaskParentTaskId(): string |
||
1048 | { |
||
1049 | return $this->taskParentTaskId; |
||
1050 | } |
||
1051 | |||
1052 | public function getTenantIds(): array |
||
1053 | { |
||
1054 | return $this->tenantIds; |
||
1055 | } |
||
1056 | |||
1057 | /*public String getCaseDefinitionId() { |
||
1058 | return caseDefinitionId; |
||
1059 | } |
||
1060 | |||
1061 | public String getCaseDefinitionKey() { |
||
1062 | return caseDefinitionKey; |
||
1063 | } |
||
1064 | |||
1065 | public String getCaseDefinitionName() { |
||
1066 | return caseDefinitionName; |
||
1067 | } |
||
1068 | |||
1069 | public String getCaseInstanceId() { |
||
1070 | return caseInstanceId; |
||
1071 | } |
||
1072 | |||
1073 | public function getCaseExecutionId(): string |
||
1074 | { |
||
1075 | return caseExecutionId; |
||
1076 | }*/ |
||
1077 | |||
1078 | public function getFinishedAfter(): string |
||
1079 | { |
||
1080 | return $this->finishedAfter; |
||
1081 | } |
||
1082 | |||
1083 | public function getFinishedBefore(): string |
||
1084 | { |
||
1085 | return $this->finishedBefore; |
||
1086 | } |
||
1087 | |||
1088 | public function getStartedAfter(): string |
||
1091 | } |
||
1092 | |||
1093 | public function getStartedBefore(): string |
||
1094 | { |
||
1095 | return $this->startedBefore; |
||
1096 | } |
||
1097 | |||
1098 | public function isTenantIdSet(): bool |
||
1099 | { |
||
1100 | return $this->isTenantIdSet; |
||
1101 | } |
||
1102 | |||
1103 | public function getQueries(): array |
||
1104 | { |
||
1105 | return $this->queries; |
||
1106 | } |
||
1107 | |||
1108 | public function isOrQueryActive(): bool |
||
1111 | } |
||
1112 | |||
1113 | public function addOrQuery(HistoricTaskInstanceQueryImpl $orQuery): void |
||
1114 | { |
||
1115 | $orQuery->isOrQueryActive = true; |
||
1116 | $this->queries[] = $orQuery; |
||
1117 | } |
||
1118 | |||
1119 | public function setOrQueryActive(): void |
||
1120 | { |
||
1121 | $this->isOrQueryActive = true; |
||
1122 | } |
||
1123 | |||
1124 | public function or(): HistoricTaskInstanceQueryInterface |
||
1125 | { |
||
1126 | if ($this != $this->queries[0]) { |
||
1127 | throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query"); |
||
1128 | } |
||
1129 | |||
1130 | $orQuery = new HistoricTaskInstanceQueryImpl(); |
||
1131 | $orQuery->isOrQueryActive = true; |
||
1132 | $orQuery->queries = $this->queries; |
||
1133 | $this->queries[] = $orQuery; |
||
1134 | return $orQuery; |
||
1135 | } |
||
1136 | |||
1137 | public function endOr(): HistoricTaskInstanceQueryInterface |
||
1138 | { |
||
1139 | if (!empty($this->queries) && $this != $this->queries[count($this->queries) - 1]) { |
||
1140 | throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()"); |
||
1141 | } |
||
1142 | return $this->queries[0]; |
||
1143 | } |
||
1144 | } |
||
1145 |