/*- * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ * Copyright (c) 2019, CMCC Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.onap.so.db.catalog.beans; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import org.apache.commons.lang3.builder.ToStringBuilder; import javax.persistence.*; import java.io.Serializable; import java.util.Date; import java.util.Objects; @Entity @Table(name = "service_artifact") public class ServiceArtifact implements Serializable { private static final long serialVersionUID = 768026109321305392L; @BusinessKey @Id @Column(name = "ARTIFACT_UUID") private String artifactUUID; @Column(name = "TYPE") private String type; @Column(name = "NAME") private String name; @Column(name = "VERSION") private String version; @Column(name = "DESCRIPTION") private String description; @Column(name = "CONTENT", columnDefinition = "LONGTEXT") private String content; @Column(name = "CHECKSUM") private String checksum; @Column(name = "CREATION_TIMESTAMP", updatable = false) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") @Temporal(TemporalType.TIMESTAMP) private Date creationTimestamp; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "SERVICE_MODEL_UUID") private Service service; @PrePersist protected void onCreate() { this.creationTimestamp = new Date(); } public String getArtifactUUID() { return artifactUUID; } public void setArtifactUUID(String artifactUUID) { this.artifactUUID = artifactUUID; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getChecksum() { return checksum; } public void setChecksum(String checksum) { this.checksum = checksum; } public Date getCreationTimestamp() { return creationTimestamp; } public void setCreationTimestamp(Date creationTimestamp) { this.creationTimestamp = creationTimestamp; } public Service getService() { return service; } public void setService(Service service) { this.service = service; } @Override public String toString() { return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("type", type).append("name", name) .append("version", version).append("description", description).append("content", content) .append("checksum", checksum).append("creationTimestamp", creationTimestamp).toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceArtifact that = (ServiceArtifact) o; return artifactUUID.equals(that.artifactUUID); } @Override public int hashCode() { return Objects.hash(artifactUUID); } }