Containerization feature of SO
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ServiceRecipe.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.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.PrePersist;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37
38 import com.openpojo.business.annotation.BusinessKey;
39
40 @Entity
41 @Table(name = "service_recipe")
42 public class ServiceRecipe implements Serializable, Recipe {
43         
44         private static final long serialVersionUID = 768026109321305392L;
45
46         @Id
47         @Column(name = "id")
48         private Integer id;
49
50         @BusinessKey
51         @Column(name = "SERVICE_MODEL_UUID")
52         private String serviceModelUUID;
53
54         @BusinessKey
55         @Column(name = "ACTION")
56         private String action;
57
58         @Column(name = "description")
59         private String description;
60
61         @BusinessKey
62         @Column(name = "ORCHESTRATION_URI")
63         private String orchestrationUri;
64
65         @Column(name = "SERVICE_PARAM_XSD")
66         private String paramXsd;
67
68         @Column(name = "RECIPE_TIMEOUT")
69         private Integer recipeTimeout;
70
71         @Column(name = "SERVICE_TIMEOUT_INTERIM")
72         private Integer serviceTimeoutInterim;
73
74         @Column(name = "CREATION_TIMESTAMP", updatable = false)
75         @Temporal(TemporalType.TIMESTAMP)
76         private Date created;
77
78         @PrePersist
79         protected void onCreate() {
80                 this.created = new Date();
81         }
82
83         @Override
84         public String toString() {
85                 return new ToStringBuilder(this).append("id", id).append("serviceModelUUID", serviceModelUUID)
86                                 .append("action", action).append("description", description)
87                                 .append("orchestrationUri", orchestrationUri).append("serviceParamXSD", paramXsd)
88                                 .append("recipeTimeout", recipeTimeout).append("serviceTimeoutInterim", serviceTimeoutInterim)
89                                 .append("created", created).toString();
90         }
91
92         @Override
93         public boolean equals(final Object other) {
94                 if (!(other instanceof ServiceRecipe)) {
95                         return false;
96                 }
97                 ServiceRecipe castOther = (ServiceRecipe) other;
98                 return new EqualsBuilder().append(serviceModelUUID, castOther.serviceModelUUID).append(action, castOther.action)
99                                 .append(orchestrationUri, castOther.orchestrationUri).isEquals();
100         }
101
102         @Override
103         public int hashCode() {
104                 return new HashCodeBuilder().append(serviceModelUUID).append(action).append(orchestrationUri).toHashCode();
105         }
106
107         // This 'default' CTR is now needed for backward compatibility since a new
108         // CTR was added below
109         public ServiceRecipe() {
110                 super();
111         }
112
113         public Integer getId() {
114                 return id;
115         }
116
117         public void setId(Integer id) {
118                 this.id = id;
119         }
120
121         public void setCreated(Date created) {
122                 this.created = created;
123         }
124
125         public String getServiceModelUUID() {
126                 return serviceModelUUID;
127         }
128
129         public void setServiceModelUUID(String serviceModelUUID) {
130                 this.serviceModelUUID = serviceModelUUID;
131         }
132
133         public String getAction() {
134                 return action;
135         }
136
137         public void setAction(String action) {
138                 this.action = action;
139         }
140
141         public String getDescription() {
142                 return description;
143         }
144
145         public void setDescription(String description) {
146                 this.description = description;
147         }
148
149         public String getOrchestrationUri() {
150                 return orchestrationUri;
151         }
152
153         public void setOrchestrationUri(String orchestrationUri) {
154                 this.orchestrationUri = orchestrationUri;
155         }
156
157         public String getParamXsd() {
158                 return paramXsd;
159         }
160
161         public void setParamXsd(String paramXsd) {
162                 this.paramXsd = paramXsd;
163         }
164
165         public Integer getRecipeTimeout() {
166                 return recipeTimeout;
167         }
168
169         public void setRecipeTimeout(Integer recipeTimeout) {
170                 this.recipeTimeout = recipeTimeout;
171         }
172
173         public Integer getServiceTimeoutInterim() {
174                 return serviceTimeoutInterim;
175         }
176
177         public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
178                 this.serviceTimeoutInterim = serviceTimeoutInterim;
179         }
180
181         public Date getCreated() {
182                 return created;
183         }
184 }