Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
45 / 45 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
WorkstationRequests | |
100.00% |
45 / 45 |
|
100.00% |
7 / 7 |
14 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getScope | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDifferentScope | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
readDepartment | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
readCluster | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
readProcessListByDate | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
3 | |||
readNextProcess | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsclient; |
4 | |
5 | class WorkstationRequests |
6 | { |
7 | /** |
8 | * @var \BO\Zmsclient\Http $http |
9 | */ |
10 | protected $http; |
11 | |
12 | /** |
13 | * @var \BO\Zmsentities\Workstation $workstation |
14 | */ |
15 | protected $workstation; |
16 | |
17 | /** |
18 | * @var \BO\Zmsentities\Cluster $cluster |
19 | */ |
20 | protected $cluster; |
21 | |
22 | /** |
23 | * @var \BO\Zmsentities\Department $department |
24 | */ |
25 | protected $department; |
26 | |
27 | /** |
28 | * @var \BO\Zmsentities\Scope $scope |
29 | */ |
30 | protected $scope; |
31 | |
32 | |
33 | public function __construct( |
34 | Http $http, |
35 | \BO\Zmsentities\Workstation $workstation |
36 | ) { |
37 | $this->http = $http; |
38 | $this->workstation = $workstation; |
39 | $this->scope = $workstation->getScope(); |
40 | } |
41 | |
42 | public function getScope(): \BO\Zmsentities\Scope |
43 | { |
44 | return $this->scope; |
45 | } |
46 | |
47 | public function setDifferentScope(\BO\Zmsentities\Scope $scope): self |
48 | { |
49 | $this->scope = $scope; |
50 | return $this; |
51 | } |
52 | |
53 | public function readDepartment(): \BO\Zmsentities\Department |
54 | { |
55 | if (!$this->department) { |
56 | $this->department = $this->http->readGetResult('/scope/' . $this->scope['id'] . '/department/') |
57 | ->getEntity(); |
58 | } |
59 | return $this->department ? $this->department : new \BO\Zmsentities\Department(); |
60 | } |
61 | |
62 | public function readCluster(): \BO\Zmsentities\Cluster |
63 | { |
64 | if (!$this->cluster) { |
65 | $this->cluster = $this->http->readGetResult('/scope/' . $this->scope['id'] . '/cluster/') |
66 | ->getEntity(); |
67 | } |
68 | return $this->cluster ? $this->cluster : new \BO\Zmsentities\Cluster(); |
69 | } |
70 | |
71 | public function readProcessListByDate( |
72 | \DateTimeInterface $selectedDate, |
73 | $gql = "" |
74 | ): \BO\Zmsentities\Collection\ProcessList { |
75 | if ($this->workstation->isClusterEnabled()) { |
76 | $processList = $this->http |
77 | ->readGetResult( |
78 | '/cluster/' . $this->readCluster()->id . '/process/' . $selectedDate->format('Y-m-d') . '/', |
79 | [ |
80 | 'resolveReferences' => 2, |
81 | 'gql' => $gql |
82 | ] |
83 | ) |
84 | ->getCollection(); |
85 | } else { |
86 | $processList = $this->http |
87 | ->readGetResult( |
88 | '/scope/' . $this->scope['id'] . '/process/' . $selectedDate->format('Y-m-d') . '/', |
89 | [ |
90 | 'resolveReferences' => 2, |
91 | 'gql' => $gql |
92 | ] |
93 | ) |
94 | ->getCollection(); |
95 | } |
96 | return ($processList) ? $processList : new \BO\Zmsentities\Collection\ProcessList(); |
97 | } |
98 | |
99 | |
100 | public function readNextProcess($excludedIds) |
101 | { |
102 | if ($this->workstation->isClusterEnabled()) { |
103 | $process = $this->http |
104 | ->readGetResult('/cluster/' . $this->cluster['id'] . '/queue/next/', ['exclude' => $excludedIds]) |
105 | ->getEntity(); |
106 | } else { |
107 | $process = $this->http |
108 | ->readGetResult( |
109 | '/scope/' . $this->scope['id'] . '/queue/next/', |
110 | ['exclude' => $excludedIds] |
111 | ) |
112 | ->getEntity(); |
113 | } |
114 | return $process; |
115 | } |
116 | } |