diff options
Diffstat (limited to 'bpmn')
12 files changed, 161 insertions, 32 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java index c02afc3327..054cc378ef 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -41,13 +41,18 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); - protected List<FlowManipulator> flowManipulators; + protected List<PreFlowManipulator> flowManipulators; + + protected List<PostFlowManipulator> postflowManipulators; @PostConstruct protected void init() { flowManipulators = new ArrayList<>( - Optional.ofNullable(context.getBeansOfType(FlowManipulator.class)).orElse(new HashMap<>()).values()); + Optional.ofNullable(context.getBeansOfType(PreFlowManipulator.class)).orElse(new HashMap<>()).values()); + + postflowManipulators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostFlowManipulator.class)) + .orElse(new HashMap<>()).values()); } @@ -56,11 +61,26 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { do { sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); - List<FlowManipulator> filtered = filterListeners(flowManipulators, + List<PreFlowManipulator> filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); + + logger.info("Running pre flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + } while (isBuildingBlockSkipped(sequenceBeforeFlowManipulator, execution)); + } + + public void postModifyFlows(List<ExecuteBuildingBlock> flowsToExecute, BuildingBlockExecution execution) { + int sequenceBeforeFlowManipulator; + do { + sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence() - 1); + List<PostFlowManipulator> filtered = filterListeners(postflowManipulators, (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), execution.getCurrentSequence() == 0, execution))); - logger.info("Running flow manipulators:\n{}", + logger.info("Running post flow manipulators:\n{}", filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); } while (isBuildingBlockSkipped(sequenceBeforeFlowManipulator, execution)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java new file mode 100644 index 0000000000..b0e259b801 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java @@ -0,0 +1,5 @@ +package org.onap.so.bpmn.common.listener.flowmanipulator; + +public interface PostFlowManipulator extends FlowManipulator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java new file mode 100644 index 0000000000..1020f65695 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java @@ -0,0 +1,5 @@ +package org.onap.so.bpmn.common.listener.flowmanipulator; + +public interface PreFlowManipulator extends FlowManipulator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 7c283ab153..5cbadd6b75 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -410,15 +410,7 @@ public class BBInputSetup implements JavaDelegate { parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, parameter.getResourceId()); this.populateVolumeGroup(parameter); } else if (modelType.equals(ModelType.vfModule)) { - if (parameter.getBbName().contains("Configuration")) { - parameter.setResourceId(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID)); - parameter.getModelInfo().setModelCustomizationUuid(parameter.getConfigurationKey()); - populateConfiguration(parameter); - } else { - parameter.getLookupKeyMap().put(ResourceKey.VF_MODULE_ID, parameter.getResourceId()); - parameter.setCloudConfiguration(parameter.getRequestDetails().getCloudConfiguration()); - this.populateVfModule(parameter); - } + populateVfModuleOnAssignAndCreateFlows(parameter); } else if (modelType.equals(ModelType.instanceGroup)) { parameter.getLookupKeyMap().put(ResourceKey.INSTANCE_GROUP_ID, parameter.getResourceId()); this.populateInstanceGroup(parameter); @@ -435,6 +427,18 @@ public class BBInputSetup implements JavaDelegate { parameter.getServiceInstance().getInstanceGroups().add(instanceGroup); } + protected void populateVfModuleOnAssignAndCreateFlows(BBInputSetupParameter parameter) throws Exception { + if (parameter.getBbName().contains("Configuration")) { + parameter.setResourceId(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID)); + parameter.getModelInfo().setModelCustomizationUuid(parameter.getConfigurationKey()); + populateConfiguration(parameter); + } else { + parameter.getLookupKeyMap().put(ResourceKey.VF_MODULE_ID, parameter.getResourceId()); + parameter.setCloudConfiguration(parameter.getRequestDetails().getCloudConfiguration()); + this.populateVfModule(parameter); + } + } + protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { // @TODO: this will populate the instanceGroup model info. // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index f5955d6c7d..d1da38f2d9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -204,8 +204,10 @@ public class WorkflowAction { } // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, // enable it. - List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); - if (sIRequest.getRequestDetails().getRequestParameters() != null && userParams != null) { + if (sIRequest.getRequestDetails().getRequestParameters() != null + && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { + List<Map<String, Object>> userParams = + sIRequest.getRequestDetails().getRequestParameters().getUserParams(); for (Map<String, Object> params : userParams) { if (params.containsKey(HOMINGSOLUTION)) { execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION))); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index b756772188..ec2ca74fa7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -420,15 +420,24 @@ public class WorkflowActionBBTasks { } public void postProcessingExecuteBB(DelegateExecution execution) { - List<ExecuteBuildingBlock> flowsToExecute = - (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - String handlingCode = (String) execution.getVariable(HANDLINGCODE); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); - String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); - if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) { - postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); + try { + List<ExecuteBuildingBlock> flowsToExecute = + (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + String handlingCode = (String) execution.getVariable(HANDLINGCODE); + final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); + logger.debug("Current Sequence: {}", currentSequence); + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); + String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); + if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte + && "Success".equalsIgnoreCase(handlingCode)) { + postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); + } + + flowManipulatorListenerRunner.postModifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); + } catch (Exception ex) { + logger.error("Exception in postProcessingExecuteBB", ex); + workflowAction.buildAndThrowException(execution, "Failed to post process Execute BB"); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java index bc32489944..b90844a733 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java @@ -22,12 +22,12 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; import java.util.List; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.springframework.stereotype.Component; @Component -public class HomingListener implements FlowManipulator { +public class HomingListener implements PreFlowManipulator { @Override diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java index 4cde9c1fc8..08e877956d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -26,7 +26,7 @@ import java.util.Optional; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class MultiStageSkipListener implements FlowManipulator, PostCompletionRequestsDbListener { +public class MultiStageSkipListener implements PreFlowManipulator, PostCompletionRequestsDbListener { @Autowired protected BBInputSetupUtils bbInputSetupUtils; 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 564ee91fb2..3af839fbec 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 @@ -27,7 +27,7 @@ import java.util.Set; import org.apache.logging.log4j.util.Strings; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; @@ -38,7 +38,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Component -public class SkipCDSBuildingBlockListener implements FlowManipulator { +public class SkipCDSBuildingBlockListener implements PreFlowManipulator { @Autowired private CatalogDbClient catalogDbClient; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java index 83f61e3a4f..5ffba455b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -3,7 +3,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; import java.util.List; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class SkipConfigVnfListener implements FlowManipulator { +public class SkipConfigVnfListener implements PreFlowManipulator { private final CatalogDbClient catalogDbClient; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 100c32f1c2..d0cd4b0b46 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -111,6 +111,7 @@ public class WorkflowActionTest extends BaseTaskTest { private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json"; private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json"; private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json"; + private static final String VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON = "VfModuleCreateWithFabricNoParams.json"; private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON = "VfModuleReplaceRebuildVolumeGroups.json"; private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; @@ -1493,6 +1494,27 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void selectExecutionListALaCarteNoRequestParametersTest() throws Exception { + String gAction = "createInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON); + initExecution(gAction, bpmnRequest, true); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB"); + } + + @Test public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; ObjectMapper mapper = new ObjectMapper(); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json new file mode 100644 index 0000000000..33b7eeee4a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json @@ -0,0 +1,62 @@ +{ + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "model-cust-name", + "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelType": "vfModule", + "modelName": "test-model-name", + "modelVersion": "1", + "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelInstanceName": "test-model-instance-name" + }, + "requestInfo": { + "source": "VID", + "instanceName": "instanceName", + "suppressRollback": false, + "requestorId": "user" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de", + "modelInfo": { + "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f", + "modelType": "service", + "modelName": "model-name", + "modelVersion": "1.0", + "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f" + } + } + }, + { + "relatedInstance": { + "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", + "modelInfo": { + "modelCustomizationName": "modle-cust-name", + "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelType": "vnf", + "modelName": "modle-name", + "modelVersion": "1.0", + "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelInstanceName": "model-inst-name" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "872f331350c54e59991a8de2cbffb40c", + "cloudOwner": "my-custom-cloud-owner", + "lcpCloudRegionId": "cloud-region" + } + } +}
\ No newline at end of file |