Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
30 / 30 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| ClusterHelper | |
100.00% |
30 / 30 |
|
100.00% |
6 / 6 |
10 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getEntity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getScopeList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProcessList | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
3 | |||
| getNextProcess | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
2 | |||
| isClusterEnabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsappointment |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsadmin\Helper; |
| 11 | |
| 12 | class ClusterHelper |
| 13 | { |
| 14 | protected static $cluster = null; |
| 15 | |
| 16 | protected static $workstation = null; |
| 17 | |
| 18 | public function __construct(\BO\Zmsentities\Workstation $workstation) |
| 19 | { |
| 20 | static::$workstation = $workstation; |
| 21 | static::$cluster = \App::$http->readGetResult('/scope/' . $workstation->scope['id'] . '/cluster/')->getEntity(); |
| 22 | } |
| 23 | |
| 24 | public static function getEntity() |
| 25 | { |
| 26 | return static::$cluster; |
| 27 | } |
| 28 | |
| 29 | public static function getScopeList() |
| 30 | { |
| 31 | return static::$workstation->getScopeList(static::$cluster); |
| 32 | } |
| 33 | |
| 34 | public static function getProcessList($selectedDate) |
| 35 | { |
| 36 | if (static::isClusterEnabled()) { |
| 37 | $processList = \App::$http |
| 38 | ->readGetResult( |
| 39 | '/cluster/' . static::$cluster->id . '/process/' . $selectedDate . '/', |
| 40 | ['gql' => GraphDefaults::getProcess()] |
| 41 | ); |
| 42 | } else { |
| 43 | $processList = \App::$http |
| 44 | ->readGetResult( |
| 45 | '/scope/' . static::$workstation->scope['id'] . '/process/' . $selectedDate . '/', |
| 46 | ['gql' => GraphDefaults::getProcess()] |
| 47 | ); |
| 48 | } |
| 49 | return ($processList) ? $processList->getCollection() : new \BO\Zmsentities\Collection\ProcessList(); |
| 50 | } |
| 51 | |
| 52 | public static function getNextProcess($excludedIds) |
| 53 | { |
| 54 | if (static::isClusterEnabled()) { |
| 55 | $nextProcess = \App::$http->readGetResult( |
| 56 | '/cluster/' . static::$cluster['id'] . '/queue/next/', |
| 57 | [ |
| 58 | 'exclude' => $excludedIds, |
| 59 | 'allowClusterWideCall' => \App::$allowClusterWideCall |
| 60 | ] |
| 61 | )?->getEntity(); |
| 62 | } else { |
| 63 | $nextProcess = \App::$http->readGetResult( |
| 64 | '/scope/' . static::$workstation->scope['id'] . '/queue/next/', |
| 65 | ['exclude' => $excludedIds] |
| 66 | )?->getEntity(); |
| 67 | } |
| 68 | |
| 69 | return $nextProcess; |
| 70 | } |
| 71 | |
| 72 | public static function isClusterEnabled() |
| 73 | { |
| 74 | return (static::$workstation->queue['clusterEnabled'] && static::$cluster); |
| 75 | } |
| 76 | } |