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