[SO] Release so 1.13.0 image
[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 javax.persistence.CascadeType;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.JoinTable;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.MapKey;
36 import javax.persistence.OneToMany;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44 import com.fasterxml.jackson.annotation.JsonFormat;
45 import com.openpojo.business.annotation.BusinessKey;
46 import uk.co.blackpepper.bowman.annotation.LinkedResource;
47 import uk.co.blackpepper.bowman.annotation.RemoteResource;
48
49 @Entity
50 @RemoteResource("/service")
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 = "SERVICE_FUNCTION")
85     private String serviceFunction;
86
87     @Column(name = "ENVIRONMENT_CONTEXT")
88     private String environmentContext;
89
90     @Column(name = "WORKLOAD_CONTEXT")
91     private String workloadContext;
92
93     @Column(name = "SERVICE_CATEGORY")
94     private String category;
95
96     @Column(name = "RESOURCE_ORDER")
97     private String resourceOrder;
98
99     @Column(name = "OVERALL_DISTRIBUTION_STATUS")
100     private String distrobutionStatus;
101
102     @OneToMany(cascade = CascadeType.ALL)
103     @JoinTable(name = "network_resource_customization_to_service",
104             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
105             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
106     private List<NetworkResourceCustomization> networkCustomizations;
107
108     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
109     private List<VnfResourceCustomization> vnfCustomizations;
110
111     @OneToMany(cascade = CascadeType.ALL)
112     @JoinTable(name = "allotted_resource_customization_to_service",
113             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
114             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
115     private List<AllottedResourceCustomization> allottedCustomizations;
116
117     @OneToMany(cascade = CascadeType.ALL)
118     @JoinTable(name = "collection_resource_customization_to_service",
119             joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
120             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
121     private List<CollectionResourceCustomization> collectionResourceCustomizations;
122
123     @OneToMany(cascade = CascadeType.ALL)
124     @JoinTable(name = "service_proxy_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
125             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
126     private List<ServiceProxyResourceCustomization> serviceProxyCustomizations;
127
128     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
129     private List<ConfigurationResourceCustomization> configurationCustomizations;
130
131     @OneToMany(cascade = CascadeType.ALL)
132     @JoinTable(name = "pnf_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"),
133             inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
134     private List<PnfResourceCustomization> pnfCustomizations;
135
136     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
137     @MapKey(name = "action")
138     private Map<String, ServiceRecipe> recipes;
139
140     @ManyToOne(cascade = CascadeType.ALL)
141     @JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID")
142     private ToscaCsar csar;
143
144     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
145     private List<ServiceArtifact> serviceArtifactList;
146
147     @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
148     private List<ServiceInfo> serviceInfos;
149
150     @Column(name = "NAMING_POLICY")
151     private String namingPolicy;
152
153     @Column(name = "ONAP_GENERATED_NAMING")
154     private Boolean onapGeneratedNaming;
155
156     @Column(name = "CDS_BLUEPRINT_NAME")
157     private String blueprintName;
158
159     @Column(name = "CDS_BLUEPRINT_VERSION")
160     private String blueprintVersion;
161
162     @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION", nullable = false)
163     private Boolean skipPostInstConf = true;
164
165     @Column(name = "CONTROLLER_ACTOR")
166     private String controllerActor;
167
168     @Override
169     public String toString() {
170         return new ToStringBuilder(this).append("modelName", modelName).append("description", description)
171                 .append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
172                 .append("created", created).append("modelVersion", modelVersion).append("serviceType", serviceType)
173                 .append("serviceRole", serviceRole).append("environmentContext", environmentContext)
174                 .append("workloadContext", workloadContext).append("category", category)
175                 .append("networkCustomizations", networkCustomizations).append("vnfCustomizations", vnfCustomizations)
176                 .append("allottedCustomizations", allottedCustomizations)
177                 .append("collectionResourceCustomizations", collectionResourceCustomizations)
178                 .append("serviceProxyCustomizations", serviceProxyCustomizations)
179                 .append("configurationCustomizations", configurationCustomizations)
180                 .append("pnfCustomizations", pnfCustomizations).append("recipes", recipes).append("csar", csar)
181                 .append("namingPolicy", namingPolicy).append("onapGeneratedNaming", onapGeneratedNaming).toString();
182     }
183
184     @PrePersist
185     protected void onCreate() {
186         this.created = new Date();
187     }
188
189     @Override
190     public boolean equals(final Object other) {
191         if (!(other instanceof Service)) {
192             return false;
193         }
194         Service castOther = (Service) other;
195         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
196     }
197
198     @Override
199     public int hashCode() {
200         return new HashCodeBuilder().append(modelUUID).toHashCode();
201     }
202
203     @LinkedResource
204     public List<ServiceProxyResourceCustomization> getServiceProxyCustomizations() {
205         return serviceProxyCustomizations;
206     }
207
208     public void setServiceProxyCustomizations(List<ServiceProxyResourceCustomization> serviceProxyCustomizations) {
209         this.serviceProxyCustomizations = serviceProxyCustomizations;
210     }
211
212     @LinkedResource
213     public List<NetworkResourceCustomization> getNetworkCustomizations() {
214         if (networkCustomizations == null) {
215             networkCustomizations = new ArrayList<>();
216         }
217         return networkCustomizations;
218     }
219
220     public void setNetworkCustomizations(List<NetworkResourceCustomization> networkCustomizations) {
221         this.networkCustomizations = networkCustomizations;
222     }
223
224     @LinkedResource
225     public List<VnfResourceCustomization> getVnfCustomizations() {
226         if (vnfCustomizations == null) {
227             vnfCustomizations = new ArrayList<>();
228         }
229         return vnfCustomizations;
230     }
231
232     public void setVnfCustomizations(List<VnfResourceCustomization> vnfCustomizations) {
233         this.vnfCustomizations = vnfCustomizations;
234     }
235
236     @LinkedResource
237     public List<AllottedResourceCustomization> getAllottedCustomizations() {
238         if (allottedCustomizations == null) {
239             allottedCustomizations = new ArrayList<>();
240         }
241         return allottedCustomizations;
242     }
243
244     public void setAllottedCustomizations(List<AllottedResourceCustomization> allotedCustomizations) {
245         this.allottedCustomizations = allotedCustomizations;
246     }
247
248     @LinkedResource
249     public List<CollectionResourceCustomization> getCollectionResourceCustomizations() {
250         if (collectionResourceCustomizations == null) {
251             collectionResourceCustomizations = new ArrayList<>();
252         }
253         return collectionResourceCustomizations;
254     }
255
256     public void setCollectionResourceCustomizations(
257             List<CollectionResourceCustomization> collectionResourceCustomizations) {
258         this.collectionResourceCustomizations = collectionResourceCustomizations;
259     }
260
261     @LinkedResource
262     public List<ConfigurationResourceCustomization> getConfigurationCustomizations() {
263         if (configurationCustomizations == null) {
264             configurationCustomizations = new ArrayList<>();
265         }
266         return configurationCustomizations;
267     }
268
269     public void setConfigurationCustomizations(List<ConfigurationResourceCustomization> configurationCustomizations) {
270         this.configurationCustomizations = configurationCustomizations;
271     }
272
273     @LinkedResource
274     public List<PnfResourceCustomization> getPnfCustomizations() {
275         if (pnfCustomizations == null) {
276             pnfCustomizations = new ArrayList<>();
277         }
278         return pnfCustomizations;
279     }
280
281     public void setPnfCustomizations(List<PnfResourceCustomization> pnfCustomizations) {
282         this.pnfCustomizations = pnfCustomizations;
283     }
284
285     public String getModelName() {
286         return modelName;
287     }
288
289     public void setModelName(String modelName) {
290         this.modelName = modelName;
291     }
292
293     public String getDescription() {
294         return description;
295     }
296
297     public void setDescription(String description) {
298         this.description = description;
299     }
300
301     @LinkedResource
302     public Map<String, ServiceRecipe> getRecipes() {
303         return recipes;
304     }
305
306     public void setRecipes(Map<String, ServiceRecipe> recipes) {
307         this.recipes = recipes;
308     }
309
310     public Date getCreated() {
311         return created;
312     }
313
314     public String getModelUUID() {
315         return modelUUID;
316     }
317
318     public void setModelUUID(String modelUUID) {
319         this.modelUUID = modelUUID;
320     }
321
322     public String getModelInvariantUUID() {
323         return modelInvariantUUID;
324     }
325
326     public void setModelInvariantUUID(String modelInvariantUUID) {
327         this.modelInvariantUUID = modelInvariantUUID;
328     }
329
330     public String getModelVersion() {
331         return modelVersion;
332     }
333
334     public void setModelVersion(String modelVersion) {
335         this.modelVersion = modelVersion;
336     }
337
338     /**
339      * @return Returns the category.
340      */
341     public String getCategory() {
342         return category;
343     }
344
345     /**
346      * @param category The category to set.
347      */
348     public void setCategory(String category) {
349         this.category = category;
350     }
351
352     public String getServiceType() {
353         return serviceType;
354     }
355
356     public void setServiceType(String serviceType) {
357         this.serviceType = serviceType;
358     }
359
360     public String getServiceRole() {
361         return serviceRole;
362     }
363
364     public void setServiceRole(String serviceRole) {
365         this.serviceRole = serviceRole;
366     }
367
368     public String getEnvironmentContext() {
369         return this.environmentContext;
370     }
371
372     public void setEnvironmentContext(String environmentContext) {
373         this.environmentContext = environmentContext;
374     }
375
376     @LinkedResource
377     public ToscaCsar getCsar() {
378         return csar;
379     }
380
381     public void setCsar(ToscaCsar csar) {
382         this.csar = csar;
383     }
384
385     public List<ServiceArtifact> getServiceArtifactList() {
386         if (serviceArtifactList == null) {
387             serviceArtifactList = new ArrayList<>();
388         }
389         return serviceArtifactList;
390     }
391
392     public void setServiceArtifactList(List<ServiceArtifact> serviceArtifactList) {
393         this.serviceArtifactList = serviceArtifactList;
394     }
395
396     public List<ServiceInfo> getServiceInfos() {
397         if (serviceInfos == null) {
398             serviceInfos = new ArrayList<>();
399         }
400         return serviceInfos;
401     }
402
403     public void setServiceInfos(List<ServiceInfo> serviceInfos) {
404         this.serviceInfos = serviceInfos;
405     }
406
407     public String getWorkloadContext() {
408         return this.workloadContext;
409     }
410
411     public void setWorkloadContext(String workloadContext) {
412         this.workloadContext = workloadContext;
413     }
414
415     public String getResourceOrder() {
416         return resourceOrder;
417     }
418
419     public void setResourceOrder(String resourceOrder) {
420         this.resourceOrder = resourceOrder;
421     }
422
423     public String getDistrobutionStatus() {
424         return distrobutionStatus;
425     }
426
427     public void setDistrobutionStatus(String distrobutionStatus) {
428         this.distrobutionStatus = distrobutionStatus;
429     }
430
431     public String getNamingPolicy() {
432         return namingPolicy;
433     }
434
435     public void setNamingPolicy(String namingPolicy) {
436         this.namingPolicy = namingPolicy;
437     }
438
439     public Boolean getOnapGeneratedNaming() {
440         return onapGeneratedNaming;
441     }
442
443     public void setOnapGeneratedNaming(Boolean onapGeneratedNaming) {
444         this.onapGeneratedNaming = onapGeneratedNaming;
445     }
446
447     public String getBlueprintName() {
448         return blueprintName;
449     }
450
451     public void setBlueprintName(String blueprintName) {
452         this.blueprintName = blueprintName;
453     }
454
455     public String getBlueprintVersion() {
456         return blueprintVersion;
457     }
458
459     public void setBlueprintVersion(String blueprintVersion) {
460         this.blueprintVersion = blueprintVersion;
461     }
462
463     public Boolean getSkipPostInstConf() {
464         return skipPostInstConf;
465     }
466
467     public void setSkipPostInstConf(Boolean skipPostInstConf) {
468         this.skipPostInstConf = skipPostInstConf;
469     }
470
471     public String getControllerActor() {
472         return controllerActor;
473     }
474
475     public void setControllerActor(String controllerActor) {
476         this.controllerActor = controllerActor;
477     }
478
479     public String getServiceFunction() {
480         return serviceFunction;
481     }
482
483     public void setServiceFunction(String serviceFunction) {
484         this.serviceFunction = serviceFunction;
485     }
486
487 }