diff options
12 files changed, 233 insertions, 398 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql new file mode 100644 index 0000000000..c196f8f6e3 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql @@ -0,0 +1,44 @@ +use catalogdb; + +/* Consolidate Service_Proxy_Customization and Service_Proxy tables into a new table also called Service_Proxy_Customization */ + +ALTER TABLE service_proxy_customization DROP FOREIGN KEY fk_service_proxy_resource_customization__service1; + +ALTER TABLE service_proxy_customization DROP FOREIGN KEY fk_spr_customization__service_proxy_resource1; + +ALTER TABLE configuration_customization DROP FOREIGN KEY fk_configuration_customization__service_proxy_customization1; + +CREATE TABLE IF NOT EXISTS `service_proxy_customization_temp` ( + `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 `catalogdb`.`service` (`MODEL_UUID`) + ON DELETE CASCADE + ON UPDATE CASCADE) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; + +INSERT INTO catalogdb.service_proxy_customization_temp (model_customization_uuid,model_instance_name,model_uuid,model_invariant_uuid,model_version,model_name,tosca_node_type,description,source_service_model_uuid) +SELECT T1.model_customization_uuid, T1.model_instance_name,T2.model_uuid, T2.model_invariant_uuid, T2.model_version, T2.model_name, T1.tosca_node_type, T2.description, T1.source_service_model_uuid + FROM catalogdb.service_proxy_customization T1 + JOIN catalogdb.service_proxy T2 ON T1.service_proxy_model_uuid = T2.model_uuid; + +DROP TABLE service_proxy_customization; + +DROP TABLE service_proxy; + +RENAME TABLE service_proxy_customization_temp TO service_proxy_customization; diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 0c67123f56..72810d6f3c 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -502,36 +502,30 @@ 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, + `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 `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 `configuration_customization` ( `model_customization_uuid` varchar(200) not null, diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index 72aa3c7f5b..179dac3c35 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -42,7 +42,6 @@ import org.onap.so.db.catalog.beans.NetworkInstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; -import org.onap.so.db.catalog.beans.ServiceProxyResource; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; import org.onap.so.db.catalog.beans.ToscaCsar; @@ -83,9 +82,7 @@ public class ToscaResourceStructure { private CollectionResourceCustomization catalogCollectionResourceCustomization; private NetworkCollectionResourceCustomization catalogNetworkCollectionResourceCustomization; - - private ServiceProxyResource catalogServiceProxyResource; - + private ServiceProxyResourceCustomization catalogServiceProxyResourceCustomization; private ConfigurationResource catalogConfigurationResource; @@ -443,14 +440,6 @@ public class ToscaResourceStructure { this.catalogNetworkCollectionResourceCustomization = catalogNetworkCollectionResourceCustomization; } - public ServiceProxyResource getCatalogServiceProxyResource() { - return catalogServiceProxyResource; - } - - public void setCatalogServiceProxyResource(ServiceProxyResource catalogServiceProxyResource) { - this.catalogServiceProxyResource = catalogServiceProxyResource; - } - public ServiceProxyResourceCustomization getCatalogServiceProxyResourceCustomization() { return catalogServiceProxyResourceCustomization; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index bde43b0845..722e1599b6 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -73,7 +73,6 @@ import org.onap.so.db.catalog.beans.NetworkInstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; -import org.onap.so.db.catalog.beans.ServiceProxyResource; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.SubType; import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; @@ -99,7 +98,6 @@ import org.onap.so.db.catalog.data.repository.InstanceGroupRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository; -import org.onap.so.db.catalog.data.repository.ServiceProxyResourceRepository; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository; import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; @@ -147,10 +145,7 @@ public class ToscaResourceInstaller { @Autowired protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo; - - @Autowired - protected ServiceProxyResourceRepository serviceProxyRepo; - + @Autowired protected CollectionResourceRepository collectionRepo; @@ -401,7 +396,7 @@ public class ToscaResourceInstaller { for (NodeTemplate spNode : serviceProxyResourceList) { serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct); - ServiceProxyResource serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getServiceProxyResource().getModelUUID()); + ServiceProxyResourceCustomization serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getModelCustomizationUUID()); if(serviceProxyResource == null){ @@ -751,28 +746,22 @@ public class ToscaResourceInstaller { Metadata spMetadata = nodeTemplate.getMetaData(); - ServiceProxyResource spResource = new ServiceProxyResource(); - - spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); - spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); - spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); - ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization(); Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>(); + spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); spCustomizationResource.setSourceService(service); - spCustomizationResource.setServiceProxyResource(spResource); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); - spCustomizationResource.setServiceProxyResource(spResource); serviceProxyCustomizationSet.add(spCustomizationResource); - - toscaResourceStructure.setCatalogServiceProxyResource(spResource); toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource); @@ -802,7 +791,7 @@ public class ToscaResourceInstaller { configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); - configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization); + configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID()); configCustomizationResource.setConfigResourceCustomization(configCustomizationResource); configCustomizationResource.setConfigurationResource(configResource); configResourceCustomizationSet.add(configCustomizationResource); @@ -1388,18 +1377,18 @@ public class ToscaResourceInstaller { return configResource; } - protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) { - ServiceProxyResource serviceProxyResource = null; + protected ServiceProxyResourceCustomization findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelCustomizationUUID) { + ServiceProxyResourceCustomization serviceProxyResourceCustomization = null; for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){ - if (serviceProxyResourceCustom.getServiceProxyResource() != null - && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) { - serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource(); + if (serviceProxyResourceCustom != null + && serviceProxyResourceCustom.getModelCustomizationUUID().equals(modelCustomizationUUID)) { + serviceProxyResourceCustomization = serviceProxyResourceCustom; } } - if(serviceProxyResource==null) - serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID); + if(serviceProxyResourceCustomization==null) + serviceProxyResourceCustomization = serviceProxyCustomizationRepo.findResourceByModelCustomizationUUID(modelCustomizationUUID); - return serviceProxyResource; + return serviceProxyResourceCustomization; } protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index a84b02db63..b17fb5d47c 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -517,36 +517,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, @@ -560,19 +553,13 @@ create table if not exists `configuration_customization` ( `configuration_customization_model_customization_uuid` varchar(200) null, primary key (`model_customization_uuid`), index `fk_configuration_customization__configuration_idx` (`configuration_model_uuid` asc), -index `fk_configuration_customization__service_proxy_customization_idx` -(`service_proxy_customization_model_customization_uuid` asc), index `fk_configuration_customization__configuration_customization_idx` (`configuration_customization_model_customization_uuid` asc), constraint `fk_configuration_resource_customization__configuration_resour1` foreign key (`configuration_model_uuid`) references `configuration` (`model_uuid`) on delete cascade on update cascade, -constraint `fk_configuration_customization__service_proxy_customization1` foreign -key (`service_proxy_customization_model_customization_uuid`) references -`service_proxy_customization` (`model_customization_uuid`) -on delete cascade on update cascade, constraint -`fk_configuration_customization__configuration_customization1` foreign -key (`configuration_customization_model_customization_uuid`) references +constraint `fk_configuration_customization__configuration_customization1` +foreign key (`configuration_customization_model_customization_uuid`) references `configuration_customization` (`model_customization_uuid`) on delete cascade on update cascade) engine = innodb diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 07f31d7a23..eae0e3a1cb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -517,36 +517,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, @@ -560,19 +553,13 @@ create table if not exists `configuration_customization` ( `configuration_customization_model_customization_uuid` varchar(200) null, primary key (`model_customization_uuid`), index `fk_configuration_customization__configuration_idx` (`configuration_model_uuid` asc), -index `fk_configuration_customization__service_proxy_customization_idx` -(`service_proxy_customization_model_customization_uuid` asc), index `fk_configuration_customization__configuration_customization_idx` (`configuration_customization_model_customization_uuid` asc), constraint `fk_configuration_resource_customization__configuration_resour1` foreign key (`configuration_model_uuid`) references `configuration` (`model_uuid`) on delete cascade on update cascade, -constraint `fk_configuration_customization__service_proxy_customization1` foreign -key (`service_proxy_customization_model_customization_uuid`) references -`service_proxy_customization` (`model_customization_uuid`) -on delete cascade on update cascade, constraint -`fk_configuration_customization__configuration_customization1` foreign -key (`configuration_customization_model_customization_uuid`) references +constraint `fk_configuration_customization__configuration_customization1` +foreign key (`configuration_customization_model_customization_uuid`) references `configuration_customization` (`model_customization_uuid`) on delete cascade on update cascade) engine = innodb 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, |