create post flow manipulator 95/118795/2
authorBENJAMIN, MAX <max.benjamin@att.com>
Thu, 4 Mar 2021 15:07:33 +0000 (10:07 -0500)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Thu, 4 Mar 2021 16:41:43 +0000 (11:41 -0500)
create post flow manipulator

Issue-ID: SO-3568
Signed-off-by: AT&T Open Source <g22940@att.com>
Change-Id: I8afe9cb0184c1f52754097f9912e123e56cfab98
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java

index c02afc3..054cc37 100644 (file)
@@ -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 (file)
index 0000000..b0e259b
--- /dev/null
@@ -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 (file)
index 0000000..1020f65
--- /dev/null
@@ -0,0 +1,5 @@
+package org.onap.so.bpmn.common.listener.flowmanipulator;
+
+public interface PreFlowManipulator extends FlowManipulator {
+
+}
index b756772..ccefc77 100644 (file)
@@ -430,6 +430,8 @@ public class WorkflowActionBBTasks {
         if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) {
             postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
         }
+
+        flowManipulatorListenerRunner.postModifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
     }
 
     protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
index bc32489..b90844a 100644 (file)
@@ -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
index 4cde9c1..08e8779 100644 (file)
@@ -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;
index 564ee91..3af839f 100644 (file)
@@ -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;
index 83f61e3..5ffba45 100644 (file)
@@ -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;