Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
48 / 48 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
Request | |
100.00% |
48 / 48 |
|
100.00% |
8 / 8 |
12 | |
100.00% |
1 / 1 |
getEntityMapping | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
addConditionRequestId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionProcessId | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
addConditionArchiveId | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
addConditionProvider | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
addConditionRequestSource | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
postProcess | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
addConditionIds | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | class Request extends Base |
6 | { |
7 | const TABLE = 'request'; |
8 | |
9 | const BATABLE = 'buergeranliegen'; |
10 | |
11 | const QUERY_BY_PROCESSID = 'SELECT |
12 | ba.`AnliegenID` AS id |
13 | FROM `buergeranliegen` ba |
14 | WHERE |
15 | ba.`BuergerID` = :process_id |
16 | '; |
17 | |
18 | public function getEntityMapping() |
19 | { |
20 | $mapping = [ |
21 | 'id' => 'request.id', |
22 | 'link' => 'request.link', |
23 | 'name' => 'request.name', |
24 | 'group' => 'request.group', |
25 | 'source' => 'request.source' |
26 | ]; |
27 | if ($this->getResolveLevel() > 0) { |
28 | $mapping['data'] = 'request.data'; |
29 | } |
30 | return $mapping; |
31 | } |
32 | |
33 | public function addConditionRequestId($requestId) |
34 | { |
35 | $this->query->where('id', '=', $requestId); |
36 | return $this; |
37 | } |
38 | |
39 | public function addConditionProcessId($processId) |
40 | { |
41 | $this->leftJoin( |
42 | new Alias("buergeranliegen", 'buergeranliegen'), |
43 | self::expression(' |
44 | buergeranliegen.AnliegenID = request.id |
45 | AND buergeranliegen.source = request.source |
46 | ') |
47 | ); |
48 | $this->query->where('buergeranliegen.BuergerID', '=', $processId); |
49 | return $this; |
50 | } |
51 | |
52 | public function addConditionArchiveId($archiveId) |
53 | { |
54 | $this->leftJoin( |
55 | new Alias("buergeranliegen", 'buergeranliegen'), |
56 | self::expression(' |
57 | buergeranliegen.AnliegenID = request.id |
58 | AND buergeranliegen.source = request.source |
59 | ') |
60 | ); |
61 | $this->query->where('buergeranliegen.BuergerarchivID', '=', $archiveId); |
62 | return $this; |
63 | } |
64 | |
65 | public function addConditionProvider($providerId, $source) |
66 | { |
67 | $this->leftJoin( |
68 | new Alias("request_provider", 'xrequest'), |
69 | 'request.id', |
70 | '=', |
71 | 'xrequest.request__id' |
72 | ); |
73 | $this->query->where(function (\Solution10\SQL\ConditionBuilder $query) use ($providerId, $source) { |
74 | $query->andWith('xrequest.provider__id', '=', $providerId); |
75 | $query->andWith('xrequest.source', '=', $source); |
76 | $query->andWith('xrequest.bookable', '=', 1); |
77 | }); |
78 | return $this; |
79 | } |
80 | |
81 | public function addConditionRequestSource($source) |
82 | { |
83 | $this->query->where('request.source', '=', $source); |
84 | return $this; |
85 | } |
86 | |
87 | public function postProcess($data) |
88 | { |
89 | if (isset($data[$this->getPrefixed('data')]) && $data[$this->getPrefixed('data')]) { |
90 | $data[$this->getPrefixed('data')] = json_decode($data[$this->getPrefixed('data')], true); |
91 | } |
92 | return $data; |
93 | } |
94 | |
95 | public function addConditionIds($ids) |
96 | { |
97 | $this->query->where(function (\Solution10\SQL\ConditionBuilder $query) use ($ids) { |
98 | foreach ($ids as $id) { |
99 | $query->orWith('request.id', '=', $id); |
100 | } |
101 | }); |
102 | |
103 | return $this; |
104 | } |
105 | } |