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;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
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;
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
42 import com.openpojo.business.annotation.BusinessKey;
45 @Table(name = "service_recipe")
46 public class ServiceRecipe implements Serializable, Recipe {
48 private static final long serialVersionUID = 768026109321305392L;
55 @Column(name = "SERVICE_MODEL_UUID")
56 private String serviceModelUUID;
59 @Column(name = "ACTION")
60 private String action;
62 @Column(name = "description")
63 private String description;
66 @Column(name = "ORCHESTRATION_URI")
67 private String orchestrationUri;
69 @Column(name = "SERVICE_PARAM_XSD")
70 private String paramXsd;
72 @Column(name = "RECIPE_TIMEOUT")
73 private Integer recipeTimeout;
75 @Column(name = "SERVICE_TIMEOUT_INTERIM")
76 private Integer serviceTimeoutInterim;
78 @Column(name = "CREATION_TIMESTAMP", updatable = false)
79 @Temporal(TemporalType.TIMESTAMP)
83 @ManyToOne(cascade = CascadeType.ALL)
84 @JoinColumn(name = "SERVICE_MODEL_UUID", referencedColumnName = "MODEL_UUID",insertable = false, updatable = false)
85 private Service service;
88 protected void onCreate() {
89 this.created = new Date();
93 public String toString() {
94 return new ToStringBuilder(this).append("id", id).append("serviceModelUUID", serviceModelUUID)
95 .append("action", action).append("description", description)
96 .append("orchestrationUri", orchestrationUri).append("serviceParamXSD", paramXsd)
97 .append("recipeTimeout", recipeTimeout).append("serviceTimeoutInterim", serviceTimeoutInterim)
98 .append("created", created).toString();
102 public boolean equals(final Object other) {
103 if (!(other instanceof ServiceRecipe)) {
106 ServiceRecipe castOther = (ServiceRecipe) other;
107 return new EqualsBuilder().append(serviceModelUUID, castOther.serviceModelUUID).append(action, castOther.action)
108 .append(orchestrationUri, castOther.orchestrationUri).isEquals();
112 public int hashCode() {
113 return new HashCodeBuilder().append(serviceModelUUID).append(action).append(orchestrationUri).toHashCode();
116 // This 'default' CTR is now needed for backward compatibility since a new
117 // CTR was added below
118 public ServiceRecipe() {
122 public Integer getId() {
126 public void setId(Integer id) {
130 public void setCreated(Date created) {
131 this.created = created;
134 public String getServiceModelUUID() {
135 return serviceModelUUID;
138 public void setServiceModelUUID(String serviceModelUUID) {
139 this.serviceModelUUID = serviceModelUUID;
142 public String getAction() {
146 public void setAction(String action) {
147 this.action = action;
150 public String getDescription() {
154 public void setDescription(String description) {
155 this.description = description;
158 public String getOrchestrationUri() {
159 return orchestrationUri;
162 public void setOrchestrationUri(String orchestrationUri) {
163 this.orchestrationUri = orchestrationUri;
166 public String getParamXsd() {
170 public void setParamXsd(String paramXsd) {
171 this.paramXsd = paramXsd;
174 public Integer getRecipeTimeout() {
175 return recipeTimeout;
178 public void setRecipeTimeout(Integer recipeTimeout) {
179 this.recipeTimeout = recipeTimeout;
182 public Integer getServiceTimeoutInterim() {
183 return serviceTimeoutInterim;
186 public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
187 this.serviceTimeoutInterim = serviceTimeoutInterim;
190 public Service getService() {
194 public void setService(Service service) {
195 this.service = service;
198 public Date getCreated() {