From 6b92778120393c34d2df84ccaa2dc9f6fa8068fd Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 12 Nov 2020 18:58:01 +0100 Subject: [PATCH] FlowManipulatorListenerRunner bug fix Issue-ID: SO-3375 Signed-off-by: Lukasz Muszkieta Change-Id: Ib63c3a93ab191720924805fcd5e72f1bc51c2ba8 --- .../FlowManipulatorListenerRunner.java | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 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 ea7de687ee..c02afc3327 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2020 Nokia. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,6 +28,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.listener.ListenerRunner; @@ -49,17 +52,21 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { } public void modifyFlows(List flowsToExecute, BuildingBlockExecution execution) { + int sequenceBeforeFlowManipulator; + do { + sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); + List filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); - ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); - List filtered = filterListeners(flowManipulators, - (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), - execution.getCurrentSequence() == 0, execution))); - - logger.info("Running flow manipulators:\n{}", - filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); - filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); - + logger.info("Running 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)); } - + private boolean isBuildingBlockSkipped(int sequenceBeforeFlowManipulator, BuildingBlockExecution execution) { + return sequenceBeforeFlowManipulator != (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + } } -- 2.16.6