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.ArrayList;
25 import java.util.Date;
26 import java.util.HashSet;
27 import java.util.List;
30 import javax.persistence.CascadeType;
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.JoinTable;
36 import javax.persistence.Lob;
37 import javax.persistence.OneToMany;
38 import javax.persistence.PrePersist;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
43 import org.apache.commons.lang3.builder.EqualsBuilder;
44 import org.apache.commons.lang3.builder.HashCodeBuilder;
45 import org.apache.commons.lang3.builder.ToStringBuilder;
47 import com.openpojo.business.annotation.BusinessKey;
49 import uk.co.blackpepper.bowman.annotation.LinkedResource;
52 @Table(name = "heat_template")
53 public class HeatTemplate implements Serializable {
55 private static final long serialVersionUID = 768026109321305392L;
59 @Column(name = "ARTIFACT_UUID", length = 200)
60 private String artifactUuid;
62 @Column(name = "NAME", length = 200)
63 private String templateName;
66 @Column(name = "BODY", columnDefinition = "LONGTEXT")
67 private String templateBody = null;
69 @Column(name = "TIMEOUT_MINUTES", length = 20)
70 private Integer timeoutMinutes;
73 @Column(name = "VERSION")
74 private String version;
76 @Column(name = "DESCRIPTION", length = 1200)
77 private String description;
79 @Column(name = "ARTIFACT_CHECKSUM", length = 200)
80 private String artifactChecksum;
82 @Column(name = "CREATION_TIMESTAMP", updatable = false)
83 @Temporal(TemporalType.TIMESTAMP)
86 @OneToMany(cascade = CascadeType.ALL, mappedBy = "heatTemplateArtifactUuid")
87 private Set<HeatTemplateParam> parameters;
89 @OneToMany(cascade = CascadeType.ALL)
90 @JoinTable(name = "heat_nested_template", joinColumns = @JoinColumn(name = "PARENT_HEAT_TEMPLATE_UUID"), inverseJoinColumns = @JoinColumn(name = "CHILD_HEAT_TEMPLATE_UUID"))
91 private List<HeatTemplate> childTemplates;
93 public enum TemplateStatus {
94 PARENT, CHILD, PARENT_COMPLETE
98 protected void onCreate() {
99 this.created = new Date();
103 public String toString() {
104 return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("templateName", templateName)
105 .append("templateBody", templateBody).append("timeoutMinutes", timeoutMinutes)
106 .append("version", version).append("description", description)
107 .append("artifactChecksum", artifactChecksum).append("created", created)
108 .append("parameters", parameters).append("childTemplates", childTemplates).toString();
112 public boolean equals(final Object other) {
113 if (!(other instanceof HeatTemplate)) {
116 HeatTemplate castOther = (HeatTemplate) other;
117 return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version)
122 public int hashCode() {
123 return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode();
127 public List<HeatTemplate> getChildTemplates() {
128 if (childTemplates == null)
129 childTemplates = new ArrayList<>();
130 return childTemplates;
133 public void setChildTemplates(List<HeatTemplate> childTemplates) {
134 this.childTemplates = childTemplates;
137 public String getVersion() {
141 public void setVersion(String version) {
142 this.version = version;
145 public String getArtifactUuid() {
146 return this.artifactUuid;
149 public void setArtifactUuid(String artifactUuid) {
150 this.artifactUuid = artifactUuid;
153 public String getTemplateName() {
157 public void setTemplateName(String templateName) {
158 this.templateName = templateName;
161 public String getTemplateBody() {
165 public void setTemplateBody(String templateBody) {
166 this.templateBody = templateBody;
169 public Integer getTimeoutMinutes() {
170 return timeoutMinutes;
173 public void setTimeoutMinutes(Integer timeout) {
174 this.timeoutMinutes = timeout;
178 public Set<HeatTemplateParam> getParameters() {
179 if (parameters == null)
180 parameters = new HashSet<>();
184 public void setParameters(Set<HeatTemplateParam> parameters) {
185 this.parameters = parameters;
188 public String getDescription() {
192 public void setDescription(String description) {
193 this.description = description;
196 public String getHeatTemplate() {
197 return this.templateBody;
200 public String getArtifactChecksum() {
201 return artifactChecksum;
204 public void setArtifactChecksum(String artifactChecksum) {
205 this.artifactChecksum = artifactChecksum;
208 public Date getCreated() {