fa0fe5636e36035e792886888afc2daa928a3cae
[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
28 import javax.persistence.CascadeType;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.FetchType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.JoinTable;
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
42 import org.apache.commons.lang3.builder.EqualsBuilder;
43 import org.apache.commons.lang3.builder.HashCodeBuilder;
44 import org.apache.commons.lang3.builder.ToStringBuilder;
45
46 import com.fasterxml.jackson.annotation.JsonFormat;
47 import com.openpojo.business.annotation.BusinessKey;
48
49 import uk.co.blackpepper.bowman.annotation.LinkedResource;
50
51 @Entity
52 @Table(name = "vnf_resource_customization")
53 public class VnfResourceCustomization implements Serializable {
54
55         private static final long serialVersionUID = 768026109321305392L;
56
57         @BusinessKey
58         @Id
59         @Column(name = "MODEL_CUSTOMIZATION_UUID")
60         private String modelCustomizationUUID;
61
62         @Column(name = "MODEL_INSTANCE_NAME")
63         private String modelInstanceName;
64
65         @Column(name = "CREATION_TIMESTAMP", updatable = false)
66         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
67         @Temporal(TemporalType.TIMESTAMP)
68         private Date created;
69
70         @Column(name = "MIN_INSTANCES")
71         private Integer minInstances;
72
73         @Column(name = "MAX_INSTANCES")
74         private Integer maxInstances;
75
76         @Column(name = "AVAILABILITY_ZONE_MAX_COUNT")
77         private Integer availabilityZoneMaxCount;
78
79         @Column(name = "NF_FUNCTION")
80         private String nfFunction;
81
82         @Column(name = "NF_TYPE")
83         private String nfType;
84
85         @Column(name = "NF_ROLE")
86         private String nfRole;
87
88         @Column(name = "NF_NAMING_CODE")
89         private String nfNamingCode;
90
91         @Column(name = "MULTI_STAGE_DESIGN")
92         private String multiStageDesign;
93
94         @ManyToOne(cascade = CascadeType.ALL)
95         @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID")
96         private VnfResource vnfResources;
97
98         @OneToMany(cascade = CascadeType.ALL)
99         @JoinTable(name = "vnf_res_custom_to_vf_module_custom", joinColumns = @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID"), inverseJoinColumns = @JoinColumn(name = "VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID"))
100         private List<VfModuleCustomization> vfModuleCustomizations;
101
102         @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResourceCust")
103         private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations;
104
105         @Override
106         public String toString() {
107                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
108                                 .append("modelInstanceName", modelInstanceName).append("created", created)
109                                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
110                                 .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction)
111                                 .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
112                                 .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources)
113                                 .append("vfModuleCustomizations", vfModuleCustomizations)
114                                 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
115         }
116
117         @Override
118         public boolean equals(final Object other) {
119                 if (!(other instanceof VnfResourceCustomization)) {
120                         return false;
121                 }
122                 VnfResourceCustomization castOther = (VnfResourceCustomization) other;
123                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
124         }
125
126         @Override
127         public int hashCode() {
128                 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
129         }
130
131         @PrePersist
132         protected void onCreate() {
133                 this.created = new Date();
134         }
135
136         public String getModelCustomizationUUID() {
137                 return modelCustomizationUUID;
138         }
139
140         public void setModelCustomizationUUID(String modelCustomizationUUID) {
141                 this.modelCustomizationUUID = modelCustomizationUUID;
142         }
143
144         public String getModelInstanceName() {
145                 return this.modelInstanceName;
146         }
147
148         public void setModelInstanceName(String modelInstanceName) {
149                 this.modelInstanceName = modelInstanceName;
150         }
151
152         public Date getCreationTimestamp() {
153                 return this.created;
154         }
155
156         public Integer getMinInstances() {
157                 return this.minInstances;
158         }
159
160         public void setMinInstances(Integer minInstances) {
161                 this.minInstances = minInstances;
162         }
163
164         public Integer getMaxInstances() {
165                 return this.maxInstances;
166         }
167
168         public void setMaxInstances(Integer maxInstances) {
169                 this.maxInstances = maxInstances;
170         }
171
172         public Integer getAvailabilityZoneMaxCount() {
173                 return this.availabilityZoneMaxCount;
174         }
175
176         public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) {
177                 this.availabilityZoneMaxCount = availabilityZoneMaxCount;
178         }
179
180         public String getNfFunction() {
181                 return nfFunction;
182         }
183
184         public void setNfFunction(String nfFunction) {
185                 this.nfFunction = nfFunction;
186         }
187
188         public String getNfType() {
189                 return nfType;
190         }
191
192         public void setNfType(String nfType) {
193                 this.nfType = nfType;
194         }
195
196         public String getNfRole() {
197                 return nfRole;
198         }
199
200         public void setNfRole(String nfRole) {
201                 this.nfRole = nfRole;
202         }
203
204         public String getNfNamingCode() {
205                 return nfNamingCode;
206         }
207
208         public void setNfNamingCode(String nfNamingCode) {
209                 this.nfNamingCode = nfNamingCode;
210         }
211
212         public String getMultiStageDesign() {
213                 return this.multiStageDesign;
214         }
215
216         public void setMultiStageDesign(String multiStageDesign) {
217                 this.multiStageDesign = multiStageDesign;
218         }
219
220         @LinkedResource
221         public List<VfModuleCustomization> getVfModuleCustomizations() {
222                 if (vfModuleCustomizations == null)
223                         vfModuleCustomizations = new ArrayList<>();
224                 return vfModuleCustomizations;
225         }
226
227         public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) {
228                 this.vfModuleCustomizations = vfModuleCustomizations;
229         }
230
231         @LinkedResource
232         public VnfResource getVnfResources() {
233                 return vnfResources;
234         }
235
236         public void setVnfResources(VnfResource vnfResources) {
237                 this.vnfResources = vnfResources;
238         }
239
240         public Date getCreated() {
241                 return created;
242         }
243
244         @LinkedResource
245         public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
246                 return vnfcInstanceGroupCustomizations;
247         }
248
249         public void setVnfcInstanceGroupCustomizations(
250                         List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
251                 this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
252         }
253 }