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