Move this constructor to comply with Java Code Conventions
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / aaiTree / RelatedVnf.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 IBM.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.vid.model.aaiTree;
23
24 import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
25
26 import org.apache.commons.lang3.builder.ToStringBuilder;
27
28 public class RelatedVnf extends Node {
29
30     private String serviceInstanceId;
31     private String serviceInstanceName;
32     private String tenantName;
33
34     public RelatedVnf(AAITreeNode node) {
35         super(node);
36     }
37     
38     public String getServiceInstanceId() {
39         return serviceInstanceId;
40     }
41
42     public void setServiceInstanceId(String serviceInstanceId) {
43         this.serviceInstanceId = serviceInstanceId;
44     }
45
46     public String getServiceInstanceName() {
47         return serviceInstanceName;
48     }
49
50     public void setServiceInstanceName(String serviceInstanceName) {
51         this.serviceInstanceName = serviceInstanceName;
52     }
53
54     public String getTenantName() {
55         return tenantName;
56     }
57
58     public void setTenantName(String tenantName) {
59         this.tenantName = tenantName;
60     }
61
62     public static RelatedVnf from(AAITreeNode node) {
63         RelatedVnf vnf = new RelatedVnf(node);
64         if (node.getParent() != null && node.getParent().getType() == NodeType.SERVICE_INSTANCE) {
65             vnf.setServiceInstanceId(node.getParent().getId());
66             vnf.setServiceInstanceName(node.getParent().getName());
67         }
68
69         if (node.getAdditionalProperties().get(VNF_TYPE) != null) {
70             vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString());
71         }
72
73         return vnf;
74     }
75
76     @Override
77     public String toString() {
78         return new ToStringBuilder(this)
79             .append("serviceInstanceId", serviceInstanceId)
80             .append("serviceInstanceName", serviceInstanceName)
81             .append("tenantName", tenantName)
82             .append("action", action)
83             .append("instanceName", instanceName)
84             .append("instanceId", instanceId)
85             .append("orchStatus", orchStatus)
86             .append("productFamilyId", productFamilyId)
87             .append("lcpCloudRegionId", lcpCloudRegionId)
88             .append("tenantId", tenantId)
89             .append("cloudOwner", cloudOwner)
90             .append("modelInfo", modelInfo)
91             .toString();
92     }
93 }