diff options
Diffstat (limited to 'mso-catalog-db/src')
6 files changed, 98 insertions, 253 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java index 4f21580b9c..0b02c11701 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java @@ -22,6 +22,7 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; import java.util.Date; +import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -30,6 +31,8 @@ import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.MapsId; +import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PrePersist; import javax.persistence.Table; @@ -74,10 +77,9 @@ public class ConfigurationResourceCustomization implements Serializable { @Temporal(TemporalType.TIMESTAMP) private Date created; - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") - private ServiceProxyResourceCustomization serviceProxyResourceCustomization; - + @Column(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") + private String serviceProxyResourceCustomizationUUID; + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") private ConfigurationResourceCustomization configResourceCustomization; @@ -134,22 +136,20 @@ public class ConfigurationResourceCustomization implements Serializable { public Date getCreated() { return created; } - - @LinkedResource - public ServiceProxyResourceCustomization getServiceProxyResourceCustomization() { - return serviceProxyResourceCustomization; + + public String getServiceProxyResourceCustomizationUUID() { + return serviceProxyResourceCustomizationUUID; } - public void setServiceProxyResourceCustomization( - ServiceProxyResourceCustomization serviceProxyResourceCustomization) { - this.serviceProxyResourceCustomization = serviceProxyResourceCustomization; + public void setServiceProxyResourceCustomizationUUID(String serviceProxyResourceCustomizationUUID) { + this.serviceProxyResourceCustomizationUUID = serviceProxyResourceCustomizationUUID; } @LinkedResource public ConfigurationResourceCustomization getConfigResourceCustomization() { return configResourceCustomization; } - + public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) { this.configResourceCustomization = configResourceCustomization; } @@ -168,7 +168,7 @@ public class ConfigurationResourceCustomization implements Serializable { return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) .append("modelInstanceName", modelInstanceName).append("nfFunction", nfFunction) .append("nfType", nfType).append("nfRole", nfRole).append("created", created) - .append("serviceProxyResourceCustomization", serviceProxyResourceCustomization) + //.append("serviceProxyResourceCustomization", serviceProxyResourceCustomization) .append("configResourceCustomization", configResourceCustomization) .append("configurationResource", configurationResource).toString(); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java deleted file mode 100644 index a3f12edef4..0000000000 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 java.io.Serializable; -import java.util.Date; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.PrePersist; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.openpojo.business.annotation.BusinessKey; - -import uk.co.blackpepper.bowman.annotation.LinkedResource; - -@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" }) -@Entity -@Table(name = "service_proxy") -public class ServiceProxyResource implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 8113564204017394906L; - - @BusinessKey - @Id - @Column(name = "MODEL_UUID") - private String modelUUID; - - @Column(name = "MODEL_INVARIANT_UUID") - private String modelInvariantUUID; - - @Column(name = "MODEL_VERSION") - private String modelVersion; - - @Column(name = "MODEL_NAME") - private String modelName; - - @Column(name = "DESCRIPTION") - private String description; - - @Column(name = "CREATION_TIMESTAMP", updatable = false) - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @OneToMany(cascade = CascadeType.ALL, mappedBy = "serviceProxyResource") - private Set<ServiceProxyResourceCustomization> serviceProxyCustomization; - - @PrePersist - protected void onCreate() { - this.created = new Date(); - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - public String getModelInvariantUUID() { - return modelInvariantUUID; - } - - public void setModelInvariantUUID(String modelInvariantUUID) { - this.modelInvariantUUID = modelInvariantUUID; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - public String getModelName() { - return modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getCreated() { - return created; - } - - @LinkedResource - public Set<ServiceProxyResourceCustomization> getServiceProxyCustomization() { - return serviceProxyCustomization; - } - - public void setServiceProxyCustomization(Set<ServiceProxyResourceCustomization> serviceProxyCustomization) { - this.serviceProxyCustomization = serviceProxyCustomization; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) - .append("modelVersion", modelVersion).append("modelName", modelName).append("description", description) - .append("created", created).append("serviceProxyCustomization", serviceProxyCustomization).toString(); - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof ServiceProxyResource)) { - return false; - } - ServiceProxyResource castOther = (ServiceProxyResource) other; - return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(modelUUID).toHashCode(); - } -} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java index 3df22bc716..d725c505ff 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java @@ -22,14 +22,19 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; import java.util.Date; +import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PrePersist; import javax.persistence.Table; @@ -52,7 +57,7 @@ public class ServiceProxyResourceCustomization implements Serializable { * */ private static final long serialVersionUID = -2822457299134903084L; - + @BusinessKey @Id @Column(name = "MODEL_CUSTOMIZATION_UUID") @@ -60,9 +65,24 @@ public class ServiceProxyResourceCustomization implements Serializable { @Column(name = "MODEL_INSTANCE_NAME") private String modelInstanceName; + + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "MODEL_NAME") + private String modelName; @Column(name = "TOSCA_NODE_TYPE") private String toscaNodeType; + + @Column(name = "DESCRIPTION") + private String description; @Column(name = "CREATION_TIMESTAMP", updatable = false) @Temporal(TemporalType.TIMESTAMP) @@ -71,19 +91,12 @@ public class ServiceProxyResourceCustomization implements Serializable { @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "SOURCE_SERVICE_MODEL_UUID") private Service sourceService; - - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "SERVICE_PROXY_MODEL_UUID") - private ServiceProxyResource serviceProxyResource; - - @OneToOne(mappedBy = "serviceProxyResourceCustomization") - private ConfigurationResourceCustomization configResourceCustomization; - + @PrePersist protected void onCreate() { this.created = new Date(); } - + public String getModelCustomizationUUID() { return modelCustomizationUUID; } @@ -120,32 +133,56 @@ public class ServiceProxyResourceCustomization implements Serializable { public void setSourceService(Service sourceService) { this.sourceService = sourceService; } + + public String getModelUUID() { + return modelUUID; + } - @LinkedResource - public ServiceProxyResource getServiceProxyResource() { - return serviceProxyResource; + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; } - public void setServiceProxyResource(ServiceProxyResource serviceProxyResource) { - this.serviceProxyResource = serviceProxyResource; + public String getModelInvariantUUID() { + return modelInvariantUUID; } - @LinkedResource - public ConfigurationResourceCustomization getConfigResourceCustomization() { - return configResourceCustomization; + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; } - public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) { - this.configResourceCustomization = configResourceCustomization; + public String getModelVersion() { + return modelVersion; } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override public String toString() { return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) .append("modelInstanceName", modelInstanceName).append("toscaNodeType", toscaNodeType) - .append("created", created).append("sourceService", sourceService) - .append("serviceProxyResource", serviceProxyResource) - .append("configResourceCustomization", configResourceCustomization).toString(); + .append("modelUUID", modelUUID) + .append("modelInvariantUUID",modelInvariantUUID).append("modelName",modelName) + .append("description",description) + .append("created", created).append("sourceService", sourceService).toString(); } @Override diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java index c90fd8965a..cb98c8a709 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java @@ -26,4 +26,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "serviceProxyResourceCustomization", path = "serviceProxyResourceCustomization") public interface ServiceProxyResourceCustomizationRepository extends JpaRepository<ServiceProxyResourceCustomization, String> { + + ServiceProxyResourceCustomization findResourceByModelCustomizationUUID(String modelCustomizationUUID); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java deleted file mode 100644 index e6ec3b04d1..0000000000 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.data.repository; - -import org.onap.so.db.catalog.beans.ServiceProxyResource; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "serviceProxyResource", path = "serviceProxyResource") -public interface ServiceProxyResourceRepository extends JpaRepository<ServiceProxyResource, Long> { - ServiceProxyResource findResourceByModelUUID(String modelUUID); -}
\ No newline at end of file diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index b7d0061e65..de2dd5e28b 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -555,36 +555,29 @@ default character set = latin1; engine = innodb auto_increment = 20654 default character set = latin1; - create table if not exists `service_proxy` ( - `model_uuid` varchar(200) not null, - `model_invariant_uuid` varchar(200) not null, - `model_version` varchar(20) not null, - `model_name` varchar(200) not null, - `description` varchar(1200) null, - `creation_timestamp` datetime not null default current_timestamp, - primary key (`model_uuid`)) - engine = innodb auto_increment = 20654 - default character set = latin1; - -create table if not exists `service_proxy_customization` ( -`model_customization_uuid` varchar(200) not null, -`model_instance_name` varchar(200) not null, -`tosca_node_type` varchar(200) not null, -`source_service_model_uuid` varchar(200) not null, -`creation_timestamp` datetime not null default current_timestamp, -`service_proxy_model_uuid` varchar(200) not null, -primary key (`model_customization_uuid`), -index `fk_service_proxy_customization__service_proxy1_idx` (`service_proxy_model_uuid` asc), -index `fk_service_proxy_customization__service1_idx` (`source_service_model_uuid` asc), -constraint`fk_spr_customization__service_proxy_resource1` -foreign key (`service_proxy_model_uuid`) references `service_proxy` (`model_uuid`) -on delete cascade on update cascade, -constraint `fk_service_proxy_resource_customization__service1` -foreign key (`source_service_model_uuid`) references `service` -(`model_uuid`) on delete cascade on update cascade) -engine = innodb -auto_increment = 20654 -default character set = latin1; + CREATE TABLE IF NOT EXISTS `service_proxy_customization` ( + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `MODEL_UUID` VARCHAR(200) NOT NULL, + `MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, + `MODEL_VERSION` VARCHAR(20) NOT NULL, + `MODEL_NAME` VARCHAR(200) NOT NULL, + `TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, + `DESCRIPTION` VARCHAR(1200) NULL, + `SOURCE_SERVICE_MODEL_UUID` VARCHAR(200) NOT NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), + INDEX `fk_service_proxy_customization__service1_idx` (`SOURCE_SERVICE_MODEL_UUID` ASC), + UNIQUE INDEX `UK_service_proxy_customization` (`MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_service_proxy_customization__serv_prox_to_serv` (`MODEL_CUSTOMIZATION_UUID` ASC), + CONSTRAINT `fk_service_proxy_resource_customization__service1` + FOREIGN KEY (`SOURCE_SERVICE_MODEL_UUID`) + REFERENCES `service` (`MODEL_UUID`) + ON DELETE CASCADE + ON UPDATE CASCADE) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; create table if not exists `configuration_customization` ( `model_customization_uuid` varchar(200) not null, |