1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edmx; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\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 string $version |
19
|
|
|
*/ |
20
|
|
|
private $version = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDesignerType $designer |
24
|
|
|
*/ |
25
|
|
|
private $designer = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edmx\TRuntimeType $runtime |
29
|
|
|
*/ |
30
|
|
|
private $runtime = null; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] $dataServices |
34
|
|
|
*/ |
35
|
|
|
private $dataServices = []; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Gets as version |
39
|
|
|
* |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public function getVersion() |
43
|
|
|
{ |
44
|
|
|
return $this->version; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Sets a new version |
49
|
|
|
* |
50
|
|
|
* @param string $version |
51
|
|
|
* @return self |
52
|
|
|
*/ |
53
|
|
|
public function setVersion($version) |
54
|
|
|
{ |
55
|
|
|
$this->version = $version; |
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Gets as designer |
61
|
|
|
* |
62
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDesignerType |
63
|
|
|
*/ |
64
|
|
|
public function getDesigner() |
65
|
|
|
{ |
66
|
|
|
return $this->designer; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Sets a new designer |
71
|
|
|
* |
72
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edmx\TDesignerType $designer |
73
|
|
|
* @return self |
74
|
|
|
*/ |
75
|
|
|
public function setDesigner(TDesignerType $designer) |
76
|
|
|
{ |
77
|
|
|
$this->designer = $designer; |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Gets as runtime |
83
|
|
|
* |
84
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edmx\TRuntimeType |
85
|
|
|
*/ |
86
|
|
|
public function getRuntime() |
87
|
|
|
{ |
88
|
|
|
return $this->runtime; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Sets a new runtime |
93
|
|
|
* |
94
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edmx\TRuntimeType $runtime |
95
|
|
|
* @return self |
96
|
|
|
*/ |
97
|
|
|
public function setRuntime(TRuntimeType $runtime) |
98
|
|
|
{ |
99
|
|
|
$this->runtime = $runtime; |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Adds as schema |
105
|
|
|
* |
106
|
|
|
* @return self |
107
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema $schema |
108
|
|
|
*/ |
109
|
|
|
public function addToDataServices(Schema $schema) |
110
|
|
|
{ |
111
|
|
|
$this->dataServices[] = $schema; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* isset dataServices |
117
|
|
|
* |
118
|
|
|
* @param scalar $index |
119
|
|
|
* @return boolean |
120
|
|
|
*/ |
121
|
|
|
public function issetDataServices($index) |
122
|
|
|
{ |
123
|
|
|
return isset($this->dataServices[$index]); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* unset dataServices |
128
|
|
|
* |
129
|
|
|
* @param scalar $index |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function unsetDataServices($index) |
133
|
|
|
{ |
134
|
|
|
unset($this->dataServices[$index]); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Gets as dataServices |
139
|
|
|
* |
140
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] |
141
|
|
|
*/ |
142
|
|
|
public function getDataServices() |
143
|
|
|
{ |
144
|
|
|
return $this->dataServices; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Sets a new dataServices |
149
|
|
|
* |
150
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] $dataServices |
151
|
|
|
* @return self |
152
|
|
|
*/ |
153
|
|
|
public function setDataServices(array $dataServices) |
154
|
|
|
{ |
155
|
|
|
$this->dataServices = $dataServices; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function isOK(&$msg = null) |
160
|
|
|
{ |
161
|
|
|
if (!$this->isStringNotNullOrEmpty($this->version)) { |
162
|
|
|
$msg = "Version cannot be null or empty"; |
163
|
|
|
return false; |
164
|
|
|
} |
165
|
|
|
if (null != $this->designer && !$this->designer->isOK($msg)) { |
166
|
|
|
return false; |
167
|
|
|
} |
168
|
|
|
if (null != $this->runtime && !$this->runtime->isOK($msg)) { |
169
|
|
|
return false; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
if (!$this->isValidArray( |
173
|
|
|
$this->dataServices, |
174
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\Schema' |
175
|
|
|
)) { |
176
|
|
|
$msg = "Data services array not a valid array"; |
177
|
|
|
return false; |
178
|
|
|
} |
179
|
|
|
if (null == $this->runtime && 0 == count($this->dataServices)) { |
180
|
|
|
$msg = "Either a runtime or a dataservice must be defined for Tedmx"; |
181
|
|
|
return false; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
if (!$this->isChildArrayOK($this->dataServices, $msg)) { |
185
|
|
|
return false; |
186
|
|
|
} |
187
|
|
|
return true; |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|