Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
43 / 43 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| WorkstationRequests | |
100.00% |
43 / 43 |
|
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% |
18 / 18 |
|
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 | 'gql' => $gql |
| 81 | ] |
| 82 | ) |
| 83 | ->getCollection(); |
| 84 | } else { |
| 85 | $processList = $this->http |
| 86 | ->readGetResult( |
| 87 | '/scope/' . $this->scope['id'] . '/process/' . $selectedDate->format('Y-m-d') . '/', |
| 88 | [ |
| 89 | 'gql' => $gql |
| 90 | ] |
| 91 | ) |
| 92 | ->getCollection(); |
| 93 | } |
| 94 | return ($processList) ? $processList : new \BO\Zmsentities\Collection\ProcessList(); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | public function readNextProcess($excludedIds) |
| 99 | { |
| 100 | if ($this->workstation->isClusterEnabled()) { |
| 101 | $process = $this->http |
| 102 | ->readGetResult('/cluster/' . $this->cluster['id'] . '/queue/next/', ['exclude' => $excludedIds]) |
| 103 | ->getEntity(); |
| 104 | } else { |
| 105 | $process = $this->http |
| 106 | ->readGetResult( |
| 107 | '/scope/' . $this->scope['id'] . '/queue/next/', |
| 108 | ['exclude' => $excludedIds] |
| 109 | ) |
| 110 | ->getEntity(); |
| 111 | } |
| 112 | return $process; |
| 113 | } |
| 114 | } |