Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
64 / 64 |
|
100.00% |
14 / 14 |
CRAP | |
100.00% |
1 / 1 |
Workstation | |
100.00% |
64 / 64 |
|
100.00% |
14 / 14 |
19 | |
100.00% |
1 / 1 |
addRequiredJoins | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLockWorkstationId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getEntityMapping | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
addJoin | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
addJoinScope | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
addJoinUseraccount | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
addConditionLoginName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionWorkstationName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionWorkstationIsNotCounter | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionWorkstationId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionScopeId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionTime | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDepartmentId | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
reverseEntityMapping | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | /** |
6 | * @SuppressWarnings(Public) |
7 | * |
8 | */ |
9 | class Workstation extends Base implements MappingInterface |
10 | { |
11 | /** |
12 | * @var String TABLE mysql table reference |
13 | */ |
14 | const TABLE = 'nutzer'; |
15 | |
16 | const QUERY_LOGIN = ' |
17 | UPDATE |
18 | ' . self::TABLE . ' |
19 | SET |
20 | `SessionID`=?, |
21 | `sessionExpiry`=?, |
22 | `Datum`=?, |
23 | `lastUpdate`=?, |
24 | `Arbeitsplatznr`="", |
25 | `aufrufzusatz`="", |
26 | `StandortID`=0 |
27 | WHERE |
28 | `Name`=? AND |
29 | `Passworthash` = ? |
30 | '; |
31 | |
32 | const QUERY_LOGIN_OIDC = ' |
33 | UPDATE |
34 | ' . self::TABLE . ' |
35 | SET |
36 | `SessionID`=?, |
37 | `sessionExpiry`=?, |
38 | `Datum`=?, |
39 | `Arbeitsplatznr`="", |
40 | `aufrufzusatz`="", |
41 | `StandortID`=0 |
42 | WHERE |
43 | `Name`=? |
44 | '; |
45 | |
46 | const QUERY_PROCESS_RESET = ' |
47 | UPDATE |
48 | ' . Process::TABLE . ' |
49 | SET |
50 | `NutzerID` = 0, |
51 | `aufrufzeit` = "00:00:00" |
52 | WHERE |
53 | `NutzerID` = ? |
54 | '; |
55 | |
56 | const QUERY_LOGOUT = ' |
57 | UPDATE |
58 | ' . self::TABLE . ' |
59 | SET |
60 | `SessionID`="", |
61 | `sessionExpiry`=NULL, |
62 | `StandortID`=0, |
63 | `Datum`="0000-00-00", |
64 | `Arbeitsplatznr`="", |
65 | `aufrufzusatz`="" |
66 | WHERE |
67 | `Name`= ? |
68 | '; |
69 | |
70 | const QUERY_LOGGEDIN_CHECK = ' |
71 | SELECT |
72 | SessionID as hash |
73 | FROM |
74 | ' . self::TABLE . ' |
75 | WHERE |
76 | `Name` = :loginName |
77 | LIMIT 1 |
78 | '; |
79 | |
80 | const QUERY_UPDATE_AUTHKEY = ' |
81 | UPDATE |
82 | ' . self::TABLE . ' |
83 | SET |
84 | `SessionID`=?, |
85 | `sessionExpiry`=? |
86 | WHERE |
87 | `Name`= ? AND |
88 | `Passworthash` = ? |
89 | '; |
90 | |
91 | protected function addRequiredJoins() |
92 | { |
93 | } |
94 | |
95 | public function getLockWorkstationId() |
96 | { |
97 | return 'SELECT * FROM `' . self::getTablename() . '` A |
98 | WHERE A.`NutzerID` = :workstationId FOR UPDATE'; |
99 | } |
100 | |
101 | public function getEntityMapping() |
102 | { |
103 | return [ |
104 | 'id' => 'workstation.NutzerID', |
105 | 'hint' => 'workstation.aufrufzusatz', |
106 | 'name' => 'workstation.Arbeitsplatznr', |
107 | 'queue__appointmentsOnly' => 'workstation.Kalenderansicht', |
108 | 'queue__clusterEnabled' => 'workstation.clusteransicht', |
109 | 'scope__id' => 'workstation.StandortID' |
110 | ]; |
111 | } |
112 | |
113 | public function addJoin() |
114 | { |
115 | return [ |
116 | $this->addJoinUseraccount(), |
117 | $this->addJoinScope(), |
118 | ]; |
119 | } |
120 | |
121 | public function addJoinScope() |
122 | { |
123 | $this->leftJoin( |
124 | new Alias(Scope::TABLE, 'scope'), |
125 | 'workstation.StandortID', |
126 | '=', |
127 | 'scope.StandortID' |
128 | ); |
129 | $joinQuery = new Scope($this, $this->getPrefixed('scope__')); |
130 | return $joinQuery; |
131 | } |
132 | |
133 | |
134 | public function addJoinUseraccount() |
135 | { |
136 | $this->leftJoin( |
137 | new Alias(Useraccount::TABLE, 'useraccount'), |
138 | 'workstation.NutzerID', |
139 | '=', |
140 | 'useraccount.NutzerID' |
141 | ); |
142 | $joinQuery = new Useraccount($this, $this->getPrefixed('useraccount__')); |
143 | return $joinQuery; |
144 | } |
145 | |
146 | public function addConditionLoginName($loginName) |
147 | { |
148 | $this->query->where('workstation.Name', '=', $loginName); |
149 | return $this; |
150 | } |
151 | |
152 | public function addConditionWorkstationName($workstationName) |
153 | { |
154 | $this->query->where('workstation.Arbeitsplatznr', '=', $workstationName); |
155 | return $this; |
156 | } |
157 | |
158 | public function addConditionWorkstationIsNotCounter() |
159 | { |
160 | $this->query->where('workstation.Arbeitsplatznr', '>', 0); |
161 | return $this; |
162 | } |
163 | |
164 | public function addConditionWorkstationId($workstationId) |
165 | { |
166 | $this->query->where('workstation.NutzerID', '=', $workstationId); |
167 | return $this; |
168 | } |
169 | |
170 | public function addConditionScopeId($scopeId) |
171 | { |
172 | $this->query->where('workstation.StandortID', '=', $scopeId); |
173 | return $this; |
174 | } |
175 | |
176 | public function addConditionTime($now) |
177 | { |
178 | $this->query->where('workstation.Datum', '=', $now->format('Y-m-d')); |
179 | return $this; |
180 | } |
181 | |
182 | public function addConditionDepartmentId($departmentId) |
183 | { |
184 | $this->leftJoin( |
185 | new Alias(Useraccount::TABLE_ASSIGNMENT, 'workstation_department'), |
186 | 'workstation.NutzerID', |
187 | '=', |
188 | 'workstation_department.nutzerid' |
189 | ); |
190 | $this->query->where('workstation_department.behoerdenid', '=', $departmentId); |
191 | return $this; |
192 | } |
193 | |
194 | public function reverseEntityMapping(\BO\Zmsentities\Workstation $entity) |
195 | { |
196 | $data = array(); |
197 | if ((isset($entity['hint']) && '' == $entity['hint']) || ! isset($entity['hint'])) { |
198 | $data['aufrufzusatz'] = $entity->name; |
199 | } else { |
200 | $data['aufrufzusatz'] = $entity['hint']; |
201 | } |
202 | |
203 | $data['Kalenderansicht'] = $entity->getQueuePreference('appointmentsOnly', true); |
204 | $data['clusteransicht'] = $entity->getQueuePreference('clusterEnabled', true); |
205 | if (isset($entity->scope['id'])) { |
206 | $data['StandortID'] = $entity->scope['id']; |
207 | } |
208 | $data['Arbeitsplatznr'] = $entity->name; |
209 | |
210 | $data = array_filter($data, function ($value) { |
211 | return ($value !== null && $value !== false); |
212 | }); |
213 | return $data; |
214 | } |
215 | } |