[SO] Release so 1.13.0 image
[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 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.OneToMany;
34 import javax.persistence.PrePersist;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
41 import org.hibernate.annotations.NotFound;
42 import org.hibernate.annotations.NotFoundAction;
43 import com.openpojo.business.annotation.BusinessKey;
44 import uk.co.blackpepper.bowman.annotation.LinkedResource;
45 import uk.co.blackpepper.bowman.annotation.RemoteResource;
46
47 @Entity
48 @RemoteResource("/vnfResource")
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     @NotFound(action = NotFoundAction.IGNORE)
95     @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID")
96     private HeatTemplate heatTemplates;
97
98     @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResource")
99     private List<VnfResourceWorkflow> vnfResourceWorkflow;
100
101     @PrePersist
102     protected void onCreate() {
103         this.created = new Date();
104     }
105
106     @Override
107     public String toString() {
108         return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
109                 .append("modelName", modelName).append("modelVersion", modelVersion)
110                 .append("toscaNodeType", toscaNodeType).append("description", description)
111                 .append("orchestrationMode", orchestrationMode).append("aicVersionMin", aicVersionMin)
112                 .append("aicVersionMax", aicVersionMax).append("created", created)
113                 .append("heatTemplates", heatTemplates).append("vnfResourceWorkflow", vnfResourceWorkflow).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 The category to set.
175      */
176     public void setCategory(String category) {
177         this.category = category;
178     }
179
180     /**
181      * @return Returns the subCategory.
182      */
183     public String getSubCategory() {
184         return subCategory;
185     }
186
187     /**
188      * @param subCategory The subCategory to set.
189      */
190     public void setSubCategory(String subCategory) {
191         this.subCategory = subCategory;
192     }
193
194     public String getModelInvariantUUID() {
195         return this.modelInvariantUUID;
196     }
197
198     public void setModelInvariantUUID(String modelInvariantUUID) {
199         this.modelInvariantUUID = modelInvariantUUID;
200     }
201
202     public String getModelName() {
203         return modelName;
204     }
205
206     public void setModelName(String modelName) {
207         this.modelName = modelName;
208     }
209
210     public String getModelUUID() {
211         return modelUUID;
212     }
213
214     public void setModelUUID(String modelUUID) {
215         this.modelUUID = modelUUID;
216     }
217
218     public String getModelInvariantId() {
219         return this.modelInvariantUUID;
220     }
221
222     public String getToscaNodeType() {
223         return toscaNodeType;
224     }
225
226     public void setToscaNodeType(String toscaNodeType) {
227         this.toscaNodeType = toscaNodeType;
228     }
229
230     @LinkedResource
231     public HeatTemplate getHeatTemplates() {
232         return heatTemplates;
233     }
234
235     public void setHeatTemplates(HeatTemplate heatTemplates) {
236         this.heatTemplates = heatTemplates;
237     }
238
239     public String getModelVersion() {
240         return modelVersion;
241     }
242
243     public void setModelVersion(String modelVersion) {
244         this.modelVersion = modelVersion;
245     }
246
247     @LinkedResource
248     public List<VnfResourceWorkflow> getVnfResourceWorkflow() {
249         if (vnfResourceWorkflow == null)
250             vnfResourceWorkflow = new ArrayList<>();
251         return vnfResourceWorkflow;
252     }
253
254     public void setVnfResourceWorkflow(List<VnfResourceWorkflow> vnfResourceWorkflow) {
255         this.vnfResourceWorkflow = vnfResourceWorkflow;
256     }
257
258 }