763c304a0fe5d315354e47f97811c0df36553d9a
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / ServiceRecipe.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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.openecomp.mso.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.sql.Timestamp;
25 import java.text.DateFormat;
26 import java.util.Date;
27
28 import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
29 import org.openecomp.mso.logger.MsoLogger;
30
31 public class ServiceRecipe extends MavenLikeVersioning implements Serializable {
32         
33         private static final long serialVersionUID = 768026109321305392L;
34         
35         private int id;
36         private String serviceModelUUID;
37         private String action;
38         private String description;
39         private String orchestrationUri;
40         private String serviceParamXSD;
41         private int recipeTimeout;
42         private Integer serviceTimeoutInterim;
43         private Timestamp created;
44
45         private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
46         
47         // This 'default' CTR is now needed for backward compatibility since a new CTR was added below
48         public ServiceRecipe() {
49                 super();
50         }
51         
52         // This CTR is needed by the HQL SELECT JOIN between the SERVICE and SERVICE_RECIPE tables
53         // in CatalogDatabase::getServiceRecipe()
54         public ServiceRecipe(int id, String serviceModelUUID, String action,
55                         String description, String orchestrationUri,
56                         String serviceParamXSD, int recipeTimeout,
57                         int serviceTimeoutInterim, Date created) {
58                 super();
59                 LOGGER.debug("ServiceRecipe id=" + id + ", serviceModelUUID=" + serviceModelUUID + ", action=" + action + ", description=" + description +
60                                 ", orchestrationUri=" + orchestrationUri + ", serviceParamXSD=" + serviceParamXSD +
61                                 ", recipeTimeout=" + recipeTimeout + ", serviceTimeoutInterim=" + serviceTimeoutInterim + ", created=" + created);
62                 this.id = id;
63                 this.serviceModelUUID = serviceModelUUID;
64                 this.action = action;
65                 this.description = description;
66                 this.orchestrationUri = orchestrationUri;
67                 this.serviceParamXSD = serviceParamXSD;
68                 this.recipeTimeout = recipeTimeout;
69                 this.serviceTimeoutInterim = serviceTimeoutInterim;
70                 long date = created.getTime();
71                 this.created = new Timestamp(date);
72         }
73
74         public int getId() {
75                 return id;
76         }
77         public void setId(int id) {
78                 this.id = id;
79         }
80
81         public String getServiceModelUUID() {
82                 return serviceModelUUID;
83         }
84         public void setServiceModelUUID(String serviceModelUUID) {
85                 this.serviceModelUUID = serviceModelUUID;
86         }
87
88         public String getAction() {
89                 return action;
90         }
91         public void setAction(String action) {
92                 this.action = action;
93         }
94
95         public String getDescription() {
96                 return description;
97         }
98         public void setDescription(String description) {
99                 this.description = description;
100         }
101
102         public String getOrchestrationUri() {
103                 return orchestrationUri;
104         }
105         public void setOrchestrationUri(String orchestrationUri) {
106                 this.orchestrationUri = orchestrationUri;
107         }
108
109         public String getServiceParamXSD() {
110                 return serviceParamXSD;
111         }
112         public void setServiceParamXSD(String serviceParamXSD) {
113                 this.serviceParamXSD = serviceParamXSD;
114         }
115
116         public int getRecipeTimeout() {
117                 return recipeTimeout;
118         }
119         public void setRecipeTimeout(int recipeTimeout) {
120                 this.recipeTimeout = recipeTimeout;
121         }
122
123         public Integer getServiceTimeoutInterim() {
124                 return serviceTimeoutInterim;
125         }
126
127         public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
128                 this.serviceTimeoutInterim = serviceTimeoutInterim;
129         }
130         
131         public Timestamp getCreated() {
132                 return created;
133         }
134
135         public void setCreated(Timestamp created) {
136                 this.created = created;
137         }
138
139         @Override
140         public String toString() {
141                 StringBuilder sb = new StringBuilder();
142                 sb.append("RECIPE: " + action);
143                 sb.append(",uri=" + orchestrationUri);
144         if (created != null) {
145                 sb.append (",created=");
146                 sb.append (DateFormat.getInstance().format(created));
147             }
148                 return sb.toString();
149         }
150 }