Change the header to SO
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / HeatTemplate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.Set;
27
28 import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
29 import org.openecomp.mso.logger.MsoLogger;
30
31 public class HeatTemplate extends MavenLikeVersioning implements Serializable {
32         
33         private static final long serialVersionUID = 768026109321305392L;
34
35     private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
36
37     private String artifactUuid;
38     private String templateName;
39     private String templateBody = null;
40     private int timeoutMinutes;
41     private Set <HeatTemplateParam> parameters;
42     private Set <HeatNestedTemplate> files;
43     private String description;
44     private String asdcUuid;
45     private String artifactChecksum;
46
47     private Timestamp created;
48
49     public enum TemplateStatus {
50                                 PARENT, CHILD, PARENT_COMPLETE
51     }
52
53     public HeatTemplate () {
54     }
55
56     public String getArtifactUuid() {
57         return this.artifactUuid;
58     }
59
60     public void setArtifactUuid (String artifactUuid) {
61         this.artifactUuid = artifactUuid;
62     }
63
64     public String getTemplateName () {
65         return templateName;
66     }
67
68     public void setTemplateName (String templateName) {
69         this.templateName = templateName;
70     }
71
72     public String getTemplateBody () {
73         return templateBody;
74     }
75
76     public void setTemplateBody (String templateBody) {
77         this.templateBody = templateBody;
78     }
79
80     public int getTimeoutMinutes () {
81         return timeoutMinutes;
82     }
83
84     public void setTimeoutMinutes (int timeout) {
85         this.timeoutMinutes = timeout;
86     }
87
88     public Set <HeatTemplateParam> getParameters () {
89         return parameters;
90     }
91
92     public void setParameters (Set <HeatTemplateParam> parameters) {
93         this.parameters = parameters;
94     }
95
96     public String getDescription() {
97                 return description;
98         }
99
100         public void setDescription(String description) {
101                 this.description = description;
102         }
103
104         public String getHeatTemplate () {
105                 return this.templateBody;
106     }
107
108     public void setFiles (Set <HeatNestedTemplate> files) {
109         this.files = files;
110     }
111
112     public Set <HeatNestedTemplate> getFiles () {
113         return this.files;
114     }
115
116         public String getAsdcUuid() {
117                 return asdcUuid;
118         }
119
120         public void setAsdcUuid(String asdcUuidp) {
121                 this.asdcUuid = asdcUuidp;
122         }
123
124     public String getArtifactChecksum() {
125         return artifactChecksum;
126     }
127
128     public void setArtifactChecksum(String artifactChecksum) {
129         this.artifactChecksum = artifactChecksum;
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         String body = (templateBody != null) ? "(" + templateBody.length () + " chars)" : "(Not defined)";
143         StringBuilder sb = new StringBuilder ();
144         sb.append ("Template=")
145           .append (templateName)
146           .append (",version=")
147           .append (version)
148           .append (",body=")
149           .append (body)
150           .append (",timeout=")
151           .append (timeoutMinutes)
152           .append (",asdcUuid=")
153           .append (asdcUuid)
154           .append (",description=")
155           .append (description);
156         if (created != null) {
157                 sb.append (",created=");
158                 sb.append (DateFormat.getInstance().format(created));
159         }
160
161
162         if (parameters != null && !parameters.isEmpty ()) {
163             sb.append (",params=[");
164             for (HeatTemplateParam param : parameters) {
165                 sb.append (param.getParamName ());
166                 if (param.isRequired ()) {
167                     sb.append ("(reqd)");
168                 }
169                 sb.append (",");
170             }
171             sb.replace (sb.length () - 1, sb.length (), "]");
172         }
173         return sb.toString ();
174     }
175
176
177 }