1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\mapping\cs; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TSimpleIdentifierTrait; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class representing TEntitySetMappingType |
10
|
|
|
* |
11
|
|
|
* |
12
|
|
|
* XSD Type: TEntitySetMapping |
13
|
|
|
*/ |
14
|
|
|
class TEntitySetMappingType extends IsOK |
15
|
|
|
{ |
16
|
|
|
use TSimpleIdentifierTrait; |
17
|
|
|
/** |
18
|
|
|
* @property string $name |
19
|
|
|
*/ |
20
|
|
|
private $name = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @property string $typeName |
24
|
|
|
*/ |
25
|
|
|
private $typeName = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @property string $storeEntitySet |
29
|
|
|
*/ |
30
|
|
|
private $storeEntitySet = null; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @property boolean $makeColumnsDistinct |
34
|
|
|
*/ |
35
|
|
|
private $makeColumnsDistinct = null; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TQueryViewType[] $queryView |
39
|
|
|
*/ |
40
|
|
|
private $queryView = []; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType[] $entityTypeMapping |
44
|
|
|
*/ |
45
|
|
|
private $entityTypeMapping = []; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TMappingFragmentType[] $mappingFragment |
49
|
|
|
*/ |
50
|
|
|
private $mappingFragment = []; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty |
54
|
|
|
*/ |
55
|
|
|
private $complexProperty = null; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty |
59
|
|
|
*/ |
60
|
|
|
private $scalarProperty = null; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
64
|
|
|
*/ |
65
|
|
|
private $condition = null; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Gets as name |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getName() |
73
|
|
|
{ |
74
|
|
|
return $this->name; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Sets a new name |
79
|
|
|
* |
80
|
|
|
* @param string $name |
81
|
|
|
* @return self |
82
|
|
|
*/ |
83
|
|
|
public function setName($name) |
84
|
|
|
{ |
85
|
|
|
$this->name = $name; |
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Gets as typeName |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getTypeName() |
95
|
|
|
{ |
96
|
|
|
return $this->typeName; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Sets a new typeName |
101
|
|
|
* |
102
|
|
|
* @param string $typeName |
103
|
|
|
* @return self |
104
|
|
|
*/ |
105
|
|
|
public function setTypeName($typeName) |
106
|
|
|
{ |
107
|
|
|
$this->typeName = $typeName; |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Gets as storeEntitySet |
113
|
|
|
* |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getStoreEntitySet() |
117
|
|
|
{ |
118
|
|
|
return $this->storeEntitySet; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Sets a new storeEntitySet |
123
|
|
|
* |
124
|
|
|
* @param string $storeEntitySet |
125
|
|
|
* @return self |
126
|
|
|
*/ |
127
|
|
|
public function setStoreEntitySet($storeEntitySet) |
128
|
|
|
{ |
129
|
|
|
$this->storeEntitySet = $storeEntitySet; |
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Gets as makeColumnsDistinct |
135
|
|
|
* |
136
|
|
|
* @return boolean |
137
|
|
|
*/ |
138
|
|
|
public function getMakeColumnsDistinct() |
139
|
|
|
{ |
140
|
|
|
return $this->makeColumnsDistinct; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Sets a new makeColumnsDistinct |
145
|
|
|
* |
146
|
|
|
* @param boolean $makeColumnsDistinct |
147
|
|
|
* @return self |
148
|
|
|
*/ |
149
|
|
|
public function setMakeColumnsDistinct($makeColumnsDistinct) |
150
|
|
|
{ |
151
|
|
|
$this->makeColumnsDistinct = $makeColumnsDistinct; |
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Adds as queryView |
157
|
|
|
* |
158
|
|
|
* @return self |
159
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TQueryViewType $queryView |
160
|
|
|
*/ |
161
|
|
|
public function addToQueryView(TQueryViewType $queryView) |
162
|
|
|
{ |
163
|
|
|
$this->queryView[] = $queryView; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* isset queryView |
169
|
|
|
* |
170
|
|
|
* @param scalar $index |
171
|
|
|
* @return boolean |
172
|
|
|
*/ |
173
|
|
|
public function issetQueryView($index) |
174
|
|
|
{ |
175
|
|
|
return isset($this->queryView[$index]); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* unset queryView |
180
|
|
|
* |
181
|
|
|
* @param scalar $index |
182
|
|
|
* @return void |
183
|
|
|
*/ |
184
|
|
|
public function unsetQueryView($index) |
185
|
|
|
{ |
186
|
|
|
unset($this->queryView[$index]); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Gets as queryView |
191
|
|
|
* |
192
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TQueryViewType[] |
193
|
|
|
*/ |
194
|
|
|
public function getQueryView() |
195
|
|
|
{ |
196
|
|
|
return $this->queryView; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Sets a new queryView |
201
|
|
|
* |
202
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TQueryViewType[] $queryView |
203
|
|
|
* @return self |
204
|
|
|
*/ |
205
|
|
|
public function setQueryView(array $queryView) |
206
|
|
|
{ |
207
|
|
|
$this->queryView = $queryView; |
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Adds as entityTypeMapping |
213
|
|
|
* |
214
|
|
|
* @return self |
215
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType $entityTypeMapping |
216
|
|
|
*/ |
217
|
|
|
public function addToEntityTypeMapping(TEntityTypeMappingType $entityTypeMapping) |
218
|
|
|
{ |
219
|
|
|
$this->entityTypeMapping[] = $entityTypeMapping; |
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* isset entityTypeMapping |
225
|
|
|
* |
226
|
|
|
* @param scalar $index |
227
|
|
|
* @return boolean |
228
|
|
|
*/ |
229
|
|
|
public function issetEntityTypeMapping($index) |
230
|
|
|
{ |
231
|
|
|
return isset($this->entityTypeMapping[$index]); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* unset entityTypeMapping |
236
|
|
|
* |
237
|
|
|
* @param scalar $index |
238
|
|
|
* @return void |
239
|
|
|
*/ |
240
|
|
|
public function unsetEntityTypeMapping($index) |
241
|
|
|
{ |
242
|
|
|
unset($this->entityTypeMapping[$index]); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Gets as entityTypeMapping |
247
|
|
|
* |
248
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType[] |
249
|
|
|
*/ |
250
|
|
|
public function getEntityTypeMapping() |
251
|
|
|
{ |
252
|
|
|
return $this->entityTypeMapping; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Sets a new entityTypeMapping |
257
|
|
|
* |
258
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType[] $entityTypeMapping |
259
|
|
|
* @return self |
260
|
|
|
*/ |
261
|
|
|
public function setEntityTypeMapping(array $entityTypeMapping) |
262
|
|
|
{ |
263
|
|
|
$this->entityTypeMapping = $entityTypeMapping; |
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Adds as mappingFragment |
269
|
|
|
* |
270
|
|
|
* @return self |
271
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TMappingFragmentType $mappingFragment |
272
|
|
|
*/ |
273
|
|
|
public function addToMappingFragment(TMappingFragmentType $mappingFragment) |
274
|
|
|
{ |
275
|
|
|
$this->mappingFragment[] = $mappingFragment; |
276
|
|
|
return $this; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* isset mappingFragment |
281
|
|
|
* |
282
|
|
|
* @param scalar $index |
283
|
|
|
* @return boolean |
284
|
|
|
*/ |
285
|
|
|
public function issetMappingFragment($index) |
286
|
|
|
{ |
287
|
|
|
return isset($this->mappingFragment[$index]); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* unset mappingFragment |
292
|
|
|
* |
293
|
|
|
* @param scalar $index |
294
|
|
|
* @return void |
295
|
|
|
*/ |
296
|
|
|
public function unsetMappingFragment($index) |
297
|
|
|
{ |
298
|
|
|
unset($this->mappingFragment[$index]); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Gets as mappingFragment |
303
|
|
|
* |
304
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TMappingFragmentType[] |
305
|
|
|
*/ |
306
|
|
|
public function getMappingFragment() |
307
|
|
|
{ |
308
|
|
|
return $this->mappingFragment; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Sets a new mappingFragment |
313
|
|
|
* |
314
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TMappingFragmentType[] $mappingFragment |
315
|
|
|
* @return self |
316
|
|
|
*/ |
317
|
|
|
public function setMappingFragment(array $mappingFragment) |
318
|
|
|
{ |
319
|
|
|
$this->mappingFragment = $mappingFragment; |
320
|
|
|
return $this; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Gets as complexProperty |
325
|
|
|
* |
326
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType |
327
|
|
|
*/ |
328
|
|
|
public function getComplexProperty() |
329
|
|
|
{ |
330
|
|
|
return $this->complexProperty; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Sets a new complexProperty |
335
|
|
|
* |
336
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty |
337
|
|
|
* @return self |
338
|
|
|
*/ |
339
|
|
|
public function setComplexProperty(TComplexPropertyType $complexProperty) |
340
|
|
|
{ |
341
|
|
|
$this->complexProperty = $complexProperty; |
342
|
|
|
return $this; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* Gets as scalarProperty |
347
|
|
|
* |
348
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType |
349
|
|
|
*/ |
350
|
|
|
public function getScalarProperty() |
351
|
|
|
{ |
352
|
|
|
return $this->scalarProperty; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* Sets a new scalarProperty |
357
|
|
|
* |
358
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty |
359
|
|
|
* @return self |
360
|
|
|
*/ |
361
|
|
|
public function setScalarProperty(TScalarPropertyType $scalarProperty) |
362
|
|
|
{ |
363
|
|
|
$this->scalarProperty = $scalarProperty; |
364
|
|
|
return $this; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Gets as condition |
369
|
|
|
* |
370
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType |
371
|
|
|
*/ |
372
|
|
|
public function getCondition() |
373
|
|
|
{ |
374
|
|
|
return $this->condition; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* Sets a new condition |
379
|
|
|
* |
380
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
381
|
|
|
* @return self |
382
|
|
|
*/ |
383
|
|
|
public function setCondition(TConditionType $condition) |
384
|
|
|
{ |
385
|
|
|
$this->condition = $condition; |
386
|
|
|
return $this; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
public function isOK(&$msg = null) |
390
|
|
|
{ |
391
|
|
|
if (!$this->isStringNotNullOrEmpty($this->name)) { |
392
|
|
|
$msg = 'Name cannot be null or empty'; |
393
|
|
|
return false; |
394
|
|
|
} |
395
|
|
View Code Duplication |
if (null != $this->typeName && !$this->isStringNotNullOrEmpty($this->typeName)) { |
|
|
|
|
396
|
|
|
$msg = 'Type name cannot be empty'; |
397
|
|
|
return false; |
398
|
|
|
} |
399
|
|
View Code Duplication |
if (null != $this->storeEntitySet && !$this->isStringNotNullOrEmpty($this->storeEntitySet)) { |
|
|
|
|
400
|
|
|
$msg = 'Store entity set cannot be empty'; |
401
|
|
|
return false; |
402
|
|
|
} |
403
|
|
|
if (null != $this->complexProperty && !$this->complexProperty->isOK($msg)) { |
404
|
|
|
return false; |
405
|
|
|
} |
406
|
|
|
if (null != $this->condition && !$this->condition->isOK($msg)) { |
407
|
|
|
return false; |
408
|
|
|
} |
409
|
|
|
if (null != $this->scalarProperty && !$this->scalarProperty->isOK($msg)) { |
410
|
|
|
return false; |
411
|
|
|
} |
412
|
|
|
if (!$this->isValidArray( |
413
|
|
|
$this->entityTypeMapping, |
414
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType' |
415
|
|
|
)) { |
416
|
|
|
$msg = "Mapping fragment array not a valid array"; |
417
|
|
|
return false; |
418
|
|
|
} |
419
|
|
|
if (!$this->isChildArrayOK($this->entityTypeMapping, $msg)) { |
420
|
|
|
return false; |
421
|
|
|
} |
422
|
|
|
if (!$this->isValidArray( |
423
|
|
|
$this->queryView, |
424
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType' |
425
|
|
|
)) { |
426
|
|
|
$msg = "Query view array not a valid array"; |
427
|
|
|
return false; |
428
|
|
|
} |
429
|
|
|
if (!$this->isChildArrayOK($this->queryView, $msg)) { |
430
|
|
|
return false; |
431
|
|
|
} |
432
|
|
|
if (!$this->isValidArray( |
433
|
|
|
$this->mappingFragment, |
434
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntityTypeMappingType' |
435
|
|
|
)) { |
436
|
|
|
$msg = "Mapping fragment array not a valid array"; |
437
|
|
|
return false; |
438
|
|
|
} |
439
|
|
|
if (!$this->isChildArrayOK($this->mappingFragment, $msg)) { |
440
|
|
|
return false; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
return true; |
444
|
|
|
} |
445
|
|
|
} |
446
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.