Implant vid-app-common org.onap.vid.job (main and test)
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / aaiTree / Node.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.onap.vid.mso.model.CloudConfiguration;
24 import org.onap.vid.mso.model.ModelInfo;
25
26 import java.util.Objects;
27 import java.util.UUID;
28
29 public class Node extends AbstractNode {
30     private String instanceType;
31
32     private String provStatus;
33     private Boolean inMaint;
34
35     private String uuid;
36     private String originalName;
37
38     private String legacyRegion;
39     private String lineOfBusiness;
40     private String platformName;
41
42     private final String trackById;
43
44     public Node() {
45         trackById = UUID.randomUUID().toString();
46     }
47
48     public Node(AAITreeNode aaiNode) {
49         super();
50         this.instanceId = aaiNode.getId();
51         this.instanceName = aaiNode.getName();
52         this.orchStatus = aaiNode.getOrchestrationStatus();
53         this.provStatus = aaiNode.getProvStatus();
54         this.inMaint = aaiNode.getInMaint();
55         this.uuid = aaiNode.getModelVersionId();
56         this.originalName = aaiNode.getKeyInModel();
57         this.trackById = aaiNode.getUniqueNodeKey();
58
59         ModelInfo nodeModelInfo = new ModelInfo();
60         if (aaiNode.getType() != null) {
61             nodeModelInfo.setModelType(aaiNode.getType().getModelType());
62         }
63         nodeModelInfo.setModelName(aaiNode.getModelName());
64         nodeModelInfo.setModelVersion(aaiNode.getModelVersion());
65         nodeModelInfo.setModelVersionId(aaiNode.getModelVersionId());
66         nodeModelInfo.setModelInvariantId(aaiNode.getModelInvariantId());
67         nodeModelInfo.setModelCustomizationId(aaiNode.getModelCustomizationId());
68         nodeModelInfo.setModelCustomizationName(aaiNode.getModelCustomizationName());
69
70         this.modelInfo = nodeModelInfo;
71     }
72
73     public void setInstanceName(String instanceName) {
74         this.instanceName = instanceName;
75     }
76
77     public void setInstanceId(String instanceId) {
78         this.instanceId = instanceId;
79     }
80
81     public String getInstanceType() {
82         return instanceType;
83     }
84
85     public void setInstanceType(String instanceType) {
86         this.instanceType = instanceType;
87     }
88
89     public void setOrchStatus(String orchStatus) {
90         this.orchStatus = orchStatus;
91     }
92
93     public String getProvStatus() {
94         return provStatus;
95     }
96
97     public void setProvStatus(String provStatus) {
98         this.provStatus = provStatus;
99     }
100
101     public Boolean getInMaint() {
102         return inMaint;
103     }
104
105     public void setInMaint(Boolean inMaint) {
106         this.inMaint = inMaint;
107     }
108
109     public void setModelInfo(ModelInfo modelInfo) {
110         this.modelInfo = modelInfo;
111     }
112
113     public String getUuid() {
114         return uuid;
115     }
116
117     public void setUuid(String uuid) {
118         this.uuid = uuid;
119     }
120
121     public String getOriginalName() {
122         return originalName;
123     }
124
125     public void setOriginalName(String originalName) {
126         this.originalName = originalName;
127     }
128
129     public void setProductFamilyId(String productFamilyId) {
130         this.productFamilyId = productFamilyId;
131     }
132
133     public void setLcpCloudRegionId(String lcpCloudRegionId) {
134         this.lcpCloudRegionId = lcpCloudRegionId;
135     }
136
137     public String getLegacyRegion() {
138         return legacyRegion;
139     }
140
141     public void setLegacyRegion(String legacyRegion) {
142         this.legacyRegion = legacyRegion;
143     }
144
145     public void setTenantId(String tenantId) {
146         this.tenantId = tenantId;
147     }
148
149     public String getLineOfBusiness() {
150         return lineOfBusiness;
151     }
152
153     public void setLineOfBusiness(String lineOfBusiness) {
154         this.lineOfBusiness = lineOfBusiness;
155     }
156
157     public String getPlatformName() {
158         return platformName;
159     }
160
161     public void setPlatformName(String platformName) {
162         this.platformName = platformName;
163     }
164
165     public String getTrackById() {
166         return trackById;
167     }
168
169     public static void fillCloudConfigurationProperties(AbstractNode that, CloudConfiguration cloudConfiguration) {
170         if (cloudConfiguration !=null) {
171             that.lcpCloudRegionId = cloudConfiguration.getLcpCloudRegionId();
172             that.tenantId = cloudConfiguration.getTenantId();
173             that.cloudOwner = cloudConfiguration.getCloudOwner();
174         }
175     }
176
177     public static String readValueAsStringFromAdditionalProperties(AAITreeNode node, String key) {
178         return Objects.toString(node.getAdditionalProperties().get(key), null);
179     }
180 }