diff options
author | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2021-04-13 18:49:42 -0400 |
---|---|---|
committer | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2021-08-04 08:47:46 -0400 |
commit | 084f025c6374249de06bf99235fd9e5b7987b933 (patch) | |
tree | 60f87c4b3cab70d238e6585335974e46cff48633 /bpmn/so-bpmn-tasks | |
parent | 872613eafe80034cca612bd93294286b3dbed4b1 (diff) |
Enable ControllerExecutionBB for service scope
Also make userParams.service optional to support usecases
where it is not being passed.
Issue-ID: SO-3627
Change-Id: I7e0abfffe54e11935b32f6c6829400de88fb4bd0
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
6 files changed, 43 insertions, 7 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java index f3b767a8f1..1da9ad584a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java @@ -157,6 +157,16 @@ public abstract class AbstractControllerExecution<T> { } /** + * Check whether the controller scope is SERVICE + * + * @param controllerScope controller scope, e.g, pnf, vnf, vfModule, service + * @return true if the controller scope is service, else return false + */ + protected boolean isServiceResourceScope(final String controllerScope) { + return "service".equalsIgnoreCase(controllerScope); + } + + /** * Check whether the controller scope is VNF resource related. * * @param controllerScope controller scope, e.g, pnf, vnf, vfModule diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java index 39a695b0b6..92be824691 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java @@ -109,6 +109,8 @@ public class ControllerExecutionBB extends AbstractControllerExecution<BuildingB PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid); controllerActor = pnfResourceCustomization.getControllerActor(); + } else if (isServiceResourceScope(controllerScope)) { + return controllerActor; } else if (isVnfResourceScope(controllerScope)) { VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java index c56ab3e71d..f2f3b5da08 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java @@ -26,7 +26,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; @@ -87,6 +89,11 @@ public class ControllerExecution { execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId()); execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + } else if ("service".equalsIgnoreCase(scope)) { + GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock(); + ModelInfoServiceInstance modelInfoServiceInstance = + gbb.getServiceInstance().getModelInfoServiceInstance(); + controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS"); } else { GenericVnf genericVnf = getGenericVnf(execution); String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java index 1fae5ce06c..5442f444ee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java @@ -46,6 +46,7 @@ public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockE public static final String CDS_ACTOR = "cds"; public static final String VNF_SCOPE = "vnf"; public static final String VF_MODULE_SCOPE = "vfmodule"; + public static final String SERVICE_SCOPE = "service"; @Autowired private ExceptionBuilder exceptionBuilder; @@ -59,8 +60,8 @@ public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockE @Override public Boolean understand(ControllerContext<BuildingBlockExecution> context) { String scope = context.getControllerScope(); - return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) - && (VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope)); + return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) && (SERVICE_SCOPE.equalsIgnoreCase(scope) + || VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope)); } @Override diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index 272c6189b4..ff6c113af3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -29,8 +29,10 @@ import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -76,11 +78,11 @@ public class SkipCDSBuildingBlockListener implements PreFlowManipulator { BuildingBlockExecution execution) { String customizationUUID = currentBB.getBuildingBlock().getKey(); - if (Strings.isEmpty(customizationUUID)) { - return; - } - - if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF") + if ("SERVICE".equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnScope())) { + String modelUUID = currentBB.getRequestDetails().getModelInfo().getModelUuid(); + Service service = catalogDbClient.getServiceByID(modelUUID); + currentSequenceSkipCheck(execution, service.getSkipPostInstConf()); + } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF") && containsIgnoreCaseAction(currentBB, vnfActions)) { List<VnfResourceCustomization> vnfResourceCustomizations = catalogDbClient.getVnfResourceCustomizationByModelUuid( diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java index fdf4d36c89..b23147e351 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java @@ -37,6 +37,7 @@ import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -46,6 +47,7 @@ import org.onap.so.serviceinstancebeans.RequestDetails; @RunWith(MockitoJUnitRunner.Silent.class) public class SkipCDSBuildingBlockListenerTest { + private static final String SERVICE_SCOPE = "service"; private static final String VNF_SCOPE = "VNF"; private static final String VF_SCOPE = "VFModule"; private static final String PNF_SCOPE = "pnf"; @@ -90,6 +92,18 @@ public class SkipCDSBuildingBlockListenerTest { } @Test + public void testSkipCDSforService() { + setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", 0); + Service service = new Service(); + when(catalogDbClient.getServiceByID(TEST_MODELUUID)).thenReturn(service); + + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(1, actual); + } + + @Test public void testProcessForVNFToSkipCDSBB() { // given setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0); |