Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / Service.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 java.util.Map;
28 import java.util.Set;
29 import javax.persistence.CascadeType;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.FetchType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.JoinTable;
36 import javax.persistence.ManyToOne;
37 import javax.persistence.MapKey;
38 import javax.persistence.OneToMany;
39 import javax.persistence.PrePersist;
40 import javax.persistence.Table;
41 import javax.persistence.Temporal;
42 import javax.persistence.TemporalType;
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 com.fasterxml.jackson.annotation.JsonFormat;
47 import com.openpojo.business.annotation.BusinessKey;
48 import uk.co.blackpepper.bowman.annotation.LinkedResource;
49
50 @Entity
51 @Table(name = "service")
52 public class Service implements Serializable {
53
54     private static final long serialVersionUID = 768026109321305392L;
55
56     @Column(name = "MODEL_NAME")
57     private String modelName;
58
59     @Column(name = "DESCRIPTION", length = 1200)
60     private String description;
61
62     @BusinessKey
63     @Id
64     @Column(name = "MODEL_UUID")
65     private String modelUUID;
66
67     @Column(name = "MODEL_INVARIANT_UUID")
68     private String modelInvariantUUID;
69
70     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
71     @Column(name = "CREATION_TIMESTAMP", updatable = false)
72     @Temporal(TemporalType.TIMESTAMP)
73     private Date created;
74
75     @Column(name = "MODEL_VERSION")
76     private String modelVersion;
77
78     @Column(name = "SERVICE_TYPE")
79     private String serviceType;
80
81     @Column(name = "SERVICE_ROLE")
82     private String serviceRole;
83
84     @Column(name = "ENVIRONMENT_CONTEXT")
85     private String environmentContext;
86
87     @Column(name = "WORKLOAD_CONTEXT")
88     private String workloadContext;
89
90     @Column(name = "SERVICE_CATEGORY")
91     private String category;
92
93     @Column(name = "RESOURCE_ORDER")
94     private String resourceOrder;
95
96     @OneToMany(cascade = CascadeType.ALL)
97     @JoinTable(name = "network_resource_customization_to_service",
98             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
99             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
100     private List<NetworkResourceCustomization> networkCustomizations;
101
102     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
103     private List<VnfResourceCustomization> vnfCustomizations;
104
105     @OneToMany(cascade = CascadeType.ALL)
106     @JoinTable(name = "allotted_resource_customization_to_service",
107             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
108             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
109     private List<AllottedResourceCustomization> allottedCustomizations;
110
111     @OneToMany(cascade = CascadeType.ALL)
112     @JoinTable(name = "collection_resource_customization_to_service",
113             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
114             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
115     private List<CollectionResourceCustomization> collectionResourceCustomizations;
116
117     @OneToMany(cascade = CascadeType.ALL)
118     @JoinTable(name = "service_proxy_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
119             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
120     private List<ServiceProxyResourceCustomization> serviceProxyCustomizations;
121
122     @OneToMany(cascade = CascadeType.ALL)
123     @JoinTable(name = "configuration_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
124             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
125     private List<ConfigurationResourceCustomization> configurationCustomizations;
126
127     @OneToMany(cascade = CascadeType.ALL)
128     @JoinTable(name = "pnf_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
129             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
130     private List<PnfResourceCustomization> pnfCustomizations;
131
132     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
133     @MapKey(name = "action")
134     private Map<String, ServiceRecipe> recipes;
135
136     @ManyToOne(cascade = CascadeType.ALL)
137     @JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID")
138     private ToscaCsar csar;
139
140     @Override
141     public String toString() {
142         return new ToStringBuilder(this).append("modelName", modelName).append("description", description)
143                 .append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
144                 .append("created", created).append("modelVersion", modelVersion).append("serviceType", serviceType)
145                 .append("serviceRole", serviceRole).append("environmentContext", environmentContext)
146                 .append("workloadContext", workloadContext).append("category", category)
147                 .append("networkCustomizations", networkCustomizations).append("vnfCustomizations", vnfCustomizations)
148                 .append("allottedCustomizations", allottedCustomizations)
149                 .append("collectionResourceCustomizations", collectionResourceCustomizations)
150                 .append("serviceProxyCustomizations", serviceProxyCustomizations)
151                 .append("configurationCustomizations", configurationCustomizations)
152                 .append("pnfCustomizations", pnfCustomizations).append("recipes", recipes).append("csar", csar)
153                 .toString();
154     }
155
156     @PrePersist
157     protected void onCreate() {
158         this.created = new Date();
159     }
160
161     @Override
162     public boolean equals(final Object other) {
163         if (!(other instanceof Service)) {
164             return false;
165         }
166         Service castOther = (Service) other;
167         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
168     }
169
170     @Override
171     public int hashCode() {
172         return new HashCodeBuilder().append(modelUUID).toHashCode();
173     }
174
175     @LinkedResource
176     public List<ServiceProxyResourceCustomization> getServiceProxyCustomizations() {
177         return serviceProxyCustomizations;
178     }
179
180     public void setServiceProxyCustomizations(List<ServiceProxyResourceCustomization> serviceProxyCustomizations) {
181         this.serviceProxyCustomizations = serviceProxyCustomizations;
182     }
183
184     @LinkedResource
185     public List<NetworkResourceCustomization> getNetworkCustomizations() {
186         if (networkCustomizations == null) {
187             networkCustomizations = new ArrayList<>();
188         }
189         return networkCustomizations;
190     }
191
192     public void setNetworkCustomizations(List<NetworkResourceCustomization> networkCustomizations) {
193         this.networkCustomizations = networkCustomizations;
194     }
195
196     @LinkedResource
197     public List<VnfResourceCustomization> getVnfCustomizations() {
198         if (vnfCustomizations == null) {
199             vnfCustomizations = new ArrayList<>();
200         }
201         return vnfCustomizations;
202     }
203
204     public void setVnfCustomizations(List<VnfResourceCustomization> vnfCustomizations) {
205         this.vnfCustomizations = vnfCustomizations;
206     }
207
208     @LinkedResource
209     public List<AllottedResourceCustomization> getAllottedCustomizations() {
210         if (allottedCustomizations == null) {
211             allottedCustomizations = new ArrayList<>();
212         }
213         return allottedCustomizations;
214     }
215
216     public void setAllottedCustomizations(List<AllottedResourceCustomization> allotedCustomizations) {
217         this.allottedCustomizations = allotedCustomizations;
218     }
219
220     @LinkedResource
221     public List<CollectionResourceCustomization> getCollectionResourceCustomizations() {
222         if (collectionResourceCustomizations == null) {
223             collectionResourceCustomizations = new ArrayList<>();
224         }
225         return collectionResourceCustomizations;
226     }
227
228     public void setCollectionResourceCustomizations(
229             List<CollectionResourceCustomization> collectionResourceCustomizations) {
230         this.collectionResourceCustomizations = collectionResourceCustomizations;
231     }
232
233     @LinkedResource
234     public List<ConfigurationResourceCustomization> getConfigurationCustomizations() {
235         if (configurationCustomizations == null) {
236             configurationCustomizations = new ArrayList<>();
237         }
238         return configurationCustomizations;
239     }
240
241     public void setConfigurationCustomizations(List<ConfigurationResourceCustomization> configurationCustomizations) {
242         this.configurationCustomizations = configurationCustomizations;
243     }
244
245     @LinkedResource
246     public List<PnfResourceCustomization> getPnfCustomizations() {
247         if (pnfCustomizations == null) {
248             pnfCustomizations = new ArrayList<>();
249         }
250         return pnfCustomizations;
251     }
252
253     public void setPnfCustomizations(List<PnfResourceCustomization> pnfCustomizations) {
254         this.pnfCustomizations = pnfCustomizations;
255     }
256
257     public String getModelName() {
258         return modelName;
259     }
260
261     public void setModelName(String modelName) {
262         this.modelName = modelName;
263     }
264
265     public String getDescription() {
266         return description;
267     }
268
269     public void setDescription(String description) {
270         this.description = description;
271     }
272
273     @LinkedResource
274     public Map<String, ServiceRecipe> getRecipes() {
275         return recipes;
276     }
277
278     public void setRecipes(Map<String, ServiceRecipe> recipes) {
279         this.recipes = recipes;
280     }
281
282     public Date getCreated() {
283         return created;
284     }
285
286     public String getModelUUID() {
287         return modelUUID;
288     }
289
290     public void setModelUUID(String modelUUID) {
291         this.modelUUID = modelUUID;
292     }
293
294     public String getModelInvariantUUID() {
295         return modelInvariantUUID;
296     }
297
298     public void setModelInvariantUUID(String modelInvariantUUID) {
299         this.modelInvariantUUID = modelInvariantUUID;
300     }
301
302     public String getModelVersion() {
303         return modelVersion;
304     }
305
306     public void setModelVersion(String modelVersion) {
307         this.modelVersion = modelVersion;
308     }
309
310     /**
311      * @return Returns the category.
312      */
313     public String getCategory() {
314         return category;
315     }
316
317     /**
318      * @param category The category to set.
319      */
320     public void setCategory(String category) {
321         this.category = category;
322     }
323
324     public String getServiceType() {
325         return serviceType;
326     }
327
328     public void setServiceType(String serviceType) {
329         this.serviceType = serviceType;
330     }
331
332     public String getServiceRole() {
333         return serviceRole;
334     }
335
336     public void setServiceRole(String serviceRole) {
337         this.serviceRole = serviceRole;
338     }
339
340     public String getEnvironmentContext() {
341         return this.environmentContext;
342     }
343
344     public void setEnvironmentContext(String environmentContext) {
345         this.environmentContext = environmentContext;
346     }
347
348     @LinkedResource
349     public ToscaCsar getCsar() {
350         return csar;
351     }
352
353     public void setCsar(ToscaCsar csar) {
354         this.csar = csar;
355     }
356
357     public String getWorkloadContext() {
358         return this.workloadContext;
359     }
360
361     public void setWorkloadContext(String workloadContext) {
362         this.workloadContext = workloadContext;
363     }
364
365     public String getResourceOrder() {
366         return resourceOrder;
367     }
368
369     public void setResourceOrder(String resourceOrder) {
370         this.resourceOrder = resourceOrder;
371     }
372 }