Containerization feature of SO
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VnfResource.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.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.OneToMany;
35 import javax.persistence.PrePersist;
36 import javax.persistence.Table;
37 import javax.persistence.Temporal;
38 import javax.persistence.TemporalType;
39
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
44 import com.openpojo.business.annotation.BusinessKey;
45
46 import uk.co.blackpepper.bowman.annotation.LinkedResource;
47
48 @Entity
49 @Table(name = "vnf_resource")
50 public class VnfResource implements Serializable {
51
52         private static final long serialVersionUID = 768026109321305392L;
53
54         @BusinessKey
55         @Id
56         @Column(name = "MODEL_UUID")
57         private String modelUUID;
58
59         @Column(name = "MODEL_INVARIANT_UUID")
60         private String modelInvariantUUID;
61
62         @Column(name = "MODEL_NAME")
63         private String modelName;
64
65         @Column(name = "MODEL_VERSION")
66         private String modelVersion;
67
68         @Column(name = "TOSCA_NODE_TYPE")
69         private String toscaNodeType;
70
71         @Column(name = "DESCRIPTION")
72         private String description;
73
74         @Column(name = "ORCHESTRATION_MODE")
75         private String orchestrationMode;
76
77         @Column(name = "AIC_VERSION_MIN")
78         private String aicVersionMin;
79
80         @Column(name = "AIC_VERSION_MAX")
81         private String aicVersionMax;
82
83         @Column(name = "RESOURCE_CATEGORY")
84         private String category;
85
86         @Column(name = "RESOURCE_SUB_CATEGORY")
87         private String subCategory;
88
89         @Column(name = "CREATION_TIMESTAMP", updatable = false)
90         @Temporal(TemporalType.TIMESTAMP)
91         private Date created;
92
93         @ManyToOne(fetch = FetchType.LAZY)
94         @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID")
95         private HeatTemplate heatTemplates;
96
97         @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResources")
98         private List<VnfResourceCustomization> vnfResourceCustomizations;
99
100         @PrePersist
101         protected void onCreate() {
102                 this.created = new Date();
103         }
104
105         @Override
106         public String toString() {
107                 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
108                                 .append("modelName", modelName).append("modelVersion", modelVersion)
109                                 .append("toscaNodeType", toscaNodeType).append("description", description)
110                                 .append("orchestrationMode", orchestrationMode).append("aicVersionMin", aicVersionMin)
111                                 .append("aicVersionMax", aicVersionMax).append("created", created)
112                                 .append("heatTemplates", heatTemplates).append("vnfResourceCustomizations", vnfResourceCustomizations)
113                                 .toString();
114         }
115
116         @Override
117         public boolean equals(final Object other) {
118                 if (!(other instanceof VnfResource)) {
119                         return false;
120                 }
121                 VnfResource castOther = (VnfResource) other;
122                 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
123         }
124
125         @Override
126         public int hashCode() {
127                 return new HashCodeBuilder().append(modelUUID).toHashCode();
128         }
129
130         public String getOrchestrationMode() {
131                 return orchestrationMode;
132         }
133
134         public void setOrchestrationMode(String orchestrationMode) {
135                 this.orchestrationMode = orchestrationMode;
136         }
137
138         public String getDescription() {
139                 return description;
140         }
141
142         public void setDescription(String description) {
143                 this.description = description;
144         }
145
146         public Date getCreated() {
147                 return created;
148         }
149
150         public String getAicVersionMin() {
151                 return this.aicVersionMin;
152         }
153
154         public void setAicVersionMin(String aicVersionMin) {
155                 this.aicVersionMin = aicVersionMin;
156         }
157
158         public String getAicVersionMax() {
159                 return this.aicVersionMax;
160         }
161
162         public void setAicVersionMax(String aicVersionMax) {
163                 this.aicVersionMax = aicVersionMax;
164         }
165
166         /**
167          * @return Returns the category.
168          */
169         public String getCategory() {
170                 return category;
171         }
172
173         /**
174          * @param category
175          *            The category to set.
176          */
177         public void setCategory(String category) {
178                 this.category = category;
179         }
180
181         /**
182          * @return Returns the subCategory.
183          */
184         public String getSubCategory() {
185                 return subCategory;
186         }
187
188         /**
189          * @param subCategory
190          *            The subCategory to set.
191          */
192         public void setSubCategory(String subCategory) {
193                 this.subCategory = subCategory;
194         }
195
196         public String getModelInvariantUUID() {
197                 return this.modelInvariantUUID;
198         }
199
200         public void setModelInvariantUUID(String modelInvariantUUID) {
201                 this.modelInvariantUUID = modelInvariantUUID;
202         }
203
204         public String getModelName() {
205                 return modelName;
206         }
207
208         public void setModelName(String modelName) {
209                 this.modelName = modelName;
210         }
211
212         public String getModelUUID() {
213                 return modelUUID;
214         }
215
216         public void setModelUUID(String modelUUID) {
217                 this.modelUUID = modelUUID;
218         }
219
220         public String getModelInvariantId() {
221                 return this.modelInvariantUUID;
222         }
223
224         public String getToscaNodeType() {
225                 return toscaNodeType;
226         }
227
228         public void setToscaNodeType(String toscaNodeType) {
229                 this.toscaNodeType = toscaNodeType;
230         }
231
232         @LinkedResource
233         public List<VnfResourceCustomization> getVnfResourceCustomizations() {
234                 if (vnfResourceCustomizations == null)
235                         vnfResourceCustomizations = new ArrayList<>();
236                 return vnfResourceCustomizations;
237         }
238
239         public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) {
240                 this.vnfResourceCustomizations = vnfResourceCustomizations;
241         }
242
243         @LinkedResource
244         public HeatTemplate getHeatTemplates() {
245                 return heatTemplates;
246         }
247
248         public void setHeatTemplates(HeatTemplate heatTemplates) {
249                 this.heatTemplates = heatTemplates;
250         }
251
252         public String getModelVersion() {
253                 return modelVersion;
254         }
255
256         public void setModelVersion(String modelVersion) {
257                 this.modelVersion = modelVersion;
258         }
259 }