diff options
Diffstat (limited to 'asdc-controller/src')
3 files changed, 16 insertions, 26 deletions
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 423c1a7ed6..f524b96fa9 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 @@ -216,9 +216,6 @@ public class ToscaResourceInstaller { protected PnfCustomizationRepository pnfCustomizationRepository; @Autowired - protected ServiceInfoRepository serviceInfoRepository; - - @Autowired protected WorkflowResource workflowResource; @Autowired @@ -393,7 +390,7 @@ public class ToscaResourceInstaller { createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); Service service = toscaResourceStruct.getCatalogService(); - ServiceInfo serviceInfo = createServiceInfo(toscaResourceStruct, service); + createServiceInfo(toscaResourceStruct, service); List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false); @@ -423,9 +420,8 @@ public class ToscaResourceInstaller { processServiceProxyAndConfiguration(toscaResourceStruct, service); logger.info("Saving Service: {} ", service.getModelName()); - ServiceInfo serviceResult = serviceInfoRepository.save(serviceInfo); - Service resultService = serviceResult.getService(); - correlateConfigCustomResources(resultService); + service = serviceRepo.save(service); + correlateConfigCustomResources(service); workflowResource.processWorkflows(vfResourceStructure); @@ -1381,6 +1377,7 @@ public class ToscaResourceInstaller { service.setServiceType(serviceMetadata.getValue("serviceType")); service.setServiceRole(serviceMetadata.getValue("serviceRole")); + service.setServiceFunction(serviceMetadata.getValue("serviceFunction")); service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); @@ -2902,9 +2899,9 @@ public class ToscaResourceInstaller { createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); Service service = toscaResourceStruct.getCatalogService(); - ServiceInfo serviceInfo = createServiceInfo(toscaResourceStruct, service); + createServiceInfo(toscaResourceStruct, service); createServiceArtifact(service, vfResourceStruct, artifactContent); - serviceInfoRepository.save(serviceInfo); + serviceRepo.save(service); } private void createServiceArtifact(Service service, VfResourceStructure vfResourceStruct, String artifactContent) { @@ -2927,16 +2924,19 @@ public class ToscaResourceInstaller { service.setServiceArtifactList(serviceArtifactList); } - private ServiceInfo createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) { + private void createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) { + List<ServiceInfo> serviceInfos = new ArrayList<>(); + ServiceInfo serviceInfo = new ServiceInfo(); String serviceInput = getServiceInput(toscaResourceStruct); serviceInfo.setServiceInput(serviceInput); String serviceProperties = getServiceProperties(toscaResourceStruct); serviceInfo.setServiceProperties(serviceProperties); - serviceInfo.setService(service); - return serviceInfo; + serviceInfos.add(serviceInfo); + + service.setServiceInfos(serviceInfos); } private String getServiceProperties(ToscaResourceStructure toscaResourceStruct) { diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java index b8a2d01b49..e4882119ab 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java @@ -343,7 +343,6 @@ public class ToscaResourceInstallerTest extends BaseTest { doReturn(resourceCustomizationUUID).when(metadata).getValue("vfModuleModelCustomizationUUID"); ServiceRepository serviceRepo = spy(ServiceRepository.class); - ServiceInfoRepository serviceInfoRepo = spy(ServiceInfoRepository.class); VnfResourceRepository vnfRepo = spy(VnfResourceRepository.class); doReturn(null).when(vnfRepo).findResourceByModelUUID(uuid); @@ -354,7 +353,6 @@ public class ToscaResourceInstallerTest extends BaseTest { WorkflowResource workflowResource = spy(WorkflowResource.class); ReflectionTestUtils.setField(toscaInstaller, "serviceRepo", serviceRepo); - ReflectionTestUtils.setField(toscaInstaller, "serviceInfoRepository", serviceInfoRepo); ReflectionTestUtils.setField(toscaInstaller, "vnfRepo", vnfRepo); ReflectionTestUtils.setField(toscaInstaller, "vfModuleRepo", vfModuleRepo); ReflectionTestUtils.setField(toscaInstaller, "instanceGroupRepo", instanceGroupRepo); @@ -425,10 +423,7 @@ public class ToscaResourceInstallerTest extends BaseTest { assertNotNull(service); service.setModelVersion("1.0"); - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setService(service); doReturn(service).when(serviceRepo).save(service); - doReturn(serviceInfo).when(serviceInfoRepo).save(any(ServiceInfo.class)); WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository = spy(WatchdogComponentDistributionStatusRepository.class); diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index d051d1a56c..f94f74da97 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -804,6 +804,7 @@ CREATE TABLE `service` ( `TOSCA_CSAR_ARTIFACT_UUID` varchar(200) DEFAULT NULL, `SERVICE_TYPE` varchar(200) DEFAULT NULL, `SERVICE_ROLE` varchar(200) DEFAULT NULL, + `SERVICE_FUNCTION` varchar(200) DEFAULT NULL, `ENVIRONMENT_CONTEXT` varchar(200) DEFAULT NULL, `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL, `SERVICE_CATEGORY` varchar(200) DEFAULT NULL, @@ -1382,7 +1383,9 @@ CREATE TABLE IF NOT EXISTS `service_info` ( `ID` int (11) AUTO_INCREMENT, `SERVICE_INPUT` varchar (5000), `SERVICE_PROPERTIES` varchar (5000), - PRIMARY KEY (`ID`) + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_service_info_service1` 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_artifact`( @@ -1399,14 +1402,6 @@ CREATE TABLE IF NOT EXISTS `service_artifact`( 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 -)ENGINE=InnoDB DEFAULT CHARSET=latin1; - --------START Request DB SCHEMA -------- CREATE DATABASE requestdb; USE requestdb; |