[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / HeatEnvironment.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.onap.so.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.text.DateFormat;
25 import java.util.Date;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.Lob;
30 import javax.persistence.PrePersist;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36 import com.openpojo.business.annotation.BusinessKey;
37 import uk.co.blackpepper.bowman.annotation.RemoteResource;
38
39 @Entity
40 @RemoteResource("/heatEnvironment")
41 @Table(name = "heat_environment")
42 public class HeatEnvironment implements Serializable {
43
44     private static final long serialVersionUID = 768026109321305392L;
45
46     @BusinessKey
47     @Id
48     @Column(name = "ARTIFACT_UUID")
49     private String artifactUuid;
50
51     @Column(name = "NAME")
52     private String name = null;
53
54     @Column(name = "DESCRIPTION")
55     private String description = null;
56
57     @Lob
58     @Column(name = "BODY", columnDefinition = "LONGTEXT")
59     private String environment = null;
60
61     @Column(name = "ARTIFACT_CHECKSUM")
62     private String artifactChecksum;
63
64     @Column(name = "CREATION_TIMESTAMP", updatable = false)
65     @Temporal(TemporalType.TIMESTAMP)
66     private Date created;
67
68     @BusinessKey
69     @Column(name = "VERSION")
70     private String version;
71
72     @PrePersist
73     protected void onCreate() {
74         this.created = new Date();
75     }
76
77     @Override
78     public boolean equals(final Object other) {
79         if (!(other instanceof HeatEnvironment)) {
80             return false;
81         }
82         HeatEnvironment castOther = (HeatEnvironment) other;
83         return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version)
84                 .isEquals();
85     }
86
87     @Override
88     public int hashCode() {
89         return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode();
90     }
91
92     public String getVersion() {
93         return version;
94     }
95
96     public void setVersion(String version) {
97         this.version = version;
98     }
99
100     public String getArtifactUuid() {
101         return this.artifactUuid;
102     }
103
104     public void setArtifactUuid(String artifactUuid) {
105         this.artifactUuid = artifactUuid;
106     }
107
108     public String getName() {
109         return name;
110     }
111
112     public void setName(String name) {
113         this.name = name;
114     }
115
116     public String getDescription() {
117         return this.description;
118     }
119
120     public void setDescription(String description) {
121         this.description = description;
122     }
123
124     public String getEnvironment() {
125         return this.environment;
126     }
127
128     public void setEnvironment(String environment) {
129         this.environment = environment;
130     }
131
132     public String getArtifactChecksum() {
133         return artifactChecksum;
134     }
135
136     public void setArtifactChecksum(String artifactChecksum) {
137         this.artifactChecksum = artifactChecksum;
138     }
139
140     public Date getCreated() {
141         return created;
142     }
143
144     @Override
145     public String toString() {
146         StringBuilder sb = new StringBuilder();
147         sb.append("Artifact UUID=" + this.artifactUuid);
148         sb.append(", name=");
149         sb.append(name);
150         sb.append(", version=");
151         sb.append(version);
152         sb.append(", description=");
153         sb.append(this.description == null ? "null" : this.description);
154         sb.append(", body=");
155         sb.append(this.environment == null ? "null" : this.environment);
156         if (this.created != null) {
157             sb.append(",creationTimestamp=");
158             sb.append(DateFormat.getInstance().format(this.created));
159         }
160         return sb.toString();
161     }
162 }