[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ServiceArtifact.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (c) 2019, CMCC Technologies Co., Ltd.
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 com.fasterxml.jackson.annotation.JsonFormat;
24 import com.openpojo.business.annotation.BusinessKey;
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26 import javax.persistence.*;
27 import java.io.Serializable;
28 import java.util.Date;
29 import java.util.Objects;
30
31 @Entity
32 @Table(name = "service_artifact")
33 public class ServiceArtifact implements Serializable {
34
35     private static final long serialVersionUID = 768026109321305392L;
36
37     @BusinessKey
38     @Id
39     @Column(name = "ARTIFACT_UUID")
40     private String artifactUUID;
41
42     @Column(name = "TYPE")
43     private String type;
44
45     @Column(name = "NAME")
46     private String name;
47
48     @Column(name = "VERSION")
49     private String version;
50
51     @Column(name = "DESCRIPTION")
52     private String description;
53
54     @Column(name = "CONTENT", columnDefinition = "LONGTEXT")
55     private String content;
56
57     @Column(name = "CHECKSUM")
58     private String checksum;
59
60     @Column(name = "CREATION_TIMESTAMP", updatable = false)
61     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
62     @Temporal(TemporalType.TIMESTAMP)
63     private Date creationTimestamp;
64
65     @ManyToOne(cascade = CascadeType.ALL)
66     @JoinColumn(name = "SERVICE_MODEL_UUID")
67     private Service service;
68
69     @PrePersist
70     protected void onCreate() {
71         this.creationTimestamp = new Date();
72     }
73
74     public String getArtifactUUID() {
75         return artifactUUID;
76     }
77
78     public void setArtifactUUID(String artifactUUID) {
79         this.artifactUUID = artifactUUID;
80     }
81
82
83     public String getType() {
84         return type;
85     }
86
87     public void setType(String type) {
88         this.type = type;
89     }
90
91     public String getName() {
92         return name;
93     }
94
95     public void setName(String name) {
96         this.name = name;
97     }
98
99     public String getVersion() {
100         return version;
101     }
102
103     public void setVersion(String version) {
104         this.version = version;
105     }
106
107     public String getDescription() {
108         return description;
109     }
110
111     public void setDescription(String description) {
112         this.description = description;
113     }
114
115     public String getContent() {
116         return content;
117     }
118
119     public void setContent(String content) {
120         this.content = content;
121     }
122
123     public String getChecksum() {
124         return checksum;
125     }
126
127     public void setChecksum(String checksum) {
128         this.checksum = checksum;
129     }
130
131     public Date getCreationTimestamp() {
132         return creationTimestamp;
133     }
134
135     public void setCreationTimestamp(Date creationTimestamp) {
136         this.creationTimestamp = creationTimestamp;
137     }
138
139     public Service getService() {
140         return service;
141     }
142
143     public void setService(Service service) {
144         this.service = service;
145     }
146
147     @Override
148     public String toString() {
149         return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("type", type).append("name", name)
150                 .append("version", version).append("description", description).append("content", content)
151                 .append("checksum", checksum).append("creationTimestamp", creationTimestamp).toString();
152     }
153
154     @Override
155     public boolean equals(Object o) {
156         if (this == o)
157             return true;
158         if (o == null || getClass() != o.getClass())
159             return false;
160         ServiceArtifact that = (ServiceArtifact) o;
161         return artifactUUID.equals(that.artifactUUID);
162     }
163
164     @Override
165     public int hashCode() {
166         return Objects.hash(artifactUUID);
167     }
168 }