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