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