e569c3b994b88acd7e97836382dc8cf9190b6fab
[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     @Override
126     public boolean equals(final Object other) {
127         if (!(other instanceof VnfResourceCustomization)) {
128             return false;
129         }
130         VnfResourceCustomization castOther = (VnfResourceCustomization) other;
131         return new EqualsBuilder().append(id, castOther.id).isEquals();
132     }
133
134     @Override
135     public int hashCode() {
136         return new HashCodeBuilder().append(id).toHashCode();
137     }
138
139     public void setCreated(Date created) {
140         this.created = created;
141     }
142
143     @Override
144     public String toString() {
145         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
146                 .append("modelInstanceName", modelInstanceName).append("created", created)
147                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
148                 .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction)
149                 .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
150                 .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources)
151                 .append("vfModuleCustomizations", vfModuleCustomizations)
152                 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
153     }
154
155     @PrePersist
156     protected void onCreate() {
157         this.created = new Date();
158     }
159
160     public String getModelCustomizationUUID() {
161         return modelCustomizationUUID;
162     }
163
164     public void setModelCustomizationUUID(String modelCustomizationUUID) {
165         this.modelCustomizationUUID = modelCustomizationUUID;
166     }
167
168     public Integer getId() {
169         return id;
170     }
171
172     public void setId(Integer id) {
173         this.id = id;
174     }
175     
176     @LinkedResource
177     public Service getService() {
178         return service;
179     }
180
181     public void setService(Service service) {
182         this.service = service;
183     }
184
185     public String getModelInstanceName() {
186         return this.modelInstanceName;
187     }
188
189     public void setModelInstanceName(String modelInstanceName) {
190         this.modelInstanceName = modelInstanceName;
191     }
192
193     public Date getCreationTimestamp() {
194         return this.created;
195     }
196
197     public Integer getMinInstances() {
198         return this.minInstances;
199     }
200
201     public void setMinInstances(Integer minInstances) {
202         this.minInstances = minInstances;
203     }
204
205     public Integer getMaxInstances() {
206         return this.maxInstances;
207     }
208
209     public void setMaxInstances(Integer maxInstances) {
210         this.maxInstances = maxInstances;
211     }
212
213     public Integer getAvailabilityZoneMaxCount() {
214         return this.availabilityZoneMaxCount;
215     }
216
217     public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) {
218         this.availabilityZoneMaxCount = availabilityZoneMaxCount;
219     }
220
221     public String getNfFunction() {
222         return nfFunction;
223     }
224
225     public void setNfFunction(String nfFunction) {
226         this.nfFunction = nfFunction;
227     }
228
229     public String getNfType() {
230         return nfType;
231     }
232
233     public void setNfType(String nfType) {
234         this.nfType = nfType;
235     }
236
237     public String getNfRole() {
238         return nfRole;
239     }
240
241     public void setNfRole(String nfRole) {
242         this.nfRole = nfRole;
243     }
244
245     public String getNfNamingCode() {
246         return nfNamingCode;
247     }
248
249     public void setNfNamingCode(String nfNamingCode) {
250         this.nfNamingCode = nfNamingCode;
251     }
252
253     public String getMultiStageDesign() {
254         return this.multiStageDesign;
255     }
256
257     public void setMultiStageDesign(String multiStageDesign) {
258         this.multiStageDesign = multiStageDesign;
259     }
260
261     @LinkedResource
262     public List<VfModuleCustomization> getVfModuleCustomizations() {
263         if (vfModuleCustomizations == null) {
264             vfModuleCustomizations = new ArrayList<>();
265         }
266         return vfModuleCustomizations;
267     }
268
269     public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) {
270         this.vfModuleCustomizations = vfModuleCustomizations;
271     }
272
273     @LinkedResource
274     public VnfResource getVnfResources() {
275         return vnfResources;
276     }
277
278     public void setVnfResources(VnfResource vnfResources) {
279         this.vnfResources = vnfResources;
280     }
281
282     public Date getCreated() {
283         return created;
284     }
285
286     @LinkedResource
287     public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
288         return vnfcInstanceGroupCustomizations;
289     }
290
291     public void setVnfcInstanceGroupCustomizations(
292             List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
293         this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
294     }
295     
296     public String getResourceInput() {
297         return resourceInput;
298     }
299
300     public void setResourceInput(String resourceInput) {
301         this.resourceInput = resourceInput;
302     }
303
304
305     public String getBlueprintName() {
306         return blueprintName;
307     }
308
309     public void setBlueprintName(String blueprintName) {
310         this.blueprintName = blueprintName;
311     }
312
313     public String getBlueprintVersion() {
314         return blueprintVersion;
315     }
316
317     public void setBlueprintVersion(String blueprintVersion) {
318         this.blueprintVersion = blueprintVersion;
319     }
320
321 }