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;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
49 @RemoteResource("/heatTemplate")
50 @Table(name = "heat_template")
51 public class HeatTemplate implements Serializable {
53 private static final long serialVersionUID = 768026109321305392L;
57 @Column(name = "ARTIFACT_UUID", length = 200)
58 private String artifactUuid;
60 @Column(name = "NAME", length = 200)
61 private String templateName;
64 @Column(name = "BODY", columnDefinition = "LONGTEXT")
65 private String templateBody = null;
67 @Column(name = "TIMEOUT_MINUTES", length = 20)
68 private Integer timeoutMinutes;
71 @Column(name = "VERSION")
72 private String version;
74 @Column(name = "DESCRIPTION", length = 1200)
75 private String description;
77 @Column(name = "ARTIFACT_CHECKSUM", length = 200)
78 private String artifactChecksum;
80 @Column(name = "CREATION_TIMESTAMP", updatable = false)
81 @Temporal(TemporalType.TIMESTAMP)
84 @OneToMany(cascade = CascadeType.ALL, mappedBy = "heatTemplateArtifactUuid")
85 private Set<HeatTemplateParam> parameters;
87 @OneToMany(cascade = CascadeType.ALL)
88 @JoinTable(name = "heat_nested_template", joinColumns = @JoinColumn(name = "PARENT_HEAT_TEMPLATE_UUID"),
89 inverseJoinColumns = @JoinColumn(name = "CHILD_HEAT_TEMPLATE_UUID"))
90 private List<HeatTemplate> childTemplates;
92 public enum TemplateStatus {
93 PARENT, CHILD, PARENT_COMPLETE
97 protected void onCreate() {
98 this.created = new Date();
102 public String toString() {
103 return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("templateName", templateName)
104 .append("templateBody", templateBody).append("timeoutMinutes", timeoutMinutes)
105 .append("version", version).append("description", description)
106 .append("artifactChecksum", artifactChecksum).append("created", created)
107 .append("parameters", parameters).append("childTemplates", childTemplates).toString();
111 public boolean equals(final Object other) {
112 if (!(other instanceof HeatTemplate)) {
115 HeatTemplate castOther = (HeatTemplate) other;
116 return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version)
121 public int hashCode() {
122 return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode();
126 public List<HeatTemplate> getChildTemplates() {
127 if (childTemplates == null)
128 childTemplates = new ArrayList<>();
129 return childTemplates;
132 public void setChildTemplates(List<HeatTemplate> childTemplates) {
133 this.childTemplates = childTemplates;
136 public String getVersion() {
140 public void setVersion(String version) {
141 this.version = version;
144 public String getArtifactUuid() {
145 return this.artifactUuid;
148 public void setArtifactUuid(String artifactUuid) {
149 this.artifactUuid = artifactUuid;
152 public String getTemplateName() {
156 public void setTemplateName(String templateName) {
157 this.templateName = templateName;
160 public String getTemplateBody() {
164 public void setTemplateBody(String templateBody) {
165 this.templateBody = templateBody;
168 public Integer getTimeoutMinutes() {
169 return timeoutMinutes;
172 public void setTimeoutMinutes(Integer timeout) {
173 this.timeoutMinutes = timeout;
177 public Set<HeatTemplateParam> getParameters() {
178 if (parameters == null)
179 parameters = new HashSet<>();
183 public void setParameters(Set<HeatTemplateParam> parameters) {
184 this.parameters = parameters;
187 public String getDescription() {
191 public void setDescription(String description) {
192 this.description = description;
195 public String getHeatTemplate() {
196 return this.templateBody;
199 public String getArtifactChecksum() {
200 return artifactChecksum;
203 public void setArtifactChecksum(String artifactChecksum) {
204 this.artifactChecksum = artifactChecksum;
207 public Date getCreated() {