1cbc7b561f5706113297107bdb02a7c293ca4e9f
[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.HashSet;
27 import java.util.List;
28 import java.util.Set;
29
30 import javax.persistence.CascadeType;
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.FetchType;
34 import javax.persistence.GeneratedValue;
35 import javax.persistence.GenerationType;
36 import javax.persistence.Id;
37 import javax.persistence.JoinColumn;
38 import javax.persistence.JoinTable;
39 import javax.persistence.ManyToOne;
40 import javax.persistence.OneToMany;
41 import javax.persistence.PrePersist;
42 import javax.persistence.Table;
43 import javax.persistence.Temporal;
44 import javax.persistence.TemporalType;
45
46 import org.apache.commons.lang3.builder.EqualsBuilder;
47 import org.apache.commons.lang3.builder.HashCodeBuilder;
48 import org.apache.commons.lang3.builder.ToStringBuilder;
49
50 import com.fasterxml.jackson.annotation.JsonFormat;
51 import com.openpojo.business.annotation.BusinessKey;
52
53 import uk.co.blackpepper.bowman.annotation.LinkedResource;
54
55 @Entity
56 @Table(name = "vnf_resource_customization")
57 public class VnfResourceCustomization implements Serializable {
58
59     private static final long serialVersionUID = 768026109321305392L;
60     
61     @Id
62     @BusinessKey
63     @Column(name = "ID")
64     @GeneratedValue(strategy = GenerationType.IDENTITY)
65     private Integer id;
66     
67     @Column(name = "MODEL_CUSTOMIZATION_UUID")
68     private String modelCustomizationUUID;
69
70     @Column(name = "MODEL_INSTANCE_NAME")
71     private String modelInstanceName;
72
73     @Column(name = "CREATION_TIMESTAMP", updatable = false)
74     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
75     @Temporal(TemporalType.TIMESTAMP)
76     private Date created;
77
78     @Column(name = "MIN_INSTANCES")
79     private Integer minInstances;
80
81     @Column(name = "MAX_INSTANCES")
82     private Integer maxInstances;
83
84     @Column(name = "AVAILABILITY_ZONE_MAX_COUNT")
85     private Integer availabilityZoneMaxCount;
86
87     @Column(name = "NF_FUNCTION")
88     private String nfFunction;
89
90     @Column(name = "NF_TYPE")
91     private String nfType;
92
93     @Column(name = "NF_ROLE")
94     private String nfRole;
95
96     @Column(name = "NF_NAMING_CODE")
97     private String nfNamingCode;
98
99     @Column(name = "MULTI_STAGE_DESIGN")
100     private String multiStageDesign;
101
102     @Column(name = "RESOURCE_INPUT")
103     private String resourceInput;
104
105     @ManyToOne(cascade = CascadeType.ALL)
106     @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID")
107     private VnfResource vnfResources;
108     
109     @ManyToOne(cascade = CascadeType.ALL)
110     @JoinColumn(name = "SERVICE_MODEL_UUID")
111     private Service service;
112
113     @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER, mappedBy = "vnfCustomization")
114     private List<VfModuleCustomization> vfModuleCustomizations;
115
116     @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResourceCust")
117     private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
118     
119     @Column(name = "CDS_BLUEPRINT_NAME")
120     private String blueprintName;
121
122     @Column(name = "CDS_BLUEPRINT_VERSION")
123     private String blueprintVersion;
124
125     @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION")
126     private Boolean skipPostInstConf;
127
128     @Override
129     public boolean equals(final Object other) {
130         if (!(other instanceof VnfResourceCustomization)) {
131             return false;
132         }
133         VnfResourceCustomization castOther = (VnfResourceCustomization) other;
134         return new EqualsBuilder().append(id, castOther.id).isEquals();
135     }
136
137     @Override
138     public int hashCode() {
139         return new HashCodeBuilder().append(id).toHashCode();
140     }
141
142     public void setCreated(Date created) {
143         this.created = created;
144     }
145
146     @Override
147     public String toString() {
148         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
149                 .append("modelInstanceName", modelInstanceName).append("created", created)
150                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
151                 .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction)
152                 .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
153                 .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources)
154                 .append("vfModuleCustomizations", vfModuleCustomizations)
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 }