2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.catalog.beans;
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;
44 @RemoteResource("/serviceRecipe")
45 @Table(name = "service_recipe")
46 public class ServiceRecipe implements Serializable, Recipe {
48 private static final long serialVersionUID = 768026109321305392L;
52 @GeneratedValue(strategy = GenerationType.IDENTITY)
56 @Column(name = "SERVICE_MODEL_UUID")
57 private String serviceModelUUID;
60 @Column(name = "ACTION")
61 private String action;
63 @Column(name = "description")
64 private String description;
67 @Column(name = "ORCHESTRATION_URI")
68 private String orchestrationUri;
70 @Column(name = "SERVICE_PARAM_XSD")
71 private String paramXsd;
73 @Column(name = "RECIPE_TIMEOUT")
74 private Integer recipeTimeout;
76 @Column(name = "SERVICE_TIMEOUT_INTERIM")
77 private Integer serviceTimeoutInterim;
79 @Column(name = "CREATION_TIMESTAMP", updatable = false)
80 @Temporal(TemporalType.TIMESTAMP)
84 @ManyToOne(cascade = CascadeType.ALL)
85 @JoinColumn(name = "SERVICE_MODEL_UUID", referencedColumnName = "MODEL_UUID", insertable = false, updatable = false)
86 private Service service;
89 protected void onCreate() {
90 this.created = new Date();
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();
103 public boolean equals(final Object other) {
104 if (!(other instanceof ServiceRecipe)) {
107 ServiceRecipe castOther = (ServiceRecipe) other;
108 return new EqualsBuilder().append(serviceModelUUID, castOther.serviceModelUUID).append(action, castOther.action)
109 .append(orchestrationUri, castOther.orchestrationUri).isEquals();
113 public int hashCode() {
114 return new HashCodeBuilder().append(serviceModelUUID).append(action).append(orchestrationUri).toHashCode();
117 // This 'default' CTR is now needed for backward compatibility since a new
118 // CTR was added below
119 public ServiceRecipe() {
124 public Integer getId() {
128 public void setId(Integer id) {
132 public void setCreated(Date created) {
133 this.created = created;
136 public String getServiceModelUUID() {
137 return serviceModelUUID;
140 public void setServiceModelUUID(String serviceModelUUID) {
141 this.serviceModelUUID = serviceModelUUID;
145 public String getAction() {
149 public void setAction(String action) {
150 this.action = action;
154 public String getDescription() {
158 public void setDescription(String description) {
159 this.description = description;
163 public String getOrchestrationUri() {
164 return orchestrationUri;
167 public void setOrchestrationUri(String orchestrationUri) {
168 this.orchestrationUri = orchestrationUri;
172 public String getParamXsd() {
176 public void setParamXsd(String paramXsd) {
177 this.paramXsd = paramXsd;
181 public Integer getRecipeTimeout() {
182 return recipeTimeout;
185 public void setRecipeTimeout(Integer recipeTimeout) {
186 this.recipeTimeout = recipeTimeout;
189 public Integer getServiceTimeoutInterim() {
190 return serviceTimeoutInterim;
193 public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
194 this.serviceTimeoutInterim = serviceTimeoutInterim;
197 public Service getService() {
201 public void setService(Service service) {
202 this.service = service;
205 public Date getCreated() {