Merge "Add SO Update to default the controller type query as "APPC" instead of null."
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VnfResourceCustomization.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.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.Date;
26 import java.util.List;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.OneToMany;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44 import com.fasterxml.jackson.annotation.JsonFormat;
45 import com.openpojo.business.annotation.BusinessKey;
46 import uk.co.blackpepper.bowman.annotation.LinkedResource;
47
48 @Entity
49 @Table(name = "vnf_resource_customization")
50 public class VnfResourceCustomization implements Serializable {
51
52     private static final long serialVersionUID = 768026109321305392L;
53
54     @Id
55     @BusinessKey
56     @Column(name = "ID")
57     @GeneratedValue(strategy = GenerationType.IDENTITY)
58     private Integer id;
59
60     @Column(name = "MODEL_CUSTOMIZATION_UUID")
61     private String modelCustomizationUUID;
62
63     @Column(name = "MODEL_INSTANCE_NAME")
64     private String modelInstanceName;
65
66     @Column(name = "CREATION_TIMESTAMP", updatable = false)
67     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
68     @Temporal(TemporalType.TIMESTAMP)
69     private Date created;
70
71     @Column(name = "MIN_INSTANCES")
72     private Integer minInstances;
73
74     @Column(name = "MAX_INSTANCES")
75     private Integer maxInstances;
76
77     @Column(name = "AVAILABILITY_ZONE_MAX_COUNT")
78     private Integer availabilityZoneMaxCount;
79
80     @Column(name = "NF_FUNCTION")
81     private String nfFunction;
82
83     @Column(name = "NF_TYPE")
84     private String nfType;
85
86     @Column(name = "NF_ROLE")
87     private String nfRole;
88
89     @Column(name = "NF_NAMING_CODE")
90     private String nfNamingCode;
91
92     @Column(name = "MULTI_STAGE_DESIGN")
93     private String multiStageDesign;
94
95     @Column(name = "RESOURCE_INPUT")
96     private String resourceInput;
97
98     @ManyToOne(cascade = CascadeType.ALL)
99     @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID")
100     private VnfResource vnfResources;
101
102     @ManyToOne(cascade = CascadeType.ALL)
103     @JoinColumn(name = "SERVICE_MODEL_UUID")
104     private Service service;
105
106     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "vnfCustomization")
107     private List<VfModuleCustomization> vfModuleCustomizations;
108
109     @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResourceCust")
110     private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
111
112     @Column(name = "CDS_BLUEPRINT_NAME")
113     private String blueprintName;
114
115     @Column(name = "CDS_BLUEPRINT_VERSION")
116     private String blueprintVersion;
117
118     @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION")
119     private Boolean skipPostInstConf;
120
121     @Column(name = "VNFCINSTANCEGROUP_ORDER")
122     private String vnfcInstanceGroupOrder;
123
124     @Column(name = "NF_DATA_VALID")
125     private Boolean nfDataValid;
126
127     @Override
128     public boolean equals(final Object other) {
129         if (!(other instanceof VnfResourceCustomization)) {
130             return false;
131         }
132         VnfResourceCustomization castOther = (VnfResourceCustomization) other;
133         return new EqualsBuilder().append(id, castOther.id).isEquals();
134     }
135
136     @Override
137     public int hashCode() {
138         return new HashCodeBuilder().append(id).toHashCode();
139     }
140
141     public void setCreated(Date created) {
142         this.created = created;
143     }
144
145     @Override
146     public String toString() {
147         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
148                 .append("modelInstanceName", modelInstanceName).append("created", created)
149                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
150                 .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction)
151                 .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
152                 .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources)
153                 .append("vfModuleCustomizations", vfModuleCustomizations)
154                 .append("vnfcInstanceGroupOrder", vnfcInstanceGroupOrder)
155                 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
156     }
157
158     @PrePersist
159     protected void onCreate() {
160         this.created = new Date();
161     }
162
163     public String getModelCustomizationUUID() {
164         return modelCustomizationUUID;
165     }
166
167     public void setModelCustomizationUUID(String modelCustomizationUUID) {
168         this.modelCustomizationUUID = modelCustomizationUUID;
169     }
170
171     public Integer getId() {
172         return id;
173     }
174
175     public void setId(Integer id) {
176         this.id = id;
177     }
178
179     @LinkedResource
180     public Service getService() {
181         return service;
182     }
183
184     public void setService(Service service) {
185         this.service = service;
186     }
187
188     public String getModelInstanceName() {
189         return this.modelInstanceName;
190     }
191
192     public void setModelInstanceName(String modelInstanceName) {
193         this.modelInstanceName = modelInstanceName;
194     }
195
196     public Date getCreationTimestamp() {
197         return this.created;
198     }
199
200     public Integer getMinInstances() {
201         return this.minInstances;
202     }
203
204     public void setMinInstances(Integer minInstances) {
205         this.minInstances = minInstances;
206     }
207
208     public Integer getMaxInstances() {
209         return this.maxInstances;
210     }
211
212     public void setMaxInstances(Integer maxInstances) {
213         this.maxInstances = maxInstances;
214     }
215
216     public Integer getAvailabilityZoneMaxCount() {
217         return this.availabilityZoneMaxCount;
218     }
219
220     public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) {
221         this.availabilityZoneMaxCount = availabilityZoneMaxCount;
222     }
223
224     public String getNfFunction() {
225         return nfFunction;
226     }
227
228     public void setNfFunction(String nfFunction) {
229         this.nfFunction = nfFunction;
230     }
231
232     public String getNfType() {
233         return nfType;
234     }
235
236     public void setNfType(String nfType) {
237         this.nfType = nfType;
238     }
239
240     public String getNfRole() {
241         return nfRole;
242     }
243
244     public void setNfRole(String nfRole) {
245         this.nfRole = nfRole;
246     }
247
248     public String getNfNamingCode() {
249         return nfNamingCode;
250     }
251
252     public void setNfNamingCode(String nfNamingCode) {
253         this.nfNamingCode = nfNamingCode;
254     }
255
256     public String getMultiStageDesign() {
257         return this.multiStageDesign;
258     }
259
260     public void setMultiStageDesign(String multiStageDesign) {
261         this.multiStageDesign = multiStageDesign;
262     }
263
264     @LinkedResource
265     public List<VfModuleCustomization> getVfModuleCustomizations() {
266         if (vfModuleCustomizations == null) {
267             vfModuleCustomizations = new ArrayList<>();
268         }
269         return vfModuleCustomizations;
270     }
271
272     public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) {
273         this.vfModuleCustomizations = vfModuleCustomizations;
274     }
275
276     @LinkedResource
277     public VnfResource getVnfResources() {
278         return vnfResources;
279     }
280
281     public void setVnfResources(VnfResource vnfResources) {
282         this.vnfResources = vnfResources;
283     }
284
285     public Date getCreated() {
286         return created;
287     }
288
289     @LinkedResource
290     public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
291         return vnfcInstanceGroupCustomizations;
292     }
293
294     public void setVnfcInstanceGroupCustomizations(
295             List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
296         this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
297     }
298
299     public String getResourceInput() {
300         return resourceInput;
301     }
302
303     public void setResourceInput(String resourceInput) {
304         this.resourceInput = resourceInput;
305     }
306
307
308     public String getBlueprintName() {
309         return blueprintName;
310     }
311
312     public void setBlueprintName(String blueprintName) {
313         this.blueprintName = blueprintName;
314     }
315
316     public String getBlueprintVersion() {
317         return blueprintVersion;
318     }
319
320     public void setBlueprintVersion(String blueprintVersion) {
321         this.blueprintVersion = blueprintVersion;
322     }
323
324     public Boolean isSkipPostInstConf() {
325         return skipPostInstConf;
326     }
327
328     public void setSkipPostInstConf(Boolean skipPostInstConf) {
329         this.skipPostInstConf = skipPostInstConf;
330     }
331
332     public String getVnfcInstanceGroupOrder() {
333         return vnfcInstanceGroupOrder;
334     }
335
336     public void setVnfcInstanceGroupOrder(String vnfcInstanceGroupOrder) {
337         this.vnfcInstanceGroupOrder = vnfcInstanceGroupOrder;
338     }
339
340     public Boolean getNfDataValid() {
341         return nfDataValid;
342     }
343
344     public void setNfDataValid(Boolean nfDataValid) {
345         this.nfDataValid = nfDataValid;
346     }
347
348
349 }