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;
29 import javax.persistence.CascadeType;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.JoinTable;
35 import javax.persistence.Lob;
36 import javax.persistence.OneToMany;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44 import com.openpojo.business.annotation.BusinessKey;
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
48 @Table(name = "heat_template")
49 public class HeatTemplate implements Serializable {
51 private static final long serialVersionUID = 768026109321305392L;
55 @Column(name = "ARTIFACT_UUID", length = 200)
56 private String artifactUuid;
58 @Column(name = "NAME", length = 200)
59 private String templateName;
62 @Column(name = "BODY", columnDefinition = "LONGTEXT")
63 private String templateBody = null;
65 @Column(name = "TIMEOUT_MINUTES", length = 20)
66 private Integer timeoutMinutes;
69 @Column(name = "VERSION")
70 private String version;
72 @Column(name = "DESCRIPTION", length = 1200)
73 private String description;
75 @Column(name = "ARTIFACT_CHECKSUM", length = 200)
76 private String artifactChecksum;
78 @Column(name = "CREATION_TIMESTAMP", updatable = false)
79 @Temporal(TemporalType.TIMESTAMP)
82 @OneToMany(cascade = CascadeType.ALL, mappedBy = "heatTemplateArtifactUuid")
83 private Set<HeatTemplateParam> parameters;
85 @OneToMany(cascade = CascadeType.ALL)
86 @JoinTable(name = "heat_nested_template", joinColumns = @JoinColumn(name = "PARENT_HEAT_TEMPLATE_UUID"),
87 inverseJoinColumns = @JoinColumn(name = "CHILD_HEAT_TEMPLATE_UUID"))
88 private List<HeatTemplate> childTemplates;
90 public enum TemplateStatus {
91 PARENT, CHILD, PARENT_COMPLETE
95 protected void onCreate() {
96 this.created = new Date();
100 public String toString() {
101 return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("templateName", templateName)
102 .append("templateBody", templateBody).append("timeoutMinutes", timeoutMinutes)
103 .append("version", version).append("description", description)
104 .append("artifactChecksum", artifactChecksum).append("created", created)
105 .append("parameters", parameters).append("childTemplates", childTemplates).toString();
109 public boolean equals(final Object other) {
110 if (!(other instanceof HeatTemplate)) {
113 HeatTemplate castOther = (HeatTemplate) other;
114 return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version)
119 public int hashCode() {
120 return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode();
124 public List<HeatTemplate> getChildTemplates() {
125 if (childTemplates == null)
126 childTemplates = new ArrayList<>();
127 return childTemplates;
130 public void setChildTemplates(List<HeatTemplate> childTemplates) {
131 this.childTemplates = childTemplates;
134 public String getVersion() {
138 public void setVersion(String version) {
139 this.version = version;
142 public String getArtifactUuid() {
143 return this.artifactUuid;
146 public void setArtifactUuid(String artifactUuid) {
147 this.artifactUuid = artifactUuid;
150 public String getTemplateName() {
154 public void setTemplateName(String templateName) {
155 this.templateName = templateName;
158 public String getTemplateBody() {
162 public void setTemplateBody(String templateBody) {
163 this.templateBody = templateBody;
166 public Integer getTimeoutMinutes() {
167 return timeoutMinutes;
170 public void setTimeoutMinutes(Integer timeout) {
171 this.timeoutMinutes = timeout;
175 public Set<HeatTemplateParam> getParameters() {
176 if (parameters == null)
177 parameters = new HashSet<>();
181 public void setParameters(Set<HeatTemplateParam> parameters) {
182 this.parameters = parameters;
185 public String getDescription() {
189 public void setDescription(String description) {
190 this.description = description;
193 public String getHeatTemplate() {
194 return this.templateBody;
197 public String getArtifactChecksum() {
198 return artifactChecksum;
201 public void setArtifactChecksum(String artifactChecksum) {
202 this.artifactChecksum = artifactChecksum;
205 public Date getCreated() {