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