3048c119a192d8a2c829bed6ebef1ef9899915c5
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / domain / model / AAIResource.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.domain.model;
21
22 import com.google.common.collect.Multimap;
23
24 import java.util.ArrayList;
25 import java.util.Map;
26
27
28 public class AAIResource {
29         private AAIResource parent;
30         private AAIResources children;
31                 
32         private AAIResourceKeys aaiResourceKeys;
33         
34         private String namespace; // /Network/Vces/Vce/PortGroups/PortGroup/CvlanTags/CvlanTag -> "Network"
35
36         private String resourceType; // node or container
37         private String resourceClassName;
38         private String simpleName; // Vce
39         private String fullName; // /Network/Vces/Vce/PortGroups/PortGroup/CvlanTags/CvlanTag
40         private String uri; // /network/vces/vce/{vnf-id}/port-groups/port-group/{interface-name}/cvlan-tags/cvlan-tag/{cvlan-tag}
41         private String apiVersion;
42         private String relationshipListClass;
43         private String relationshipUtils;
44         
45         private Map<String, String>      PropertyDataTypeMap; 
46         private Multimap<String, String> NodeMapIndexedProps;
47         private Multimap<String, String> NodeAltKey1Props;
48         private Multimap<String, String> NodeDependencies;
49         private Multimap<String, String> NodeKeyProps;
50         private Multimap<String, String> NodeReqProps;
51         private Multimap<String, String> NodeNameProps;
52         private Multimap<String, String> NodeUniqueProps;
53         
54         // if new dataTypes are added - make sure to update getAllFields() method below
55         private ArrayList<String> stringFields;
56         private ArrayList<String> stringListFields;
57         private ArrayList<String> longFields;
58         private ArrayList<String> intFields;
59         private ArrayList<String> shortFields;
60         private ArrayList<String> booleanFields;
61                 
62         private ArrayList<String> requiredFields;
63         private ArrayList<String> orderedFields;
64         private AAIResource recurseToResource;
65         private boolean allowDirectWrite;
66         private boolean allowDirectRead;
67         private ArrayList<String> autoGenUuidFields;
68         
69         /**
70          * Gets the parent.
71          *
72          * @return the parent
73          */
74         public AAIResource getParent() {
75                 return parent;
76         }
77         
78         /**
79          * Sets the parent.
80          *
81          * @param parent the new parent
82          */
83         public void setParent(AAIResource parent) {
84                 this.parent = parent;
85         }
86         
87         /**
88          * Gets the children.
89          *
90          * @return the children
91          */
92         public AAIResources getChildren() { 
93                 if (this.children == null) { 
94                         this.children = new AAIResources();
95                 }
96                 return this.children;
97         }
98         
99         /**
100          * Gets the aai resource keys.
101          *
102          * @return the aai resource keys
103          */
104         public AAIResourceKeys getAaiResourceKeys() {
105                 if (aaiResourceKeys == null) {
106                         aaiResourceKeys = new AAIResourceKeys();
107                 }
108                 return aaiResourceKeys;
109         }
110         
111         /**
112          * Gets the namespace.
113          *
114          * @return the namespace
115          */
116         public String getNamespace() {
117                 return namespace;
118         }
119         
120         /**
121          * Sets the namespace.
122          *
123          * @param namespace the new namespace
124          */
125         public void setNamespace(String namespace) {
126                 this.namespace = namespace;
127         }
128         
129         /**
130          * Gets the resource type.
131          *
132          * @return the resource type
133          */
134         public String getResourceType() {
135                 return resourceType;
136         }
137         
138         /**
139          * Sets the resource type.
140          *
141          * @param resourceType the new resource type
142          */
143         public void setResourceType(String resourceType) {
144                 this.resourceType = resourceType;
145         }
146         
147         /**
148          * Gets the simple name.
149          *
150          * @return the simple name
151          */
152         public String getSimpleName() {
153                 return simpleName;
154         }
155         
156         /**
157          * Sets the simple name.
158          *
159          * @param simpleName the new simple name
160          */
161         public void setSimpleName(String simpleName) {
162                 this.simpleName = simpleName;
163         }
164         
165         /**
166          * Gets the full name.
167          *
168          * @return the full name
169          */
170         public String getFullName() {
171                 return fullName;
172         }
173         
174         /**
175          * Sets the full name.
176          *
177          * @param fullName the new full name
178          */
179         public void setFullName(String fullName) {
180                 this.fullName = fullName;
181         }
182         
183         /**
184          * Gets the uri.
185          *
186          * @return the uri
187          */
188         public String getUri() {
189                 return uri;
190         }
191         
192         /**
193          * Sets the uri.
194          *
195          * @param uri the new uri
196          */
197         public void setUri(String uri) {
198                 this.uri = uri;
199         }
200         
201         /**
202          * Gets the resource class name.
203          *
204          * @return the resource class name
205          */
206         public String getResourceClassName() {
207                 return resourceClassName;
208         }
209         
210         /**
211          * Sets the resource class name.
212          *
213          * @param resourceClassName the new resource class name
214          */
215         public void setResourceClassName(String resourceClassName) {
216                 this.resourceClassName = resourceClassName;
217         }
218
219         /**
220          * Gets the property data type map.
221          *
222          * @return the property data type map
223          */
224         public Map<String, String> getPropertyDataTypeMap() {
225                 return PropertyDataTypeMap;
226         }
227         
228         /**
229          * Sets the property data type map.
230          *
231          * @param propertyDataTypeMap the property data type map
232          */
233         public void setPropertyDataTypeMap(Map<String, String> propertyDataTypeMap) {
234                 PropertyDataTypeMap = propertyDataTypeMap;
235         }
236         
237         /**
238          * Gets the node map indexed props.
239          *
240          * @return the node map indexed props
241          */
242         public Multimap<String, String> getNodeMapIndexedProps() {
243                 return NodeMapIndexedProps;
244         }
245         
246         /**
247          * Sets the node map indexed props.
248          *
249          * @param nodeMapIndexedProps the node map indexed props
250          */
251         public void setNodeMapIndexedProps(Multimap<String, String> nodeMapIndexedProps) {
252                 NodeMapIndexedProps = nodeMapIndexedProps;
253         }
254         
255         /**
256          * Gets the node key props.
257          *
258          * @return the node key props
259          */
260         public Multimap<String, String> getNodeKeyProps() {     
261                 return NodeKeyProps;
262         }
263         
264         /**
265          * Sets the node key props.
266          *
267          * @param nodeKeyProps the node key props
268          */
269         public void setNodeKeyProps(Multimap<String, String> nodeKeyProps) {
270                 this.NodeKeyProps = nodeKeyProps;
271         }
272         
273         /**
274          * Gets the node name props.
275          *
276          * @return the node name props
277          */
278         public Multimap<String, String> getNodeNameProps() {
279                 return NodeNameProps;
280         }
281         
282         /**
283          * Sets the node name props.
284          *
285          * @param nodeNameProps the node name props
286          */
287         public void setNodeNameProps(Multimap<String, String> nodeNameProps) {
288         
289                 NodeNameProps = nodeNameProps;
290         }
291         
292         /**
293          * Gets the node unique props.
294          *
295          * @return the node unique props
296          */
297         public Multimap<String, String> getNodeUniqueProps() {
298                 return NodeUniqueProps;
299         }
300         
301         /**
302          * Sets the node unique props.
303          *
304          * @param nodeUniqueProps the node unique props
305          */
306         public void setNodeUniqueProps(Multimap<String, String> nodeUniqueProps) {
307                 NodeUniqueProps = nodeUniqueProps;
308         }
309         
310         /**
311          * Gets the node req props.
312          *
313          * @return the node req props
314          */
315         public Multimap<String, String> getNodeReqProps() {
316                 return NodeReqProps;
317         }
318         
319         /**
320          * Sets the node req props.
321          *
322          * @param nodeReqProps the node req props
323          */
324         public void setNodeReqProps(Multimap<String, String> nodeReqProps) {
325                 NodeReqProps = nodeReqProps;
326         }
327         
328         /**
329          * Gets the api version.
330          *
331          * @return the api version
332          */
333         public String getApiVersion() {
334                 return apiVersion;
335         }
336         
337         /**
338          * Sets the api version.
339          *
340          * @param apiVersion the new api version
341          */
342         public void setApiVersion(String apiVersion) {
343                 this.apiVersion = apiVersion;
344         }
345         
346         /**
347          * Gets the relationship list class.
348          *
349          * @return the relationship list class
350          */
351         public String getRelationshipListClass() {
352                 return relationshipListClass;
353         }
354         
355         /**
356          * Sets the relationship list class.
357          *
358          * @param relationshipListClass the new relationship list class
359          */
360         public void setRelationshipListClass(String relationshipListClass) {
361                 this.relationshipListClass = relationshipListClass;
362         }
363         
364         /**
365          * Gets the relationship utils.
366          *
367          * @return the relationship utils
368          */
369         public String getRelationshipUtils() {
370                 return relationshipUtils;
371         }
372         
373         /**
374          * Sets the relationship utils.
375          *
376          * @param relationshipUtils the new relationship utils
377          */
378         public void setRelationshipUtils(String relationshipUtils) {
379                 this.relationshipUtils = relationshipUtils;
380         }
381         
382         /**
383          * Gets the string fields.
384          *
385          * @return the string fields
386          */
387         public ArrayList<String> getStringFields() {
388                 if (this.stringFields == null) {
389                         this.stringFields = new ArrayList<String>();
390                 }
391                 return this.stringFields;
392         }
393         
394         /**
395          * Sets the string fields.
396          *
397          * @param stringFields the new string fields
398          */
399         public void setStringFields(ArrayList<String> stringFields) {
400                 this.stringFields = stringFields;
401         }
402         
403         /**
404          * Gets the string list fields.
405          *
406          * @return the string list fields
407          */
408         public ArrayList<String> getStringListFields() {
409                 if (this.stringListFields == null) {
410                         this.stringListFields = new ArrayList<String>();
411                 }
412                 return this.stringListFields;
413         }
414         
415         /**
416          * Sets the string list fields.
417          *
418          * @param stringListFields the new string list fields
419          */
420         public void setStringListFields(ArrayList<String> stringListFields) {
421                 this.stringListFields = stringListFields;
422         }
423         
424         /**
425          * Gets the long fields.
426          *
427          * @return the long fields
428          */
429         public ArrayList<String> getLongFields() {
430                 if (this.longFields == null) {
431                         this.longFields = new ArrayList<String>();
432                 }
433                 return longFields;
434         }
435         
436         /**
437          * Sets the long fields.
438          *
439          * @param longFields the new long fields
440          */
441         public void setLongFields(ArrayList<String> longFields) {
442                 this.longFields = longFields;
443         }
444         
445         /**
446          * Gets the int fields.
447          *
448          * @return the int fields
449          */
450         public ArrayList<String> getIntFields() {
451                 if (this.intFields == null) {
452                         this.intFields = new ArrayList<String>();
453                 }
454                 return intFields;
455         }
456         
457         /**
458          * Sets the int fields.
459          *
460          * @param intFields the new int fields
461          */
462         public void setIntFields(ArrayList<String> intFields) {
463                 this.intFields = intFields;
464         }
465         
466         /**
467          * Gets the short fields.
468          *
469          * @return the short fields
470          */
471         public ArrayList<String> getShortFields() {
472                 if (this.shortFields == null) {
473                         this.shortFields = new ArrayList<String>();
474                 }
475                 return shortFields;
476         }
477         
478         /**
479          * Sets the short fields.
480          *
481          * @param shortFields the new short fields
482          */
483         public void setShortFields(ArrayList<String> shortFields) {
484                 this.shortFields = shortFields;
485         }
486         
487         /**
488          * Gets the boolean fields.
489          *
490          * @return the boolean fields
491          */
492         public ArrayList<String> getBooleanFields() {
493                 if (this.booleanFields == null) {
494                         this.booleanFields = new ArrayList<String>();
495                 }
496                 return booleanFields;
497         }
498         
499         /**
500          * Sets the boolean fields.
501          *
502          * @param booleanFields the new boolean fields
503          */
504         public void setBooleanFields(ArrayList<String> booleanFields) {
505                 this.booleanFields = booleanFields;
506         }
507         
508         /**
509          * Gets the required fields.
510          *
511          * @return the required fields
512          */
513         public ArrayList<String> getRequiredFields() {
514                 if (this.requiredFields == null) {
515                         this.requiredFields = new ArrayList<String>();
516                 }
517                 return requiredFields;
518         }
519         
520         /**
521          * Sets the required fields.
522          *
523          * @param requiredFields the new required fields
524          */
525         public void setRequiredFields(ArrayList<String> requiredFields) {
526                 this.requiredFields = requiredFields;
527         }
528         
529         /**
530          * Gets the ordered fields.
531          *
532          * @return the ordered fields
533          */
534         public ArrayList<String> getOrderedFields() {
535                 if (this.orderedFields == null) { 
536                         this.orderedFields = new ArrayList<String>();
537                 }
538                 return this.orderedFields;
539         }
540         
541         /**
542          * Gets the all fields.
543          *
544          * @return the all fields
545          */
546         public ArrayList<String>  getAllFields() {
547                 
548                 ArrayList<String> allFields = new ArrayList<String>();
549                 allFields.addAll(getBooleanFields());
550                 allFields.addAll(getStringListFields());
551                 allFields.addAll(getStringFields());
552                 allFields.addAll(getIntFields());
553                 allFields.addAll(getLongFields());
554                 allFields.addAll(getShortFields());
555                 
556                 return allFields;
557         }
558                 
559         /**
560          * Gets the plural name.
561          *
562          * @return the plural name
563          */
564         public String  getPluralName() {        
565                 
566                 if (simpleName.contains("List")  || simpleName.contains("-list") )
567                         return "";
568                 String[] fullNameList = getFullName().split("/");               
569                 return fullNameList[fullNameList.length - 2];
570         }
571         
572         /**
573          * Sets the node alt key 1 props.
574          *
575          * @param _dbRulesNodeAltKey1Props the db rules node alt key 1 props
576          */
577         public void setNodeAltKey1Props(Multimap<String, String> _dbRulesNodeAltKey1Props) {
578                 this.NodeAltKey1Props = _dbRulesNodeAltKey1Props;
579         }
580         
581         /**
582          * Gets the node alt key 1 props.
583          *
584          * @return the node alt key 1 props
585          */
586         public Multimap<String,String> getNodeAltKey1Props() {
587                 return this.NodeAltKey1Props;
588         }
589         
590         /**
591          * Sets the node dependencies.
592          *
593          * @param _dbRulesNodeDependencies the db rules node dependencies
594          */
595         public void setNodeDependencies(Multimap<String, String> _dbRulesNodeDependencies) {
596                 this.NodeDependencies = _dbRulesNodeDependencies;
597         }
598         
599         /**
600          * Gets the node dependencies.
601          *
602          * @return the node dependencies
603          */
604         public Multimap<String,String> getNodeDependencies() {
605                 return this.NodeDependencies;
606         }
607         
608         /**
609          * Gets the recurse to resource.
610          *
611          * @return the recurse to resource
612          */
613         public AAIResource getRecurseToResource() { 
614                 return this.recurseToResource;
615         }
616         
617         /**
618          * Sets the recurse to resource.
619          *
620          * @param ancestor the new recurse to resource
621          */
622         public void setRecurseToResource(AAIResource ancestor) {
623                 this.recurseToResource = ancestor;
624                 
625         }
626         
627         /**
628          * Sets the allow direct write.
629          *
630          * @param allowDirectWrite the new allow direct write
631          */
632         public void setAllowDirectWrite(boolean allowDirectWrite) {
633                 this.allowDirectWrite = allowDirectWrite;
634         }
635         
636         /**
637          * Checks if is allow direct write.
638          *
639          * @return true, if is allow direct write
640          */
641         public boolean isAllowDirectWrite() {
642                 return this.allowDirectWrite;
643         }
644         
645         /**
646          * Sets the allow direct read.
647          *
648          * @param allowDirectRead the new allow direct read
649          */
650         public void setAllowDirectRead(boolean allowDirectRead) {
651                 this.allowDirectRead = allowDirectRead;
652         }
653         
654         /**
655          * Checks if is allow direct read.
656          *
657          * @return true, if is allow direct read
658          */
659         public boolean isAllowDirectRead() {
660                 return this.allowDirectRead;
661         }
662         
663         /**
664          * Gets the auto gen uuid fields.
665          *
666          * @return the auto gen uuid fields
667          */
668         public ArrayList<String> getAutoGenUuidFields() {
669                 if (this.autoGenUuidFields == null) { 
670                         this.autoGenUuidFields = new ArrayList<String>();
671                 }
672                 return this.autoGenUuidFields;
673         }
674 }