Merge "Enable WorkflowActionBB to skip last building block"
authorSeshu Kumar M <seshu.kumar.m@huawei.com>
Fri, 6 Aug 2021 04:39:49 +0000 (04:39 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 6 Aug 2021 04:39:49 +0000 (04:39 +0000)
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java

index 054cc37..c6d92cc 100644 (file)
@@ -60,6 +60,9 @@ public class FlowManipulatorListenerRunner extends ListenerRunner {
         int sequenceBeforeFlowManipulator;
         do {
             sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+            if (sequenceBeforeFlowManipulator >= flowsToExecute.size()) {
+                break;
+            }
             ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence());
             List<PreFlowManipulator> filtered = filterListeners(flowManipulators,
                     (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(),
index 5fd9701..6fb7b5b 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.6.0">
   <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true">
     <bpmn:extensionElements>
       <camunda:executionListener class="org.onap.so.bpmn.core.plugins.AsyncTaskExecutorListener" event="end" />
@@ -30,7 +30,7 @@
         <camunda:in source="rollbackTargetState" target="rollbackTargetState" />
         <camunda:out source="rollbackTargetState" target="rollbackTargetState" />
       </bpmn:extensionElements>
-      <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_0duoleg</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1hsqed1</bpmn:outgoing>
     </bpmn:callActivity>
     <bpmn:sequenceFlow id="SequenceFlow_0mqrkxv" sourceRef="Task_SelectBB" targetRef="ServiceTask_0e2p0xs" />
       <bpmn:incoming>SequenceFlow_0mqrkxv</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0mew9im</bpmn:outgoing>
     </bpmn:serviceTask>
-    <bpmn:sequenceFlow id="SequenceFlow_0mew9im" sourceRef="ServiceTask_0e2p0xs" targetRef="Call_ExecuteBB" />
+    <bpmn:sequenceFlow id="SequenceFlow_0mew9im" sourceRef="ServiceTask_0e2p0xs" targetRef="ExclusiveGateway_10j89d1" />
     <bpmn:sequenceFlow id="SequenceFlow_0kf5sen" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlowC" targetRef="Task_UpdateRequestComplete" />
     <bpmn:sequenceFlow id="SequenceFlow_1tfizxf" sourceRef="Task_PreValidateWorkflow" targetRef="Task_SelectBB" />
     <bpmn:serviceTask id="Task_PreValidateWorkflow" name="PreValidate Workflow" camunda:expression="${WorkflowValidatorRunner.preValidate(execution.getVariable(&#34;requestAction&#34;), execution)}">
     </bpmn:serviceTask>
     <bpmn:serviceTask id="ServiceTask_0lbkcyp" name="Post Processing Execute BB" camunda:expression="${WorkflowActionBBTasks.postProcessingExecuteBB(execution)}">
       <bpmn:incoming>SequenceFlow_1hsqed1</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1knplug</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1fftixk</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="SequenceFlow_1hsqed1" sourceRef="Call_ExecuteBB" targetRef="ServiceTask_0lbkcyp" />
       <bpmn:incoming>SequenceFlow_0ilo6lo</bpmn:incoming>
     </bpmn:endEvent>
     <bpmn:sequenceFlow id="SequenceFlow_0ilo6lo" name="yes" sourceRef="ExclusiveGateway_1dez26n" targetRef="EndEvent_12f15tu" />
+    <bpmn:exclusiveGateway id="ExclusiveGateway_10j89d1" default="SequenceFlow_0duoleg">
+      <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_0duoleg</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_1knplug</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:sequenceFlow id="SequenceFlow_0duoleg" sourceRef="ExclusiveGateway_10j89d1" targetRef="Call_ExecuteBB" />
+    <bpmn:sequenceFlow id="SequenceFlow_1knplug" name="completed = true" sourceRef="ExclusiveGateway_10j89d1" targetRef="ServiceTask_0lbkcyp">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true}</bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
   </bpmn:process>
   <bpmn:error id="Error_0kd2o2a" name="java.lang.Exception" errorCode="java.lang.Exception" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="CallActivity_03m7z4y_di" bpmnElement="Call_ExecuteBB">
-        <dc:Bounds x="1150" y="356" width="100" height="80" />
+        <dc:Bounds x="1200" y="356" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0mqrkxv_di" bpmnElement="SequenceFlow_0mqrkxv">
         <di:waypoint x="929" y="396" />
-        <di:waypoint x="990" y="396" />
+        <di:waypoint x="960" y="396" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="324.5" y="105" width="90" height="0" />
         </bpmndi:BPMNLabel>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0e2p0xs_di" bpmnElement="ServiceTask_0e2p0xs">
-        <dc:Bounds x="990" y="356" width="100" height="80" />
+        <dc:Bounds x="960" y="356" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0mew9im_di" bpmnElement="SequenceFlow_0mew9im">
-        <di:waypoint x="1090" y="396" />
-        <di:waypoint x="1150" y="396" />
+        <di:waypoint x="1060" y="396" />
+        <di:waypoint x="1105" y="396" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="530" y="99" width="0" height="12" />
         </bpmndi:BPMNLabel>
         <dc:Bounds x="670" y="356" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_0lbkcyp_di" bpmnElement="ServiceTask_0lbkcyp">
-        <dc:Bounds x="1325" y="356" width="100" height="80" />
+        <dc:Bounds x="1350" y="356" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1hsqed1_di" bpmnElement="SequenceFlow_1hsqed1">
-        <di:waypoint x="1250" y="396" />
-        <di:waypoint x="1325" y="396" />
+        <di:waypoint x="1300" y="396" />
+        <di:waypoint x="1350" y="396" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="697.5" y="99" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1fftixk_di" bpmnElement="SequenceFlow_1fftixk">
-        <di:waypoint x="1425" y="396" />
+        <di:waypoint x="1450" y="396" />
         <di:waypoint x="1501" y="396" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="873" y="99" width="0" height="12" />
           <dc:Bounds x="727" y="173" width="18" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ExclusiveGateway_10j89d1_di" bpmnElement="ExclusiveGateway_10j89d1" isMarkerVisible="true">
+        <dc:Bounds x="1105" y="371" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1100" y="428" width="60" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_0duoleg_di" bpmnElement="SequenceFlow_0duoleg">
+        <di:waypoint x="1155" y="396" />
+        <di:waypoint x="1200" y="396" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1knplug_di" bpmnElement="SequenceFlow_1knplug">
+        <di:waypoint x="1130" y="371" />
+        <di:waypoint x="1130" y="330" />
+        <di:waypoint x="1400" y="330" />
+        <di:waypoint x="1400" y="356" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1224" y="312" width="83" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
index cd151ba..b76cf1e 100644 (file)
@@ -111,13 +111,15 @@ public class WorkflowActionBBTasks {
             }
             int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
 
-            ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
-
-            execution.setVariable("buildingBlock", ebb);
-            currentSequence++;
-            execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size());
-            execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence);
-
+            boolean completed = false;
+            if (currentSequence < flowsToExecute.size()) {
+                ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
+                execution.setVariable("buildingBlock", ebb);
+                execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1);
+            } else {
+                completed = true;
+            }
+            execution.setVariable(COMPLETED, completed);
         } catch (Exception e) {
             workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e);
         }
@@ -425,6 +427,9 @@ public class WorkflowActionBBTasks {
             final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
             int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
             logger.debug("Current Sequence: {}", currentSequence);
+            if (currentSequence >= flowsToExecute.size()) {
+                execution.setVariable(COMPLETED, true);
+            }
             ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
             String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
             if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte
index 5cd3055..cbb746d 100644 (file)
@@ -149,7 +149,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
         workflowActionBBTasks.selectBB(execution);
         boolean success = (boolean) execution.getVariable("completed");
         int currentSequence = (int) execution.getVariable("gCurrentSequence");
-        assertTrue(success);
+        assertFalse(success);
         assertEquals(1, currentSequence);
     }