Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
36 / 36
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
ClusterHelper
100.00% covered (success)
100.00%
36 / 36
100.00% covered (success)
100.00%
6 / 6
13
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%
19 / 19
100.00% covered (success)
100.00%
1 / 1
5
 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
12class 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                    ['resolveReferences' => 1, 'gql' => GraphDefaults::getProcess()]
41                );
42        } else {
43            $processList = \App::$http
44                ->readGetResult(
45                    '/scope/' . static::$workstation->scope['id'] . '/process/' . $selectedDate . '/',
46                    ['resolveReferences' => 1, '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        $queueList = static::getProcessList(\App::$now->format('Y-m-d'))
55            ->toQueueList(\App::$now)
56            ->withoutStatus(['fake','missed', 'parked']);
57        $excludedIds = (0 < $queueList->count()) ? $excludedIds : '';
58
59        if (1 > $queueList->count()) {
60            return new \BO\Zmsentities\Process();
61        }
62        if (static::isClusterEnabled()) {
63            $nextProcess =  \App::$http->readGetResult(
64                '/cluster/' . static::$cluster['id'] . '/queue/next/',
65                [
66                    'exclude' => $excludedIds,
67                    'allowClusterWideCall' => \App::$allowClusterWideCall
68                ]
69            )->getEntity();
70        } else {
71            $nextProcess = \App::$http->readGetResult(
72                '/scope/' . static::$workstation->scope['id'] . '/queue/next/',
73                ['exclude' => $excludedIds]
74            )->getEntity();
75        }
76
77
78        return ($nextProcess) ? $nextProcess : new \BO\Zmsentities\Process();
79    }
80
81    public static function isClusterEnabled()
82    {
83        return (static::$workstation->queue['clusterEnabled'] && static::$cluster);
84    }
85}