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