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