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