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