Merge "Reorder modifiers"
[so.git] / bpmn / MSOCoreBPMN / src / main / java / org / openecomp / mso / bpmn / core / domain / VnfResource.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.mso.bpmn.core.domain;\r
22 \r
23 import java.util.ArrayList;\r
24 import java.util.List;\r
25 import java.util.UUID;\r
26 \r
27 import com.fasterxml.jackson.annotation.JsonIgnore;\r
28 import com.fasterxml.jackson.annotation.JsonProperty;\r
29 import com.fasterxml.jackson.annotation.JsonRootName;\r
30 \r
31 /**\r
32  * Encapsulates VNF resource data set\r
33  *\r
34  */\r
35 @JsonRootName("vnfResource")\r
36 public class VnfResource extends Resource {\r
37 \r
38         private static final long serialVersionUID = 1L;\r
39 \r
40         /*\r
41          * set resourceType for this object\r
42          */\r
43         public VnfResource(){\r
44                 resourceType = ResourceType.VNF;\r
45                 setResourceId(UUID.randomUUID().toString());\r
46         }\r
47 \r
48         /*\r
49          * fields specific to VNF resource type\r
50          */\r
51         @JsonProperty("vfModules")\r
52         private List <ModuleResource>  vfModules;\r
53         private String vnfHostname;\r
54         private String vnfType;\r
55         private String nfFunction;\r
56         private String nfType;\r
57         private String nfRole;\r
58         private String nfNamingCode;\r
59         private String multiStageDesign;\r
60 \r
61         /*\r
62          * GET and SET\r
63          */\r
64         public List<ModuleResource> getVfModules() {\r
65                 return vfModules;\r
66         }\r
67         public void setModules(List<ModuleResource> moduleResources) {\r
68                 this.vfModules = moduleResources;\r
69         }\r
70         public String getVnfHostname() {\r
71                 return vnfHostname;\r
72         }\r
73         public void setVnfHostname(String vnfHostname) {\r
74                 this.vnfHostname = vnfHostname;\r
75         }\r
76         @Deprecated\r
77         public void setVnfType(String vnfType) {\r
78                 this.vnfType = vnfType;\r
79         }\r
80         public String getVnfType() {\r
81                 return vnfType;\r
82         }\r
83         public String getNfFunction() {\r
84                 return nfFunction;\r
85         }\r
86         public void setNfFunction(String nfFunction) {\r
87                 this.nfFunction = nfFunction;\r
88         }\r
89         public String getNfType() {\r
90                 return nfType;\r
91         }\r
92         public void setNfType(String nfType) {\r
93                 this.nfType = nfType;\r
94         }\r
95         public String getNfRole() {\r
96                 return nfRole;\r
97         }\r
98         public void setNfRole(String nfRole) {\r
99                 this.nfRole = nfRole;\r
100         }\r
101         public String getNfNamingCode() {\r
102                 return nfNamingCode;\r
103         }\r
104         public void setNfNamingCode(String nfNamingCode) {\r
105                 this.nfNamingCode = nfNamingCode;\r
106         }\r
107         public String getMultiStageDesign() {\r
108                 return multiStageDesign;\r
109         }\r
110         public void setMultiStageDesign(String multiStageDesign) {\r
111                 this.multiStageDesign = multiStageDesign;\r
112         }\r
113         /*\r
114          * GET accessors per design requirements\r
115          */\r
116 \r
117         /**\r
118          * Returns a list of all VfModule objects.\r
119          * Base module is first entry in the list\r
120          * @return ordered list of ModuleResources objects\r
121          */\r
122         @JsonIgnore\r
123         public List<ModuleResource> getAllVfModuleObjects(){\r
124                 if (vfModules == null) {\r
125                         return null;\r
126                 }\r
127 \r
128                 for (int i = 0; i < vfModules.size(); i++) {\r
129                         ModuleResource moduleResource = vfModules.get(i);\r
130                         if (moduleResource.getIsBase()){\r
131                                 vfModules.remove(moduleResource);\r
132                                 vfModules.add(0,moduleResource);\r
133                         }\r
134                 }\r
135                 return vfModules;\r
136         }\r
137 \r
138         /**\r
139          *\r
140          * @return Returns JSON list of all VfModule structures.\r
141          */\r
142         @JsonIgnore\r
143         public String getAllVfModulesJson(){\r
144 \r
145                 return listToJson(vfModules);\r
146         }\r
147 \r
148         // methods to add to the list\r
149         public void addVfModule(ModuleResource moduleResource) {\r
150                 if (vfModules == null){\r
151                         vfModules = new ArrayList<>();\r
152                 }\r
153                 this.vfModules.add(moduleResource);\r
154         }\r
155 \r
156 \r
157         /**\r
158          * Utility method to allow construction of the filed in the form of\r
159          * <serviceResources.modelInfo.modelName>/<serviceVnfs.modelInfo.modelInstanceName>\r
160          *\r
161          * default setter for this field deprecated\r
162          * @param modelName << serviceResources.modelInfo.modelName\r
163          */\r
164         public void constructVnfType(String modelName) {\r
165                 this.vnfType = modelName.concat("/").concat(this.modelInfo.getModelInstanceName());\r
166         }\r
167 }