4b16b3122cc5b452c588510cc1078cd7de23d606
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / aaiTree / AAITreeNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.vid.model.aaiTree;
22
23 import org.apache.commons.lang3.StringUtils;
24
25 import java.util.*;
26
27 public class AAITreeNode {
28
29     private String type;
30     private int uniqueNumber;
31     private String orchestrationStatus;
32     private String provStatus;
33     private Boolean inMaint = null;
34     private String modelVersionId;
35     private String modelCustomizationId;
36     private String modelInvariantId;
37     private String id;
38     private String name;
39     private String modelVersion;
40     private String modelName;
41     private String modelCustomizationName;
42     private final List<AAITreeNode> children = Collections.synchronizedList(new LinkedList<>());
43     private Map<String, Object> additionalProperties = new HashMap<>();
44     private String keyInModel;
45     private AAITreeNode parent;
46
47     public String getType() {
48         return type;
49     }
50
51     public void setType(String type) {
52         this.type = type;
53     }
54
55     public int getUniqueNumber() {
56         return uniqueNumber;
57     }
58
59     public void setUniqueNumber(int uniqueNumber) {
60         this.uniqueNumber = uniqueNumber;
61     }
62     
63     public String getOrchestrationStatus() {
64         return orchestrationStatus;
65     }
66
67     public void setOrchestrationStatus(String orchestrationStatus) {
68         this.orchestrationStatus = orchestrationStatus;
69     }
70
71     public String getProvStatus() {
72         return provStatus;
73     }
74
75     public void setProvStatus(String provStatus) {
76         this.provStatus = provStatus;
77     }
78
79     public Boolean getInMaint() {
80         return inMaint;
81     }
82
83     public void setInMaint(Boolean inMaint) {
84         this.inMaint = inMaint;
85     }
86
87     public String getModelVersionId() {
88         return modelVersionId;
89     }
90
91     public void setModelVersionId(String modelVersionId) {
92         this.modelVersionId = modelVersionId;
93     }
94
95     public String getModelCustomizationId() {
96         return modelCustomizationId;
97     }
98
99     public void setModelCustomizationId(String modelCustomizationId) {
100         this.modelCustomizationId = modelCustomizationId;
101     }
102
103     public String getModelInvariantId() {
104         return modelInvariantId;
105     }
106
107     public void setModelInvariantId(String modelInvariantId) {
108         this.modelInvariantId = modelInvariantId;
109     }
110
111     public String getId() {
112         return id;
113     }
114
115     public void setId(String id) {
116         this.id = id;
117     }
118
119     public String getName() {
120         return name;
121     }
122
123     public void setName(String name) {
124         this.name = name;
125     }
126
127     public String getModelVersion() {
128         return modelVersion;
129     }
130
131     public void setModelVersion(String modelVersion) {
132         this.modelVersion = modelVersion;
133     }
134
135     public String getModelName() {
136         return modelName;
137     }
138
139     public void setModelName(String modelName) {
140         this.modelName = modelName;
141     }
142
143     public String getModelCustomizationName() {
144         return modelCustomizationName;
145     }
146
147     public void setModelCustomizationName(String modelCustomizationName) {
148         this.modelCustomizationName = modelCustomizationName;
149     }
150
151     public List<AAITreeNode> getChildren() {
152         return children;
153     }
154
155     public Map<String, Object> getAdditionalProperties() {
156         return additionalProperties;
157     }
158
159     public void setAdditionalProperties(Map<String, Object> additionalProperties) {
160         this.additionalProperties = additionalProperties;
161     }
162
163     public String getNodeKey() {
164         if (this.keyInModel != null) {
165             return this.keyInModel;
166         }
167
168         return StringUtils.defaultIfEmpty(this.modelVersionId, "not provided");
169     }
170
171     public String getUniqueNodeKey() {
172         return getNodeKey() + ":" + String.format("%03d", this.uniqueNumber);
173     }
174
175     public void setKeyInModel(String keyInModel) {
176         this.keyInModel = keyInModel;
177     }
178
179     public String getKeyInModel() {
180         return keyInModel;
181     }
182
183     public AAITreeNode getParent() {
184         return parent;
185     }
186
187     public void setParent(AAITreeNode parent) {
188         this.parent = parent;
189     }
190
191     public void addChildren(List<AAITreeNode> children) {
192         for (AAITreeNode child : children) {
193             child.setParent(this);
194         }
195
196         this.getChildren().addAll(children);
197     }
198 }