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