[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ToscaCsar.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.util.Date;
25 import java.util.List;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.OneToMany;
31 import javax.persistence.PrePersist;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import org.apache.commons.lang3.builder.EqualsBuilder;
36 import org.apache.commons.lang3.builder.HashCodeBuilder;
37 import org.apache.commons.lang3.builder.ToStringBuilder;
38 import com.fasterxml.jackson.annotation.JsonIgnore;
39 import com.openpojo.business.annotation.BusinessKey;
40 import uk.co.blackpepper.bowman.annotation.LinkedResource;
41 import uk.co.blackpepper.bowman.annotation.RemoteResource;
42
43 @Entity
44 @RemoteResource("/toscaCsar")
45 @Table(name = "tosca_csar")
46 public class ToscaCsar implements Serializable {
47
48     private static final long serialVersionUID = 768026109321305392L;
49
50     @BusinessKey
51     @Id
52     @Column(name = "ARTIFACT_UUID")
53     private String artifactUUID;
54
55     @Column(name = "NAME")
56     private String name;
57
58     @Column(name = "ARTIFACT_CHECKSUM")
59     private String artifactChecksum;
60
61     @Column(name = "URL")
62     private String url;
63
64     @Column(name = "DESCRIPTION")
65     private String description;
66
67     @Column(name = "CREATION_TIMESTAMP", updatable = false)
68     @Temporal(TemporalType.TIMESTAMP)
69     private Date created;
70
71     @BusinessKey
72     @Column(name = "Version")
73     private String version;
74
75     @OneToMany(cascade = CascadeType.ALL, mappedBy = "csar")
76     @JsonIgnore
77     private List<Service> services;
78
79     @Override
80     public String toString() {
81         return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("name", name)
82                 .append("artifactChecksum", artifactChecksum).append("url", url).append("description", description)
83                 .append("created", created).append("version", version).append("services", services).toString();
84     }
85
86     @PrePersist
87     protected void onCreate() {
88         this.created = new Date();
89     }
90
91     @Override
92     public boolean equals(final Object other) {
93         if (!(other instanceof ToscaCsar)) {
94             return false;
95         }
96         ToscaCsar castOther = (ToscaCsar) other;
97         return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID).append(version, castOther.version)
98                 .isEquals();
99     }
100
101     @Override
102     public int hashCode() {
103         return new HashCodeBuilder().append(artifactUUID).append(version).toHashCode();
104     }
105
106     public ToscaCsar() {}
107
108     public String getArtifactUUID() {
109         return artifactUUID;
110     }
111
112     public void setArtifactUUID(String artifactUUID) {
113         this.artifactUUID = artifactUUID;
114     }
115
116     public String getName() {
117         return name;
118     }
119
120     public void setName(String name) {
121         this.name = name;
122     }
123
124     public String getVersion() {
125         return version;
126     }
127
128     public void setVersion(String version) {
129         this.version = version;
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 String getUrl() {
141         return url;
142     }
143
144     public void setUrl(String url) {
145         this.url = url;
146     }
147
148     public String getDescription() {
149         return description;
150     }
151
152     public void setDescription(String description) {
153         this.description = description;
154     }
155
156     public Date getCreated() {
157         return created;
158     }
159
160     @LinkedResource
161     public List<Service> getServices() {
162         return services;
163     }
164
165     public void setServices(List<Service> services) {
166         this.services = services;
167     }
168 }