Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / NetworkResource.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.text.DateFormat;
25 import java.util.ArrayList;
26 import java.util.Date;
27 import java.util.List;
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.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 com.openpojo.business.annotation.BusinessKey;
43 import uk.co.blackpepper.bowman.annotation.LinkedResource;
44
45 @Entity
46 @Table(name = "network_resource")
47 public class NetworkResource implements Serializable {
48
49     private static final long serialVersionUID = 768026109321305392L;
50
51     @BusinessKey
52     @Id
53     @Column(name = "MODEL_UUID")
54     private String modelUUID;
55
56     @Column(name = "ORCHESTRATION_MODE")
57     private String orchestrationMode = null;
58
59     @Column(name = "DESCRIPTION")
60     private String description = null;
61
62     @Column(name = "NEUTRON_NETWORK_TYPE")
63     private String neutronNetworkType = null;
64
65     @Column(name = "AIC_VERSION_MIN")
66     private String aicVersionMin = null;
67
68     @Column(name = "AIC_VERSION_MAX")
69     private String aicVersionMax = null;
70
71     @Column(name = "MODEL_NAME")
72     private String modelName;
73
74     @Column(name = "MODEL_INVARIANT_UUID")
75     private String modelInvariantUUID;
76
77     @Column(name = "MODEL_VERSION")
78     private String modelVersion;
79
80     @Column(name = "TOSCA_NODE_TYPE")
81     private String toscaNodeType;
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     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "networkResource")
94     private List<NetworkResourceCustomization> networkResourceCustomization;
95
96     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "networkResource")
97     private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomization;
98
99     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
100     @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID")
101     private HeatTemplate heatTemplate;
102
103     @PrePersist
104     protected void onCreate() {
105         this.created = new Date();
106     }
107
108     @Override
109     public boolean equals(final Object other) {
110         if (!(other instanceof NetworkResource)) {
111             return false;
112         }
113         NetworkResource castOther = (NetworkResource) other;
114         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
115     }
116
117     @Override
118     public int hashCode() {
119         return new HashCodeBuilder().append(modelUUID).toHashCode();
120     }
121
122     @LinkedResource
123     public List<NetworkResourceCustomization> getNetworkResourceCustomization() {
124         return networkResourceCustomization;
125     }
126
127     public void addNetworkResourceCustomization(NetworkResourceCustomization networkResourceCustomization) {
128         if (this.networkResourceCustomization == null)
129             this.networkResourceCustomization = new ArrayList<>();
130
131         this.networkResourceCustomization.add(networkResourceCustomization);
132     }
133
134     public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomization) {
135         this.networkResourceCustomization = networkResourceCustomization;
136     }
137
138     @LinkedResource
139     public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomization() {
140         return collectionNetworkResourceCustomization;
141     }
142
143     public void setCollectionNetworkResourceCustomization(
144             List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomization) {
145         this.collectionNetworkResourceCustomization = collectionNetworkResourceCustomization;
146     }
147
148     public String getOrchestrationMode() {
149         return orchestrationMode;
150     }
151
152     public void setOrchestrationMode(String orchestrationMode) {
153         this.orchestrationMode = orchestrationMode;
154     }
155
156     public String getDescription() {
157         return description;
158     }
159
160     public void setDescription(String description) {
161         this.description = description;
162     }
163
164     public String getNeutronNetworkType() {
165         return neutronNetworkType;
166     }
167
168     public void setNeutronNetworkType(String neutronNetworkType) {
169         this.neutronNetworkType = neutronNetworkType;
170     }
171
172     public Date getCreated() {
173         return created;
174     }
175
176     public String getAicVersionMin() {
177         return aicVersionMin;
178     }
179
180     public void setAicVersionMin(String aicVersionMin) {
181         this.aicVersionMin = aicVersionMin;
182     }
183
184     public String getAicVersionMax() {
185         return aicVersionMax;
186     }
187
188     public void setAicVersionMax(String aicVersionMax) {
189         this.aicVersionMax = aicVersionMax;
190     }
191
192     public String getModelName() {
193         return modelName;
194     }
195
196     public void setModelName(String modelName) {
197         this.modelName = modelName;
198     }
199
200     public String getModelInvariantUUID() {
201         return modelInvariantUUID;
202     }
203
204     public void setModelInvariantUUID(String modelInvariantUUID) {
205         this.modelInvariantUUID = modelInvariantUUID;
206     }
207
208     public String getToscaNodeType() {
209         return toscaNodeType;
210     }
211
212     public void setToscaNodeType(String toscaNodeType) {
213         this.toscaNodeType = toscaNodeType;
214     }
215
216     public String getModelUUID() {
217         return modelUUID;
218     }
219
220     public void setModelUUID(String modelUUID) {
221         this.modelUUID = modelUUID;
222     }
223
224     /**
225      * @return Returns the category.
226      */
227     public String getCategory() {
228         return category;
229     }
230
231     /**
232      * @param category The category to set.
233      */
234     public void setCategory(String category) {
235         this.category = category;
236     }
237
238     /**
239      * @return Returns the subCategory.
240      */
241     public String getSubCategory() {
242         return subCategory;
243     }
244
245     /**
246      * @param subCategory The subCategory to set.
247      */
248     public void setSubCategory(String subCategory) {
249         this.subCategory = subCategory;
250     }
251
252     @LinkedResource
253     public HeatTemplate getHeatTemplate() {
254         return heatTemplate;
255     }
256
257     public void setHeatTemplate(HeatTemplate heatTemplate) {
258         this.heatTemplate = heatTemplate;
259     }
260
261     public String getModelVersion() {
262         return modelVersion;
263     }
264
265     public void setModelVersion(String modelVersion) {
266         this.modelVersion = modelVersion;
267     }
268
269     @Override
270     public String toString() {
271         StringBuilder sb = new StringBuilder();
272         sb.append("NETWORK Resource:");
273         sb.append("modelVersion=");
274         sb.append(modelVersion);
275         sb.append(",mode=");
276         sb.append(orchestrationMode);
277         sb.append(",neutronType=");
278         sb.append(neutronNetworkType);
279         sb.append(",aicVersionMin=");
280         sb.append(aicVersionMin);
281         sb.append(",aicVersionMax=");
282         sb.append(aicVersionMax);
283         sb.append(",modelName=");
284         sb.append(modelName);
285         sb.append(",modelInvariantUUID=");
286         sb.append(modelInvariantUUID);
287         sb.append(",toscaNodeType=");
288         sb.append(toscaNodeType);
289         sb.append(",modelUUID=");
290         sb.append(modelUUID);
291
292         if (created != null) {
293             sb.append(",created=");
294             sb.append(DateFormat.getInstance().format(created));
295         }
296
297         return sb.toString();
298     }
299 }