Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
44 / 44
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
Cluster
100.00% covered (success)
100.00%
44 / 44
100.00% covered (success)
100.00%
8 / 8
10
100.00% covered (success)
100.00%
1 / 1
 getQueryWriteAssignedScopes
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQueryDeleteAssignedScopes
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getEntityMapping
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 addConditionClusterId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addConditionDepartmentId
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 addConditionScopeId
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 reverseEntityMapping
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
3
 addRequiredJoins
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace BO\Zmsdb\Query;
4
5class Cluster extends Base
6{
7    /**
8     * @var String TABLE mysql table reference
9     */
10    const TABLE = 'standortcluster';
11
12    public function getQueryWriteAssignedScopes()
13    {
14        return '
15            REPLACE INTO `clusterzuordnung`
16            SET
17                clusterID=:clusterId,
18                standortID=:scopeId
19        ';
20    }
21
22    public function getQueryDeleteAssignedScopes()
23    {
24        return '
25            DELETE FROM `clusterzuordnung`
26            WHERE
27                `clusterID` = :clusterId
28        ';
29    }
30
31    public function getEntityMapping()
32    {
33        return [
34            'id' => 'cluster.clusterID',
35            'name' => 'cluster.name',
36            'hint' => 'cluster.clusterinfozeile1',
37            'shortNameEnabled' => 'cluster.standortkuerzelanzeigen',
38            'callDisplayText' => 'cluster.aufrufanzeigetext'
39        ];
40    }
41
42    public function addConditionClusterId($clusterId)
43    {
44        $this->query->where('cluster.clusterID', '=', $clusterId);
45        return $this;
46    }
47
48    public function addConditionDepartmentId($departementId)
49    {
50        $this->leftJoin(
51            new Alias('standort', 'scope'),
52            'scope.StandortID',
53            '=',
54            'cluster_scope.standortID'
55        );
56        $this->query->where('scope.BehoerdenID', '=', $departementId);
57        return $this;
58    }
59
60    public function addConditionScopeId($scopeId)
61    {
62        $this->leftJoin(
63            new Alias('standort', 'scope'),
64            'scope.StandortID',
65            '=',
66            'cluster_scope.standortID'
67        );
68        $this->query->where('scope.StandortID', '=', $scopeId);
69        return $this;
70    }
71
72    public function reverseEntityMapping(\BO\Zmsentities\Cluster $entity)
73    {
74        $data = array();
75        $data['name'] = $entity->name;
76        $data['clusterinfozeile1'] = $entity->hint;
77        $data['standortkuerzelanzeigen'] = ($entity->shortNameEnabled)  ? 1 : 0;
78        $data['aufrufanzeigetext'] = $entity->callDisplayText;
79
80        $data = array_filter($data, function ($value) {
81            return ($value !== null && $value !== false);
82        });
83        return $data;
84    }
85
86    public function addRequiredJoins()
87    {
88        $this->leftJoin(
89            new Alias('clusterzuordnung', 'cluster_scope'),
90            'cluster.clusterID',
91            '=',
92            'cluster_scope.clusterID'
93        );
94    }
95}