Test Failed
Push — main ( a2096a...c7561b )
by Bingo
15:21
created

hasExcludingConditions()   B

Complexity

Conditions 10
Paths 12

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 10
rs 7.6666
c 0
b 0
f 0
cc 10
nc 12
nop 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Jabe\Engine\Impl;
4
5
use Jabe\Engine\ProcessEngineException;
6
use Jabe\Engine\Exception\NotValidException;
7
use Jabe\Engine\History\{
8
    HistoricTaskInstanceInterface,
9
    HistoricTaskInstanceQueryInterface
10
};
11
use Jabe\Engine\Impl\Cfg\ProcessEngineConfigurationImpl;
12
use Jabe\Engine\Impl\Context\Context;
13
use Jabe\Engine\Impl\Interceptor\{
14
    CommandContext,
15
    CommandExecutorInterface
16
};
17
use Jabe\Engine\Impl\Util\{
18
    CompareUtil,
19
    EnsureUtil
20
};
21
use Jabe\Engine\Impl\Variable\Serializer\VariableSerializersInterface;
22
23
class HistoricTaskInstanceQueryImpl extends AbstractQuery implements HistoricTaskInstanceQueryInterface
24
{
25
    protected $processDefinitionId;
26
    protected $processDefinitionKey;
27
    protected $processDefinitionName;
28
    protected $processInstanceId;
29
    protected $processInstanceBusinessKey;
30
    protected $processInstanceBusinessKeys = [];
31
    protected $processInstanceBusinessKeyLike;
32
    protected $executionId;
33
    protected $activityInstanceIds = [];
34
    protected $taskId;
35
    protected $taskName;
36
    protected $taskNameLike;
37
    protected $taskParentTaskId;
38
    protected $taskDescription;
39
    protected $taskDescriptionLike;
40
    protected $taskDeleteReason;
41
    protected $taskDeleteReasonLike;
42
    protected $taskOwner;
43
    protected $taskOwnerLike;
44
    protected $assigned;
45
    protected $unassigned;
46
    protected $taskAssignee;
47
    protected $taskAssigneeLike;
48
    protected $taskDefinitionKeys = [];
49
    protected $taskInvolvedUser;
50
    protected $taskInvolvedGroup;
51
    protected $taskHadCandidateUser;
52
    protected $taskHadCandidateGroup;
53
    protected $withCandidateGroups;
54
    protected $withoutCandidateGroups;
55
    protected $taskPriority;
56
    protected $finished;
57
    protected $unfinished;
58
    protected $processFinished;
59
    protected $processUnfinished;
60
    protected $variables = [];
61
    protected $variableNamesIgnoreCase;
62
    protected $variableValuesIgnoreCase;
63
64
    protected $dueDate;
65
    protected $dueAfter;
66
    protected $dueBefore;
67
    protected $isWithoutTaskDueDate;
68
69
    protected $followUpDate;
70
    protected $followUpBefore;
71
    protected $followUpAfter;
72
73
    protected $tenantIds = [];
74
    protected $isTenantIdSet;
75
76
    protected $caseDefinitionId;
77
    protected $caseDefinitionKey;
78
    protected $caseDefinitionName;
79
    protected $caseInstanceId;
80
    protected $caseExecutionId;
81
82
    protected $finishedAfter;
83
    protected $finishedBefore;
84
    protected $startedAfter;
85
    protected $startedBefore;
86
87
    protected $queries = [];
88
    protected $isOrQueryActive = false;
89
90
    public function __construct(CommandExecutorInterface $commandExecutor)
91
    {
92
        parent::__construct($commandExecutor);
93
        $this->queries[] = $this;
94
    }
95
96
    public function executeCount(CommandContext $commandContext): int
97
    {
98
        $this->ensureVariablesInitialized();
99
        $this->checkQueryOk();
100
        return $commandContext
101
            ->getHistoricTaskInstanceManager()
102
            ->findHistoricTaskInstanceCountByQueryCriteria($this);
103
    }
104
105
    public function executeList(CommandContext $commandContext, Page $page): array
106
    {
107
        $this->ensureVariablesInitialized();
108
        $this->checkQueryOk();
109
        return $commandContext
110
            ->getHistoricTaskInstanceManager()
111
            ->findHistoricTaskInstancesByQueryCriteria($this, $page);
112
    }
113
114
    public function processInstanceId(string $processInstanceId): HistoricTaskInstanceQueryImpl
115
    {
116
        $this->processInstanceId = $processInstanceId;
117
        return $this;
118
    }
119
120
    public function processInstanceBusinessKey(string $processInstanceBusinessKey): HistoricTaskInstanceQueryInterface
121
    {
122
        $this->processInstanceBusinessKey = $processInstanceBusinessKey;
123
        return $this;
124
    }
125
126
    public function processInstanceBusinessKeyIn(array $processInstanceBusinessKeys): HistoricTaskInstanceQueryInterface
127
    {
128
        EnsureUtil::ensureNotNull("processInstanceBusinessKeys", "processInstanceBusinessKeys", $processInstanceBusinessKeys);
129
        $this->processInstanceBusinessKeys = $processInstanceBusinessKeys;
130
        return $this;
131
    }
132
133
    public function processInstanceBusinessKeyLike(string $processInstanceBusinessKey): HistoricTaskInstanceQueryInterface
134
    {
135
        $this->processInstanceBusinessKeyLike = $processInstanceBusinessKey;
136
        return $this;
137
    }
138
139
    public function executionId(string $executionId): HistoricTaskInstanceQueryImpl
140
    {
141
        $this->executionId = $executionId;
142
        return $this;
143
    }
144
145
    public function activityInstanceIdIn(array $activityInstanceIds): HistoricTaskInstanceQueryInterface
146
    {
147
        EnsureUtil::ensureNotNull("activityInstanceIds", "activityInstanceIds", $activityInstanceIds);
148
        $this->activityInstanceIds = $activityInstanceIds;
149
        return $this;
150
    }
151
152
    public function processDefinitionId(string $processDefinitionId): HistoricTaskInstanceQueryImpl
153
    {
154
        $this->processDefinitionId = $processDefinitionId;
155
        return $this;
156
    }
157
158
    public function processDefinitionKey(string $processDefinitionKey): HistoricTaskInstanceQueryInterface
159
    {
160
        $this->processDefinitionKey = $processDefinitionKey;
161
        return $this;
162
    }
163
164
    public function processDefinitionName(string $processDefinitionName): HistoricTaskInstanceQueryInterface
165
    {
166
        $this->processDefinitionName = $processDefinitionName;
167
        return $this;
168
    }
169
170
    public function taskId(string $taskId): HistoricTaskInstanceQueryInterface
171
    {
172
        $this->taskId = $taskId;
173
        return $this;
174
    }
175
176
    public function taskName(string $taskName): HistoricTaskInstanceQueryImpl
177
    {
178
        $this->taskName = $taskName;
179
        return $this;
180
    }
181
182
    public function taskNameLike(string $taskNameLike): HistoricTaskInstanceQueryImpl
183
    {
184
        $this->taskNameLike = $taskNameLike;
185
        return $this;
186
    }
187
188
    public function taskParentTaskId(string $parentTaskId): HistoricTaskInstanceQueryInterface
189
    {
190
        $this->taskParentTaskId = $parentTaskId;
191
        return $this;
192
    }
193
194
    public function taskDescription(string $taskDescription): HistoricTaskInstanceQueryImpl
195
    {
196
        $this->taskDescription = $taskDescription;
197
        return $this;
198
    }
199
200
    public function taskDescriptionLike(string $taskDescriptionLike): HistoricTaskInstanceQueryImpl
201
    {
202
        $this->taskDescriptionLike = $taskDescriptionLike;
203
        return $this;
204
    }
205
206
    public function taskDeleteReason(string $taskDeleteReason): HistoricTaskInstanceQueryImpl
207
    {
208
        $this->taskDeleteReason = $taskDeleteReason;
209
        return $this;
210
    }
211
212
    public function taskDeleteReasonLike(string $taskDeleteReasonLike): HistoricTaskInstanceQueryImpl
213
    {
214
        $this->taskDeleteReasonLike = $taskDeleteReasonLike;
215
        return $this;
216
    }
217
218
    public function taskAssigned(): HistoricTaskInstanceQueryImpl
219
    {
220
        $this->assigned = true;
221
        return $this;
222
    }
223
224
    public function taskUnassigned(): HistoricTaskInstanceQueryImpl
225
    {
226
        $this->unassigned = true;
227
        return $this;
228
    }
229
230
    public function taskAssignee(string $taskAssignee): HistoricTaskInstanceQueryImpl
231
    {
232
        $this->taskAssignee = $taskAssignee;
233
        return $this;
234
    }
235
236
    public function taskAssigneeLike(string $taskAssigneeLike): HistoricTaskInstanceQueryImpl
237
    {
238
        $this->taskAssigneeLike = $taskAssigneeLike;
239
        return $this;
240
    }
241
242
    public function taskOwner(string $taskOwner): HistoricTaskInstanceQueryImpl
243
    {
244
        $this->taskOwner = $taskOwner;
245
        return $this;
246
    }
247
248
    public function taskOwnerLike(string $taskOwnerLike): HistoricTaskInstanceQueryImpl
249
    {
250
        $this->taskOwnerLike = $taskOwnerLike;
251
        return $this;
252
    }
253
254
    /*public HistoricTaskInstanceQueryInterface caseDefinitionId(string $caseDefinitionId) {
255
        $this->caseDefinitionId = caseDefinitionId;
256
        return $this;
257
    }
258
259
    public HistoricTaskInstanceQueryInterface caseDefinitionKey(string $caseDefinitionKey) {
260
        $this->caseDefinitionKey = caseDefinitionKey;
261
        return $this;
262
    }
263
264
    public HistoricTaskInstanceQueryInterface caseDefinitionName(string $caseDefinitionName) {
265
        $this->caseDefinitionName = caseDefinitionName;
266
        return $this;
267
    }
268
269
    public HistoricTaskInstanceQueryInterface caseInstanceId(string $caseInstanceId) {
270
        $this->caseInstanceId = caseInstanceId;
271
        return $this;
272
    }
273
274
    public HistoricTaskInstanceQueryInterface caseExecutionId(string $caseExecutionId) {
275
        $this->caseExecutionId = caseExecutionId;
276
        return $this;
277
    }*/
278
279
    public function finished(): HistoricTaskInstanceQueryImpl
280
    {
281
        $this->finished = true;
282
        return $this;
283
    }
284
285
    public function unfinished(): HistoricTaskInstanceQueryImpl
286
    {
287
        $this->unfinished = true;
288
        return $this;
289
    }
290
291
    public function matchVariableNamesIgnoreCase(): HistoricTaskInstanceQueryInterface
292
    {
293
        $this->variableNamesIgnoreCase = true;
294
        foreach ($this->variables as $variable) {
295
            $variable->setVariableNameIgnoreCase(true);
296
        }
297
        return $this;
298
    }
299
300
    public function matchVariableValuesIgnoreCase(): HistoricTaskInstanceQueryInterface
301
    {
302
        $this->variableValuesIgnoreCase = true;
303
        foreach ($this->variables as $variable) {
304
            $variable->setVariableValueIgnoreCase(true);
305
        }
306
        return $this;
307
    }
308
309
    public function taskVariableValueEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryImpl
310
    {
311
        $this->addVariable($variableName, $variableValue, QueryOperator::EQUALS, true, false);
312
        return $this;
313
    }
314
315
    public function processVariableValueEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
316
    {
317
        $this->addVariable($variableName, $variableValue, QueryOperator::EQUALS, false, true);
318
        return $this;
319
    }
320
321
    public function processVariableValueNotEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
322
    {
323
        $this->addVariable($variableName, $variableValue, QueryOperator::NOT_EQUALS, false, true);
324
        return $this;
325
    }
326
327
    public function processVariableValueLike(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
328
    {
329
        $this->addVariable($variableName, $variableValue, QueryOperator::LIKE, false, true);
330
        return $this;
331
    }
332
333
    public function processVariableValueNotLike(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
334
    {
335
        $this->addVariable($variableName, $variableValue, QueryOperator::NOT_LIKE, false, true);
336
        return $this;
337
    }
338
339
    public function processVariableValueGreaterThan(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
340
    {
341
        $this->addVariable($variableName, $variableValue, QueryOperator::GREATER_THAN, false, true);
342
        return $this;
343
    }
344
345
    public function processVariableValueGreaterThanOrEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
346
    {
347
        $this->addVariable($variableName, $variableValue, QueryOperator::GREATER_THAN_OR_EQUAL, false, true);
348
        return $this;
349
    }
350
351
    public function processVariableValueLessThan(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
352
    {
353
        $this->addVariable($variableName, $variableValue, QueryOperator::LESS_THAN, false, true);
354
        return $this;
355
    }
356
357
    public function processVariableValueLessThanOrEquals(string $variableName, $variableValue): HistoricTaskInstanceQueryInterface
358
    {
359
        $this->addVariable($variableName, $variableValue, QueryOperator::LESS_THAN_OR_EQUAL, false, true);
360
        return $this;
361
    }
362
363
    public function taskDefinitionKey(string $taskDefinitionKey): HistoricTaskInstanceQueryInterface
364
    {
365
        return $this->taskDefinitionKeyIn($taskDefinitionKey);
0 ignored issues
show
Bug introduced by
$taskDefinitionKey of type string is incompatible with the type array expected by parameter $taskDefinitionKeys of Jabe\Engine\Impl\Histori...::taskDefinitionKeyIn(). ( Ignorable by Annotation )

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

365
        return $this->taskDefinitionKeyIn(/** @scrutinizer ignore-type */ $taskDefinitionKey);
Loading history...
366
    }
367
368
    public function taskDefinitionKeyIn(array $taskDefinitionKeys): HistoricTaskInstanceQueryInterface
369
    {
370
        EnsureUtil::ensureNotNull(NotValidException::class, "taskDefinitionKeys", $taskDefinitionKeys);
371
        $this->taskDefinitionKeys = $taskDefinitionKeys;
372
        return $this;
373
    }
374
375
    public function taskPriority(int $taskPriority): HistoricTaskInstanceQueryInterface
376
    {
377
        $this->taskPriority = $taskPriority;
378
        return $this;
379
    }
380
381
    public function processFinished(): HistoricTaskInstanceQueryInterface
382
    {
383
        $this->processFinished = true;
384
        return $this;
385
    }
386
387
    public function taskInvolvedUser(string $userId): HistoricTaskInstanceQueryInterface
388
    {
389
        $this->taskInvolvedUser = $userId;
390
        return $this;
391
    }
392
393
    public function taskInvolvedGroup(string $groupId): HistoricTaskInstanceQueryInterface
394
    {
395
        $this->taskInvolvedGroup = $groupId;
396
        return $this;
397
    }
398
399
    public function taskHadCandidateUser(string $userId): HistoricTaskInstanceQueryInterface
400
    {
401
        $this->taskHadCandidateUser = $userId;
402
        return $this;
403
    }
404
405
    public function taskHadCandidateGroup(string $groupId): HistoricTaskInstanceQueryInterface
406
    {
407
        $this->taskHadCandidateGroup = $groupId;
408
        return $this;
409
    }
410
411
    public function withCandidateGroups(): HistoricTaskInstanceQueryInterface
412
    {
413
        if ($this->isOrQueryActive) {
414
            throw new ProcessEngineException("Invalid query usage: cannot set withCandidateGroups() within 'or' query");
415
        }
416
417
        $this->withCandidateGroups = true;
418
        return $this;
419
    }
420
421
    public function withoutCandidateGroups(): HistoricTaskInstanceQueryInterface
422
    {
423
        if ($this->isOrQueryActive) {
424
            throw new ProcessEngineException("Invalid query usage: cannot set withoutCandidateGroups() within 'or' query");
425
        }
426
427
        $this->withoutCandidateGroups = true;
428
        return $this;
429
    }
430
431
    public function processUnfinished(): HistoricTaskInstanceQueryInterface
432
    {
433
        $this->processUnfinished = true;
434
        return $this;
435
    }
436
437
    protected function ensureVariablesInitialized(): void
438
    {
439
        $processEngineConfiguration = Context::getProcessEngineConfiguration();
440
        $variableSerializers = $processEngineConfiguration->getVariableSerializers();
0 ignored issues
show
Bug introduced by
The method getVariableSerializers() does not exist on Jabe\Engine\Impl\Cfg\Pro...EngineConfigurationImpl. ( Ignorable by Annotation )

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

440
        /** @scrutinizer ignore-call */ 
441
        $variableSerializers = $processEngineConfiguration->getVariableSerializers();

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...
441
        $dbType = $processEngineConfiguration->getDatabaseType();
442
        foreach ($this->variables as $var) {
443
            $var->initialize($variableSerializers, $dbType);
444
        }
445
446
        if (!empty($this->queries)) {
447
            foreach ($this->queries as $orQuery) {
448
                foreach ($orQuery->variables as $var) {
449
                    $var->initialize($variableSerializers, $dbType);
450
                }
451
            }
452
        }
453
    }
454
455
    public function addVariable($nameOrValue, $value = null, string $operator = null, bool $isTaskVariable = null, bool $isProcessInstanceVariable = null): void
456
    {
457
        if ($nameOrValue instanceof TaskQueryVariableValue) {
458
            $this->variables[] = $taskQueryVariableValue;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $taskQueryVariableValue seems to be never defined.
Loading history...
459
        } else {
460
            EnsureUtil::ensureNotNull("name", "name", $name);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $name seems to be never defined.
Loading history...
461
            if ($value == null || $this->isBoolean($value)) {
462
                // Null-values and booleans can only be used in EQUALS and NOT_EQUALS
463
                switch ($operator) {
464
                    case QueryOperator::GREATER_THAN:
465
                        throw new ProcessEngineException("Booleans and null cannot be used in 'greater than' condition");
466
                    case QueryOperator::LESS_THAN:
467
                        throw new ProcessEngineException("Booleans and null cannot be used in 'less than' condition");
468
                    case QueryOperator::GREATER_THAN_OR_EQUAL:
469
                        throw new ProcessEngineException("Booleans and null cannot be used in 'greater than or equal' condition");
470
                    case QueryOperator::LESS_THAN_OR_EQUAL:
471
                        throw new ProcessEngineException("Booleans and null cannot be used in 'less than or equal' condition");
472
                    case QueryOperator::LIKE:
473
                        throw new ProcessEngineException("Booleans and null cannot be used in 'like' condition");
474
                    case QueryOperator::NOT_LIKE:
475
                        throw new ProcessEngineException("Booleans and null cannot be used in 'not like' condition");
476
                    default:
477
                        break;
478
                }
479
            }
480
            $shouldMatchVariableValuesIgnoreCase = $variableValuesIgnoreCase && $value != null && is_string($value);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $variableValuesIgnoreCase seems to be never defined.
Loading history...
481
            $shouldMatchVariableNamesIgnoreCase = $variableNamesIgnoreCase;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $variableNamesIgnoreCase seems to be never defined.
Loading history...
482
            $this->addVariable(
483
                new TaskQueryVariableValue($name, $value, $operator, $isTaskVariable, $isProcessInstanceVariable, $shouldMatchVariableNamesIgnoreCase, $shouldMatchVariableValuesIgnoreCase)
484
            );
485
        }
486
    }
487
488
    private function isBoolean($value): bool
489
    {
490
        if ($value == null) {
491
            return false;
492
        }
493
        return is_bool($value) || strtolower($value) === "true" || strtolower($value) === "false";
494
    }
495
496
    public function taskDueDate(string $dueDate): HistoricTaskInstanceQueryInterface
497
    {
498
        // The taskDueDate filter can't be used in an AND query with
499
        // the withoutTaskDueDate filter. They can be combined in an OR query
500
        if (!$this->isOrQueryActive) {
501
            if ($this->isWithoutTaskDueDate) {
502
                throw new ProcessEngineException("Invalid query usage: cannot set both taskDueDate and withoutTaskDueDate filters.");
503
            }
504
        }
505
506
        $this->dueDate = $dueDate;
507
        return $this;
508
    }
509
510
    public function taskDueAfter(string $dueAfter): HistoricTaskInstanceQueryInterface
511
    {
512
        // The taskDueAfter filter can't be used in an AND query with
513
        // the withoutTaskDueDate filter. They can be combined in an OR query
514
        if (!$this->isOrQueryActive) {
515
            if ($this->isWithoutTaskDueDate) {
516
                throw new ProcessEngineException("Invalid query usage: cannot set both taskDueAfter and withoutTaskDueDate filters.");
517
            }
518
        }
519
520
        $this->dueAfter = $dueAfter;
521
        return $this;
522
    }
523
524
    public function taskDueBefore(string $dueBefore): HistoricTaskInstanceQueryInterface
525
    {
526
        // The taskDueBefore filter can't be used in an AND query with
527
        // the withoutTaskDueDate filter. They can be combined in an OR query
528
        if (!$this->isOrQueryActive) {
529
            if ($this->isWithoutTaskDueDate) {
530
                throw new ProcessEngineException("Invalid query usage: cannot set both taskDueBefore and withoutTaskDueDate filters.");
531
            }
532
        }
533
534
        $this->dueBefore = $dueBefore;
535
        return $this;
536
    }
537
538
    public function withoutTaskDueDate(): HistoricTaskInstanceQueryInterface
539
    {
540
        // The due date filters can't be used in an AND query with
541
        // the withoutTaskDueDate filter. They can be combined in an OR query
542
        if (!$this->isOrQueryActive) {
543
            if ($this->dueAfter != null || $this->dueBefore != null || $this->dueDate != null) {
544
                throw new ProcessEngineException("Invalid query usage: cannot set both task due date (equal to, before, or after) and withoutTaskDueDate filters.");
545
            }
546
        }
547
548
        $this->isWithoutTaskDueDate = true;
549
        return $this;
550
    }
551
552
    public function taskFollowUpDate(string $followUpDate): HistoricTaskInstanceQueryInterface
553
    {
554
        $this->followUpDate = $followUpDate;
555
        return $this;
556
    }
557
558
    public function taskFollowUpBefore(string $followUpBefore): HistoricTaskInstanceQueryInterface
559
    {
560
        $this->followUpBefore = $followUpBefore;
561
        return $this;
562
    }
563
564
    public function taskFollowUpAfter(string $followUpAfter): HistoricTaskInstanceQueryInterface
565
    {
566
        $this->followUpAfter = $followUpAfter;
567
        return $this;
568
    }
569
570
    public function tenantIdIn(array $tenantIds): HistoricTaskInstanceQueryInterface
571
    {
572
        EnsureUtil::ensureNotNull("tenantIds", "tenantIds", $tenantIds);
573
        $this->tenantIds = $tenantIds;
574
        $this->isTenantIdSet = true;
575
        return $this;
576
    }
577
578
    public function withoutTenantId(): HistoricTaskInstanceQueryInterface
579
    {
580
        $this->tenantIds = null;
581
        $this->isTenantIdSet = true;
582
        return $this;
583
    }
584
585
    public function finishedAfter(string $date): HistoricTaskInstanceQueryInterface
586
    {
587
        $this->finishedAfter = $date;
588
        return $this;
589
    }
590
591
    public function finishedBefore(string $date): HistoricTaskInstanceQueryInterface
592
    {
593
        $this->finishedBefore = $date;
594
        return $this;
595
    }
596
597
    public function startedAfter(string $date): HistoricTaskInstanceQueryInterface
598
    {
599
        $this->startedAfter = $date;
600
        return $this;
601
    }
602
603
    public function startedBefore(string $date): HistoricTaskInstanceQueryInterface
604
    {
605
        $this->startedBefore = $date;
606
        return $this;
607
    }
608
609
    protected function hasExcludingConditions(): bool
610
    {
611
        return parent::hasExcludingConditions()
612
            || ($this->finished && $this->unfinished)
613
            || ($this->processFinished && $this->processUnfinished)
614
            || CompareUtil::areNotInAscendingOrder($this->startedAfter, $this->startedBefore)
615
            || CompareUtil::areNotInAscendingOrder($this->finishedAfter, $this->finishedBefore)
616
            || CompareUtil::areNotInAscendingOrder($this->dueAfter, $this->dueDate, $this->dueBefore)
617
            || CompareUtil::areNotInAscendingOrder($this->followUpAfter, $this->followUpDate, $this->followUpBefore)
618
            || CompareUtil::elementIsNotContainedInArray($this->processInstanceBusinessKey, $this->processInstanceBusinessKeys);
619
    }
620
621
    public function orderByTaskId(): HistoricTaskInstanceQueryImpl
622
    {
623
        if ($this->isOrQueryActive) {
624
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskId() within 'or' query");
625
        }
626
627
        $this->orderBy(HistoricTaskInstanceQueryProperty::historicTaskInstanceId());
628
        return $this;
629
    }
630
631
    public function orderByHistoricActivityInstanceId(): HistoricTaskInstanceQueryImpl
632
    {
633
        if ($this->isOrQueryActive) {
634
            throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceId() within 'or' query");
635
        }
636
637
        $this->orderBy(HistoricTaskInstanceQueryProperty::activityInstanceId());
638
        return $this;
639
    }
640
641
    public function orderByProcessDefinitionId(): HistoricTaskInstanceQueryImpl
642
    {
643
        if ($this->isOrQueryActive) {
644
            throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionId() within 'or' query");
645
        }
646
647
        $this->orderBy(HistoricTaskInstanceQueryProperty::processDefinitionId());
648
        return $this;
649
    }
650
651
    public function orderByProcessInstanceId(): HistoricTaskInstanceQueryImpl
652
    {
653
        if ($this->isOrQueryActive) {
654
            throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceId() within 'or' query");
655
        }
656
657
        $this->orderBy(HistoricTaskInstanceQueryProperty::processInstanceId());
658
        return $this;
659
    }
660
661
    public function orderByExecutionId(): HistoricTaskInstanceQueryImpl
662
    {
663
        if ($this->isOrQueryActive) {
664
            throw new ProcessEngineException("Invalid query usage: cannot set orderByExecutionId() within 'or' query");
665
        }
666
667
        $this->orderBy(HistoricTaskInstanceQueryProperty::executionId());
668
        return $this;
669
    }
670
671
    public function orderByHistoricTaskInstanceDuration(): HistoricTaskInstanceQueryImpl
672
    {
673
        if ($this->isOrQueryActive) {
674
            throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceDuration() within 'or' query");
675
        }
676
677
        $this->orderBy(HistoricTaskInstanceQueryProperty::duration());
678
        return $this;
679
    }
680
681
    public function orderByHistoricTaskInstanceEndTime(): HistoricTaskInstanceQueryImpl
682
    {
683
        if ($this->isOrQueryActive) {
684
            throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceEndTime() within 'or' query");
685
        }
686
687
        $this->orderBy(HistoricTaskInstanceQueryProperty::end());
688
        return $this;
689
    }
690
691
    public function orderByHistoricActivityInstanceStartTime(): HistoricTaskInstanceQueryImpl
692
    {
693
        if ($this->isOrQueryActive) {
694
            throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceStartTime() within 'or' query");
695
        }
696
697
        $this->orderBy(HistoricTaskInstanceQueryProperty::start());
698
        return $this;
699
    }
700
701
    public function orderByTaskName(): HistoricTaskInstanceQueryImpl
702
    {
703
        if ($this->isOrQueryActive) {
704
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskName() within 'or' query");
705
        }
706
707
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskName());
708
        return $this;
709
    }
710
711
    public function orderByTaskDescription(): HistoricTaskInstanceQueryImpl
712
    {
713
        if ($this->isOrQueryActive) {
714
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDescription() within 'or' query");
715
        }
716
717
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskDescription());
718
        return $this;
719
    }
720
721
    public function orderByTaskAssignee(): HistoricTaskInstanceQueryInterface
722
    {
723
        if ($this->isOrQueryActive) {
724
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskAssignee() within 'or' query");
725
        }
726
727
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskAssignee());
728
        return $this;
729
    }
730
731
    public function orderByTaskOwner(): HistoricTaskInstanceQueryInterface
732
    {
733
        if ($this->isOrQueryActive) {
734
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskOwner() within 'or' query");
735
        }
736
737
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskOwner());
738
        return $this;
739
    }
740
741
    public function orderByTaskDueDate(): HistoricTaskInstanceQueryInterface
742
    {
743
        if ($this->isOrQueryActive) {
744
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDueDate() within 'or' query");
745
        }
746
747
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskDueDate());
748
        return $this;
749
    }
750
751
    public function orderByTaskFollowUpDate(): HistoricTaskInstanceQueryInterface
752
    {
753
        if ($this->isOrQueryActive) {
754
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskFollowUpDate() within 'or' query");
755
        }
756
757
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskFollowUpDate());
758
        return $this;
759
    }
760
761
    public function orderByDeleteReason(): HistoricTaskInstanceQueryImpl
762
    {
763
        if ($this->isOrQueryActive) {
764
            throw new ProcessEngineException("Invalid query usage: cannot set orderByDeleteReason() within 'or' query");
765
        }
766
767
        $this->orderBy(HistoricTaskInstanceQueryProperty::deleteReason());
768
        return $this;
769
    }
770
771
    public function orderByTaskDefinitionKey(): HistoricTaskInstanceQueryInterface
772
    {
773
        if ($this->isOrQueryActive) {
774
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDefinitionKey() within 'or' query");
775
        }
776
777
        $this->orderBy(HistoricTaskInstanceQueryProperty::taskDefinitionKey());
778
        return $this;
779
    }
780
781
    public function orderByTaskPriority(): HistoricTaskInstanceQueryInterface
782
    {
783
        if ($this->isOrQueryActive) {
784
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskPriority() within 'or' query");
785
        }
786
787
        $this->orderBy(HistoricTaskInstanceQueryProperty:: taskPriority());
788
        return $this;
789
    }
790
791
    /*public HistoricTaskInstanceQueryInterface orderByCaseDefinitionId() {
792
        if ($this->isOrQueryActive) {
793
            throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseDefinitionId() within 'or' query");
794
        }
795
796
        $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_DEFINITION_ID);
797
        return $this;
798
    }
799
800
    public HistoricTaskInstanceQueryInterface orderByCaseInstanceId() {
801
        if ($this->isOrQueryActive) {
802
            throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseInstanceId() within 'or' query");
803
        }
804
805
        $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_INSTANCE_ID);
806
        return $this;
807
    }
808
809
    public function orderByCaseExecutionId(): HistoricTaskInstanceQueryInterface
810
    {
811
        if ($this->isOrQueryActive) {
812
            throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseExecutionId() within 'or' query");
813
        }
814
        $this->orderBy(HistoricTaskInstanceQueryProperty.CASE_EXECUTION_ID);
815
        return $this;
816
    }*/
817
818
    public function orderByTenantId(): HistoricTaskInstanceQueryInterface
819
    {
820
        if ($this->isOrQueryActive) {
821
            throw new ProcessEngineException("Invalid query usage: cannot set orderByTenantId() within 'or' query");
822
        }
823
        return $this->orderBy(HistoricTaskInstanceQueryProperty::tenantId());
824
    }
825
826
    // getters and setters //////////////////////////////////////////////////////
827
828
    public function getProcessInstanceId(): string
829
    {
830
        return $this->processInstanceId;
831
    }
832
833
    public function getProcessInstanceBusinessKey(): string
834
    {
835
        return $this->processInstanceBusinessKey;
836
    }
837
838
    public function getProcessInstanceBusinessKeys(): array
839
    {
840
        return $this->processInstanceBusinessKeys;
841
    }
842
843
    public function getProcessInstanceBusinessKeyLike(): string
844
    {
845
        return $this->processInstanceBusinessKeyLike;
846
    }
847
848
    public function getProcessDefinitionKey(): string
849
    {
850
        return $this->processDefinitionKey;
851
    }
852
853
    public function getProcessDefinitionName(): string
854
    {
855
        return $this->processDefinitionName;
856
    }
857
858
    public function getExecutionId(): string
859
    {
860
        return $this->executionId;
861
    }
862
863
    public function getActivityInstanceIds(): array
864
    {
865
        return $this->activityInstanceIds;
866
    }
867
868
    public function getProcessDefinitionId(): string
869
    {
870
        return $this->processDefinitionId;
871
    }
872
873
    public function isAssigned(): bool
874
    {
875
        return $this->assigned;
876
    }
877
878
    public function isUnassigned(): bool
879
    {
880
        return $this->unassigned;
881
    }
882
883
    public function isWithCandidateGroups(): bool
884
    {
885
        return $this->withCandidateGroups;
886
    }
887
888
    public function isWithoutCandidateGroups(): bool
889
    {
890
        return $this->withoutCandidateGroups;
891
    }
892
893
    public function isFinished(): bool
894
    {
895
        return $this->finished;
896
    }
897
898
    public function isProcessFinished(): bool
899
    {
900
        return $this->processFinished;
901
    }
902
903
    public function isUnfinished(): bool
904
    {
905
        return $this->unfinished;
906
    }
907
908
    public function isProcessUnfinished(): bool
909
    {
910
        return $this->processUnfinished;
911
    }
912
913
    public function getDueDate(): string
914
    {
915
        return $this->dueDate;
916
    }
917
918
    public function getDueBefore(): string
919
    {
920
        return $this->dueBefore;
921
    }
922
923
    public function getDueAfter(): string
924
    {
925
        return $this->dueAfter;
926
    }
927
928
    public function isWithoutTaskDueDate(): bool
929
    {
930
        return $this->isWithoutTaskDueDate;
931
    }
932
933
    public function getFollowUpDate(): string
934
    {
935
        return $this->followUpDate;
936
    }
937
938
    public function getFollowUpBefore(): string
939
    {
940
        return $this->followUpBefore;
941
    }
942
943
    public function getFollowUpAfter(): string
944
    {
945
        return $this->followUpAfter;
946
    }
947
948
    public function getTaskName(): string
949
    {
950
        return $this->taskName;
951
    }
952
953
    public function getTaskNameLike(): string
954
    {
955
        return $this->taskNameLike;
956
    }
957
958
    public function getTaskDescription(): string
959
    {
960
        return $this->taskDescription;
961
    }
962
963
    public function getTaskDescriptionLike(): string
964
    {
965
        return $this->taskDescriptionLike;
966
    }
967
968
    public function getTaskDeleteReason(): string
969
    {
970
        return $this->taskDeleteReason;
971
    }
972
973
    public function getTaskDeleteReasonLike(): string
974
    {
975
        return $this->taskDeleteReasonLike;
976
    }
977
978
    public function getTaskAssignee(): string
979
    {
980
        return $this->taskAssignee;
981
    }
982
983
    public function getTaskAssigneeLike(): string
984
    {
985
        return $this->taskAssigneeLike;
986
    }
987
988
    public function getTaskId(): string
989
    {
990
        return $this->taskId;
991
    }
992
993
    public function getTaskInvolvedGroup(): string
994
    {
995
        return $this->taskInvolvedGroup;
996
    }
997
998
    public function getTaskInvolvedUser(): string
999
    {
1000
        return $this->taskInvolvedUser;
1001
    }
1002
1003
    public function getTaskHadCandidateGroup(): string
1004
    {
1005
        return $this->taskHadCandidateGroup;
1006
    }
1007
1008
    public function getTaskHadCandidateUser(): string
1009
    {
1010
        return $this->taskHadCandidateUser;
1011
    }
1012
1013
    public function getTaskDefinitionKeys(): array
1014
    {
1015
        return $this->taskDefinitionKeys;
1016
    }
1017
1018
    public function getVariables(): array
1019
    {
1020
        return $this->variables;
1021
    }
1022
1023
    public function getVariableNamesIgnoreCase(): bool
1024
    {
1025
        return $this->variableNamesIgnoreCase;
1026
    }
1027
1028
    public function getVariableValuesIgnoreCase(): bool
1029
    {
1030
        return $this->variableValuesIgnoreCase;
1031
    }
1032
1033
    public function getTaskOwnerLike(): string
1034
    {
1035
        return $this->taskOwnerLike;
1036
    }
1037
1038
    public function getTaskOwner(): string
1039
    {
1040
        return $this->taskOwner;
1041
    }
1042
1043
    public function getTaskPriority(): int
1044
    {
1045
        return $this->taskPriority;
1046
    }
1047
1048
    public function getTaskParentTaskId(): string
1049
    {
1050
        return $this->taskParentTaskId;
1051
    }
1052
1053
    public function getTenantIds(): array
1054
    {
1055
        return $this->tenantIds;
1056
    }
1057
1058
    /*public String getCaseDefinitionId() {
1059
        return caseDefinitionId;
1060
    }
1061
1062
    public String getCaseDefinitionKey() {
1063
        return caseDefinitionKey;
1064
    }
1065
1066
    public String getCaseDefinitionName() {
1067
        return caseDefinitionName;
1068
    }
1069
1070
    public String getCaseInstanceId() {
1071
        return caseInstanceId;
1072
    }
1073
1074
    public function getCaseExecutionId(): string
1075
    {
1076
        return caseExecutionId;
1077
    }*/
1078
1079
    public function getFinishedAfter(): string
1080
    {
1081
        return $this->finishedAfter;
1082
    }
1083
1084
    public function getFinishedBefore(): string
1085
    {
1086
        return $this->finishedBefore;
1087
    }
1088
1089
    public function getStartedAfter(): string
1090
    {
1091
        return $this->startedAfter;
1092
    }
1093
1094
    public function getStartedBefore(): string
1095
    {
1096
        return $this->startedBefore;
1097
    }
1098
1099
    public function isTenantIdSet(): bool
1100
    {
1101
        return $this->isTenantIdSet;
1102
    }
1103
1104
    public function getQueries(): array
1105
    {
1106
        return $this->queries;
1107
    }
1108
1109
    public function isOrQueryActive(): bool
1110
    {
1111
        return $this->isOrQueryActive;
1112
    }
1113
1114
    public function addOrQuery(HistoricTaskInstanceQueryImpl $orQuery): void
1115
    {
1116
        $orQuery->isOrQueryActive = true;
1117
        $this->queries[] = $orQuery;
1118
    }
1119
1120
    public function setOrQueryActive(): void
1121
    {
1122
        $this->isOrQueryActive = true;
1123
    }
1124
1125
    public function or(): HistoricTaskInstanceQueryInterface
1126
    {
1127
        if ($this != $this->queries[0]) {
1128
            throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query");
1129
        }
1130
1131
        $orQuery = new HistoricTaskInstanceQueryImpl();
0 ignored issues
show
Bug introduced by
The call to Jabe\Engine\Impl\Histori...ueryImpl::__construct() has too few arguments starting with commandExecutor. ( Ignorable by Annotation )

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

1131
        $orQuery = /** @scrutinizer ignore-call */ new HistoricTaskInstanceQueryImpl();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1132
        $orQuery->isOrQueryActive = true;
1133
        //@CHECK IT OUT
1134
        $orQuery->queries = $this->queries;
1135
        $this->queries[] = $orQuery;
1136
        return $orQuery;
1137
    }
1138
1139
    public function endOr(): HistoricTaskInstanceQueryInterface
1140
    {
1141
        if (!empty($this->queries) && $this != $this->queries[count($this->queries) - 1]) {
1142
            throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()");
1143
        }
1144
        return $this->queries[0];
1145
    }
1146
}
1147