Replaced all tabs with spaces in java and pom.xml
[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
42 @Entity
43 @Table(name = "tosca_csar")
44 public class ToscaCsar implements Serializable {
45
46     private static final long serialVersionUID = 768026109321305392L;
47
48     @BusinessKey
49     @Id
50     @Column(name = "ARTIFACT_UUID")
51     private String artifactUUID;
52
53     @Column(name = "NAME")
54     private String name;
55
56     @Column(name = "ARTIFACT_CHECKSUM")
57     private String artifactChecksum;
58
59     @Column(name = "URL")
60     private String url;
61
62     @Column(name = "DESCRIPTION")
63     private String description;
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     @OneToMany(cascade = CascadeType.ALL, mappedBy = "csar")
74     @JsonIgnore
75     private List<Service> services;
76
77     @Override
78     public String toString() {
79         return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("name", name)
80                 .append("artifactChecksum", artifactChecksum).append("url", url).append("description", description)
81                 .append("created", created).append("version", version).append("services", services).toString();
82     }
83
84     @PrePersist
85     protected void onCreate() {
86         this.created = new Date();
87     }
88
89     @Override
90     public boolean equals(final Object other) {
91         if (!(other instanceof ToscaCsar)) {
92             return false;
93         }
94         ToscaCsar castOther = (ToscaCsar) other;
95         return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID).append(version, castOther.version)
96                 .isEquals();
97     }
98
99     @Override
100     public int hashCode() {
101         return new HashCodeBuilder().append(artifactUUID).append(version).toHashCode();
102     }
103
104     public ToscaCsar() {}
105
106     public String getArtifactUUID() {
107         return artifactUUID;
108     }
109
110     public void setArtifactUUID(String artifactUUID) {
111         this.artifactUUID = artifactUUID;
112     }
113
114     public String getName() {
115         return name;
116     }
117
118     public void setName(String name) {
119         this.name = name;
120     }
121
122     public String getVersion() {
123         return version;
124     }
125
126     public void setVersion(String version) {
127         this.version = version;
128     }
129
130     public String getArtifactChecksum() {
131         return artifactChecksum;
132     }
133
134     public void setArtifactChecksum(String artifactChecksum) {
135         this.artifactChecksum = artifactChecksum;
136     }
137
138     public String getUrl() {
139         return url;
140     }
141
142     public void setUrl(String url) {
143         this.url = url;
144     }
145
146     public String getDescription() {
147         return description;
148     }
149
150     public void setDescription(String description) {
151         this.description = description;
152     }
153
154     public Date getCreated() {
155         return created;
156     }
157
158     @LinkedResource
159     public List<Service> getServices() {
160         return services;
161     }
162
163     public void setServices(List<Service> services) {
164         this.services = services;
165     }
166 }