Containerization feature of SO
[so.git] / bpmn / MSOCoreBPMN / src / main / java / org / onap / so / bpmn / core / domain / VnfResource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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.so.bpmn.core.domain;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.UUID;
26
27 import com.fasterxml.jackson.annotation.JsonIgnore;
28 import com.fasterxml.jackson.annotation.JsonProperty;
29 import com.fasterxml.jackson.annotation.JsonRootName;
30
31 /**
32  * Encapsulates VNF resource data set
33  *
34  */
35 @JsonRootName("vnfResource")
36 public class VnfResource extends Resource {
37
38         private static final long serialVersionUID = 1L;
39
40         /*
41          * set resourceType for this object
42          */
43         public VnfResource(){
44                 resourceType = ResourceType.VNF;
45                 setResourceId(UUID.randomUUID().toString());
46         }
47
48         /*
49          * fields specific to VNF resource type
50          */
51         @JsonProperty("vfModules")
52         private List <ModuleResource>  vfModules;
53         private String vnfHostname;
54         private String vnfType;
55         private String nfFunction;
56         private String nfType;
57         private String nfRole;
58         private String nfNamingCode;
59         private String multiStageDesign;
60         private String orchestrationStatus;
61
62         /*
63          * GET and SET
64          */
65         public List<ModuleResource> getVfModules() {
66                 return vfModules;
67         }
68         public void setModules(List<ModuleResource> moduleResources) {
69                 this.vfModules = moduleResources;
70         }
71         public String getVnfHostname() {
72                 return vnfHostname;
73         }
74         public void setVnfHostname(String vnfHostname) {
75                 this.vnfHostname = vnfHostname;
76         }
77         @Deprecated
78         public void setVnfType(String vnfType) {
79                 this.vnfType = vnfType;
80         }
81         public String getVnfType() {
82                 return vnfType;
83         }
84         public String getNfFunction() {
85                 return nfFunction;
86         }
87         public void setNfFunction(String nfFunction) {
88                 this.nfFunction = nfFunction;
89         }
90         public String getNfType() {
91                 return nfType;
92         }
93         public void setNfType(String nfType) {
94                 this.nfType = nfType;
95         }
96         public String getNfRole() {
97                 return nfRole;
98         }
99         public void setNfRole(String nfRole) {
100                 this.nfRole = nfRole;
101         }
102         public String getNfNamingCode() {
103                 return nfNamingCode;
104         }
105         public void setNfNamingCode(String nfNamingCode) {
106                 this.nfNamingCode = nfNamingCode;
107         }
108         public String getMultiStageDesign() {
109                 return multiStageDesign;
110         }
111         public void setMultiStageDesign(String multiStageDesign) {
112                 this.multiStageDesign = multiStageDesign;
113         }
114         /*
115          * GET accessors per design requirements
116          */
117
118
119         public String getOrchestrationStatus(){
120                 return orchestrationStatus;
121         }
122
123         public void setOrchestrationStatus(String orchestrationStatus){
124                 this.orchestrationStatus = orchestrationStatus;
125         }
126         /**
127          * Returns a list of all VfModule objects.
128          * Base module is first entry in the list
129          * @return ordered list of ModuleResources objects
130          */
131         @JsonIgnore
132         public List<ModuleResource> getAllVfModuleObjects(){
133                 if (vfModules == null) {
134                         return null;
135                 }
136
137                 for (int i = 0; i < vfModules.size(); i++) {
138                         ModuleResource moduleResource = vfModules.get(i);
139                         if (moduleResource.getIsBase()){
140                                 vfModules.remove(moduleResource);
141                                 vfModules.add(0,moduleResource);
142                         }
143                 }
144                 return vfModules;
145         }
146
147         /**
148          *
149          * @return Returns JSON list of all VfModule structures.
150          */
151         @JsonIgnore
152         public String getAllVfModulesJson(){
153
154                 return listToJson(vfModules);
155         }
156
157         // methods to add to the list
158         public void addVfModule(ModuleResource moduleResource) {
159                 if (vfModules == null){
160                         vfModules = new ArrayList<>();
161                 }
162                 this.vfModules.add(moduleResource);
163         }
164
165
166         /**
167          * Utility method to allow construction of the filed in the form of
168          * <serviceResources.modelInfo.modelName>/<serviceVnfs.modelInfo.modelInstanceName>
169          *
170          * default setter for this field deprecated
171          * @param modelName << serviceResources.modelInfo.modelName
172          */
173         public void constructVnfType(String modelName) {
174                 this.vnfType = modelName.concat("/").concat(this.modelInfo.getModelInstanceName());
175         }
176 }