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.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;
42 @Table(name = "service_recipe")
43 public class ServiceRecipe implements Serializable, Recipe {
45 private static final long serialVersionUID = 768026109321305392L;
52 @Column(name = "SERVICE_MODEL_UUID")
53 private String serviceModelUUID;
56 @Column(name = "ACTION")
57 private String action;
59 @Column(name = "description")
60 private String description;
63 @Column(name = "ORCHESTRATION_URI")
64 private String orchestrationUri;
66 @Column(name = "SERVICE_PARAM_XSD")
67 private String paramXsd;
69 @Column(name = "RECIPE_TIMEOUT")
70 private Integer recipeTimeout;
72 @Column(name = "SERVICE_TIMEOUT_INTERIM")
73 private Integer serviceTimeoutInterim;
75 @Column(name = "CREATION_TIMESTAMP", updatable = false)
76 @Temporal(TemporalType.TIMESTAMP)
80 @ManyToOne(cascade = CascadeType.ALL)
81 @JoinColumn(name = "SERVICE_MODEL_UUID", referencedColumnName = "MODEL_UUID", insertable = false, updatable = false)
82 private Service service;
85 protected void onCreate() {
86 this.created = new Date();
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();
99 public boolean equals(final Object other) {
100 if (!(other instanceof ServiceRecipe)) {
103 ServiceRecipe castOther = (ServiceRecipe) other;
104 return new EqualsBuilder().append(serviceModelUUID, castOther.serviceModelUUID).append(action, castOther.action)
105 .append(orchestrationUri, castOther.orchestrationUri).isEquals();
109 public int hashCode() {
110 return new HashCodeBuilder().append(serviceModelUUID).append(action).append(orchestrationUri).toHashCode();
113 // This 'default' CTR is now needed for backward compatibility since a new
114 // CTR was added below
115 public ServiceRecipe() {
119 public Integer getId() {
123 public void setId(Integer id) {
127 public void setCreated(Date created) {
128 this.created = created;
131 public String getServiceModelUUID() {
132 return serviceModelUUID;
135 public void setServiceModelUUID(String serviceModelUUID) {
136 this.serviceModelUUID = serviceModelUUID;
139 public String getAction() {
143 public void setAction(String action) {
144 this.action = action;
147 public String getDescription() {
151 public void setDescription(String description) {
152 this.description = description;
155 public String getOrchestrationUri() {
156 return orchestrationUri;
159 public void setOrchestrationUri(String orchestrationUri) {
160 this.orchestrationUri = orchestrationUri;
163 public String getParamXsd() {
167 public void setParamXsd(String paramXsd) {
168 this.paramXsd = paramXsd;
171 public Integer getRecipeTimeout() {
172 return recipeTimeout;
175 public void setRecipeTimeout(Integer recipeTimeout) {
176 this.recipeTimeout = recipeTimeout;
179 public Integer getServiceTimeoutInterim() {
180 return serviceTimeoutInterim;
183 public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
184 this.serviceTimeoutInterim = serviceTimeoutInterim;
187 public Service getService() {
191 public void setService(Service service) {
192 this.service = service;
195 public Date getCreated() {