[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VfModuleCustomization.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.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.OneToMany;
36 import javax.persistence.PrePersist;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40 import org.apache.commons.lang3.builder.EqualsBuilder;
41 import org.apache.commons.lang3.builder.HashCodeBuilder;
42 import org.apache.commons.lang3.builder.ToStringBuilder;
43 import com.fasterxml.jackson.annotation.JsonFormat;
44 import com.openpojo.business.annotation.BusinessKey;
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
47
48 @Entity
49 @RemoteResource("/vfModuleCustomization")
50 @Table(name = "vf_module_customization")
51 public class VfModuleCustomization implements Serializable {
52
53     public static final long serialVersionUID = -1322322139926390329L;
54
55     @Id
56     @BusinessKey
57     @Column(name = "ID")
58     @GeneratedValue(strategy = GenerationType.IDENTITY)
59     private Integer id;
60
61     @Column(name = "MODEL_CUSTOMIZATION_UUID")
62     private String modelCustomizationUUID;
63
64     @Column(name = "LABEL")
65     private String label;
66
67     @Column(name = "MIN_INSTANCES", nullable = false)
68     private Integer minInstances = 0;
69
70     @Column(name = "MAX_INSTANCES")
71     private Integer maxInstances;
72
73     @Column(name = "INITIAL_COUNT", nullable = false)
74     private Integer initialCount = 0;
75
76     @Column(name = "AVAILABILITY_ZONE_COUNT")
77     private Integer availabilityZoneCount;
78
79     @Column(name = "CREATION_TIMESTAMP", updatable = false)
80     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
81     @Temporal(TemporalType.TIMESTAMP)
82     private Date created;
83
84     @ManyToOne(cascade = CascadeType.ALL)
85     @JoinColumn(name = "VOL_ENVIRONMENT_ARTIFACT_UUID")
86     HeatEnvironment volumeHeatEnv;
87
88     @ManyToOne(cascade = CascadeType.ALL)
89     @JoinColumn(name = "HEAT_ENVIRONMENT_ARTIFACT_UUID")
90     HeatEnvironment heatEnvironment;
91
92     @ManyToOne(cascade = CascadeType.ALL)
93     @JoinColumn(name = "VF_MODULE_MODEL_UUID")
94     private VfModule vfModule;
95
96     @ManyToOne(cascade = CascadeType.ALL)
97     @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_ID")
98     private VnfResourceCustomization vnfCustomization;
99
100     @OneToMany(cascade = CascadeType.ALL, mappedBy = "vfModuleCustomization")
101     private List<CvnfcCustomization> cvnfcCustomization;
102
103     @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION", nullable = false)
104     private Boolean skipPostInstConf = true;
105
106     @Override
107     public boolean equals(final Object other) {
108         if (!(other instanceof VfModuleCustomization)) {
109             return false;
110         }
111         VfModuleCustomization castOther = (VfModuleCustomization) other;
112         return new EqualsBuilder().append(id, castOther.id).isEquals();
113     }
114
115     @Override
116     public int hashCode() {
117         return new HashCodeBuilder().append(id).toHashCode();
118     }
119
120     @PrePersist
121     protected void onCreate() {
122         this.created = new Date();
123     }
124
125     @Override
126     public String toString() {
127         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID).append("label", label)
128                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
129                 .append("initialCount", initialCount).append("availabilityZoneCount", availabilityZoneCount)
130                 .append("created", created).append("volumeHeatEnv", volumeHeatEnv)
131                 .append("heatEnvironment", heatEnvironment).append("vfModule", vfModule).toString();
132     }
133
134
135
136     public Integer getId() {
137         return id;
138     }
139
140     public void setId(Integer id) {
141         this.id = id;
142     }
143
144     public VnfResourceCustomization getVnfCustomization() {
145         return vnfCustomization;
146     }
147
148     public void setVnfCustomization(VnfResourceCustomization vnfCustomization) {
149         this.vnfCustomization = vnfCustomization;
150     }
151
152     public VfModuleCustomization() {
153         super();
154     }
155
156     public String getModelCustomizationUUID() {
157         return this.modelCustomizationUUID;
158     }
159
160     public void setModelCustomizationUUID(String modelCustomizationUUID) {
161         this.modelCustomizationUUID = modelCustomizationUUID;
162     }
163
164     @LinkedResource
165     public HeatEnvironment getVolumeHeatEnv() {
166         return volumeHeatEnv;
167     }
168
169     public void setVolumeHeatEnv(HeatEnvironment volumeHeatEnv) {
170         this.volumeHeatEnv = volumeHeatEnv;
171     }
172
173     @LinkedResource
174     public HeatEnvironment getHeatEnvironment() {
175         return heatEnvironment;
176     }
177
178     public void setHeatEnvironment(HeatEnvironment heatEnvironment) {
179         this.heatEnvironment = heatEnvironment;
180     }
181
182     public Integer getMinInstances() {
183         return this.minInstances;
184     }
185
186     public void setMinInstances(Integer minInstances) {
187         this.minInstances = minInstances;
188     }
189
190     public Integer getMaxInstances() {
191         return this.maxInstances;
192     }
193
194     public void setMaxInstances(Integer maxInstances) {
195         this.maxInstances = maxInstances;
196     }
197
198     public Integer getInitialCount() {
199         return this.initialCount;
200     }
201
202     public void setInitialCount(Integer initialCount) {
203         this.initialCount = initialCount;
204     }
205
206     public Integer getAvailabilityZoneCount() {
207         return this.availabilityZoneCount;
208     }
209
210     public void setAvailabilityZoneCount(Integer availabilityZoneCount) {
211         this.availabilityZoneCount = availabilityZoneCount;
212     }
213
214     public Date getCreated() {
215         return created;
216     }
217
218     public String getLabel() {
219         return this.label;
220     }
221
222     public void setLabel(String label) {
223         this.label = label;
224     }
225
226     @LinkedResource
227     public VfModule getVfModule() {
228         return this.vfModule;
229     }
230
231     public void setVfModule(VfModule vfModule) {
232         this.vfModule = vfModule;
233     }
234
235     @LinkedResource
236     public List<CvnfcCustomization> getCvnfcCustomization() {
237         if (cvnfcCustomization == null)
238             cvnfcCustomization = new ArrayList<>();
239         return cvnfcCustomization;
240     }
241
242     public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) {
243         this.cvnfcCustomization = cvnfcCustomization;
244     }
245
246     public Boolean getSkipPostInstConf() {
247         return skipPostInstConf;
248     }
249
250     public void setSkipPostInstConf(Boolean skipPostInstConf) {
251         this.skipPostInstConf = skipPostInstConf;
252     }
253 }