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