diff options
author | zm330 <zhangminyj@chinamobile.com> | 2020-02-27 19:30:05 +0800 |
---|---|---|
committer | zm330 <zhangminyj@chinamobile.com> | 2020-02-28 10:19:55 +0800 |
commit | 527090251194bcecf513ff493bed97da7f862927 (patch) | |
tree | 87e0d9a85df95a5158ce66544c5da9513484708e | |
parent | 7b4653622bba6d9392c53fe406088cd22e223ca1 (diff) |
add service beans
Issue-ID: SO-2368
Signed-off-by: zm330 <zhangminyj@chinamobile.com>
Change-Id: Ic6b015dad81f53fa86bd17eaf205dbc46d9d3761
3 files changed, 304 insertions, 0 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql new file mode 100644 index 0000000000..d32c4666c5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql @@ -0,0 +1,30 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `service_info` ( + `ID` int (11) AUTO_INCREMENT, + `SERVICE_INPUT` varchar (5000), + `SERVICE_PROPERTIES` varchar (5000), + PRIMARY KEY (`ID`) +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_artifact`( + `ARTIFACT_UUID` varchar (200) NOT NULL, + `TYPE` varchar (200) NOT NULL, + `NAME` varchar (200) NOT NULL, + `VERSION` varchar (200) NOT NULL, + `DESCRIPTION` varchar (200) DEFAULT NULL, + `CONTENT` LONGTEXT DEFAULT NULL, + `CHECKSUM` varchar (200) DEFAULT NULL, + `CREATION_TIMESTAMP` DATETIME DEFAULT CURRENT_TIMESTAMP, + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + PRIMARY KEY (`ARTIFACT_UUID`), + CONSTRAINT `fk_service_artifact_service_info1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_to_service_info` ( + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + `SERVICE_INFO_ID` INT (11) NOT NULL, + PRIMARY KEY (`SERVICE_MODEL_UUID`,`SERVICE_INFO_ID`), + CONSTRAINT `fk_service_to_service_info__service1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_service_to_service_info__service_info1` FOREIGN KEY (`SERVICE_INFO_ID`) REFERENCES `service_info` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE +)
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java new file mode 100644 index 0000000000..a8884a81bb --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java @@ -0,0 +1,168 @@ +/*- + * ============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); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java new file mode 100644 index 0000000000..f9c95767f6 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java @@ -0,0 +1,106 @@ +/*- + * ============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.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import uk.co.blackpepper.bowman.annotation.LinkedResource; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Objects; + +@Entity +@Table(name = "service_info") +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @BusinessKey + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private Integer id; + + @Column(name = "SERVICE_INPUT") + private String serviceInput; + + @Column(name = "SERVICE_PROPERTIES") + private String serviceProperties; + + @OneToOne(cascade = CascadeType.ALL) + @JoinTable(name = "service_to_service_info", joinColumns = @JoinColumn(name = "SERVICE_INFO_ID"), + inverseJoinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID")) + private Service service; + + public Integer getId() { + return id; + } + + public void setId(Integer serviceInfoId) { + this.id = serviceInfoId; + } + + public String getServiceInput() { + return serviceInput; + } + + public void setServiceInput(String serviceInput) { + this.serviceInput = serviceInput; + } + + public String getServiceProperties() { + return serviceProperties; + } + + public void setServiceProperties(String serviceProperties) { + this.serviceProperties = serviceProperties; + } + + @LinkedResource + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("serviceProperties", serviceProperties) + .append("serviceInput", serviceInput).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ServiceInfo that = (ServiceInfo) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } +} |