1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV4\edmx; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV4\edm\Schema; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class representing TEdmxType |
10
|
|
|
* |
11
|
|
|
* |
12
|
|
|
* XSD Type: TEdmx |
13
|
|
|
*/ |
14
|
|
|
class TEdmxType extends IsOK |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @property float $version |
19
|
|
|
*/ |
20
|
|
|
private $version = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV4\edmx\TReferenceType[] $reference |
24
|
|
|
*/ |
25
|
|
|
private $reference = []; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV4\edm\Schema[] $dataServices |
29
|
|
|
*/ |
30
|
|
|
private $dataServices = null; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Gets as version |
34
|
|
|
* |
35
|
|
|
* @return float |
36
|
|
|
*/ |
37
|
|
|
public function getVersion() |
38
|
|
|
{ |
39
|
|
|
return $this->version; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Sets a new version |
44
|
|
|
* |
45
|
|
|
* @param float $version |
46
|
|
|
* @return self |
47
|
|
|
*/ |
48
|
|
|
public function setVersion($version) |
49
|
|
|
{ |
50
|
|
|
$this->version = $version; |
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Adds as reference |
56
|
|
|
* |
57
|
|
|
* @return self |
58
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TReferenceType $reference |
59
|
|
|
*/ |
60
|
|
|
public function addToReference(TReferenceType $reference) |
61
|
|
|
{ |
62
|
|
|
$this->reference[] = $reference; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* isset reference |
68
|
|
|
* |
69
|
|
|
* @param scalar $index |
70
|
|
|
* @return boolean |
71
|
|
|
*/ |
72
|
|
|
public function issetReference($index) |
73
|
|
|
{ |
74
|
|
|
return isset($this->reference[$index]); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* unset reference |
79
|
|
|
* |
80
|
|
|
* @param scalar $index |
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
|
|
public function unsetReference($index) |
84
|
|
|
{ |
85
|
|
|
unset($this->reference[$index]); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Gets as reference |
90
|
|
|
* |
91
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV4\edmx\TReferenceType[] |
92
|
|
|
*/ |
93
|
|
|
public function getReference() |
94
|
|
|
{ |
95
|
|
|
return $this->reference; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Sets a new reference |
100
|
|
|
* |
101
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TReferenceType[] $reference |
102
|
|
|
* @return self |
103
|
|
|
*/ |
104
|
|
|
public function setReference(array $reference) |
105
|
|
|
{ |
106
|
|
|
$this->reference = $reference; |
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Adds as schema |
112
|
|
|
* |
113
|
|
|
* @return self |
114
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edm\Schema $schema |
115
|
|
|
*/ |
116
|
|
|
public function addToDataServices(Schema $schema) |
117
|
|
|
{ |
118
|
|
|
$this->dataServices[] = $schema; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* isset dataServices |
124
|
|
|
* |
125
|
|
|
* @param scalar $index |
126
|
|
|
* @return boolean |
127
|
|
|
*/ |
128
|
|
|
public function issetDataServices($index) |
129
|
|
|
{ |
130
|
|
|
return isset($this->dataServices[$index]); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* unset dataServices |
135
|
|
|
* |
136
|
|
|
* @param scalar $index |
137
|
|
|
* @return void |
138
|
|
|
*/ |
139
|
|
|
public function unsetDataServices($index) |
140
|
|
|
{ |
141
|
|
|
unset($this->dataServices[$index]); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Gets as dataServices |
146
|
|
|
* |
147
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV4\edm\Schema[] |
148
|
|
|
*/ |
149
|
|
|
public function getDataServices() |
150
|
|
|
{ |
151
|
|
|
return $this->dataServices; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Sets a new dataServices |
156
|
|
|
* |
157
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edm\Schema[] $dataServices |
158
|
|
|
* @return self |
159
|
|
|
*/ |
160
|
|
|
public function setDataServices(array $dataServices) |
161
|
|
|
{ |
162
|
|
|
$this->dataServices = $dataServices; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
public function isOK(&$msg = null) |
167
|
|
|
{ |
168
|
|
|
if (is_null($this->version)) { |
169
|
|
|
$msg = "Edmx version can not be null"; |
170
|
|
|
return false; |
171
|
|
|
} |
172
|
|
|
if (is_float($this->version)) { |
173
|
|
|
if (!$this->isValidArray($this->dataServices, \AlgoWeb\ODataMetadata\MetadataV4\edm\Schema, 1)) { |
174
|
|
|
$msg = "Edmx dataservice definition contains invalid enteries."; |
175
|
|
|
return false; |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
if (!$this->isValidArray($this->reference, \AlgoWeb\ODataMetadata\MetadataV4\edmx\TReferenceType)) { |
179
|
|
|
$msg = "Edmx references contains invalid elements"; |
180
|
|
|
return false; |
181
|
|
|
} |
182
|
|
|
if (!$this->isChildArrayOK($this->dataServices, $msg)) { |
183
|
|
|
return false; |
184
|
|
|
} |
185
|
|
|
if (!$this->isChildArrayOK($this->reference, $msg)) { |
186
|
|
|
return false; |
187
|
|
|
} |
188
|
|
|
return true; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|