Search in sources :

Example 6 with PathContext

use of org.jbpm.simulation.PathContext in project droolsjbpm-integration by kiegroup.

the class TestUtils method matchExpected.

public static boolean matchExpected(List<PathContext> paths, List<String>... expectedIds) {
    for (PathContext context : paths) {
        List<FlowElement> elements = removeDuplicates(context.getPathElements());
        boolean match = false;
        for (int i = 0; i < expectedIds.length; i++) {
            List<String> expected = expectedIds[i];
            if (expected != null && elements.size() == expected.size()) {
                for (FlowElement fe : elements) {
                    if (!expected.contains(fe.getId())) {
                        System.err.println("Following element not matched: " + fe.getId() + " " + fe.getName());
                        match = false;
                        break;
                    }
                    match = true;
                }
                if (match) {
                    expectedIds[i] = null;
                    break;
                }
            }
        }
        if (!match) {
            return false;
        }
    }
    return true;
}
Also used : PathContext(org.jbpm.simulation.PathContext) FlowElement(org.eclipse.bpmn2.FlowElement)

Example 7 with PathContext

use of org.jbpm.simulation.PathContext in project droolsjbpm-integration by kiegroup.

the class TestUtils method printOutPaths.

public static void printOutPaths(List<PathContext> paths, String name) {
    if (!"true".equalsIgnoreCase(System.getProperty("test.debug.off"))) {
        System.out.println("###################" + name + "###################");
        for (PathContext context : paths) {
            System.out.println("PATH: " + context.getId());
            System.out.println("AS TEXT:");
            for (FlowElement fe : context.getPathElements()) {
                System.out.println(fe.getName() + "  - " + fe.eClass().getName());
            }
        }
        System.out.println("#####################################################");
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) FlowElement(org.eclipse.bpmn2.FlowElement)

Example 8 with PathContext

use of org.jbpm.simulation.PathContext in project droolsjbpm-integration by kiegroup.

the class TestUtils method printOutPaths.

public static void printOutPaths(List<PathContext> paths, JSONObject jsonPaths, String name) {
    if (!"true".equalsIgnoreCase(System.getProperty("test.debug.off"))) {
        System.out.println("###################" + name + "###################");
        for (PathContext context : paths) {
            System.out.println("$$$$$$$$ PATH: " + context.getId() + " " + context.getType());
            System.out.println("$$$ AS TEXT:");
            for (FlowElement fe : context.getPathElements()) {
                System.out.println(fe.getName() + "  - " + fe.eClass().getName());
            }
        }
        if (jsonPaths != null) {
            System.out.println("$$$ AS JSON:");
            System.out.println(jsonPaths.toString());
            System.out.println("$$$$$$$$");
        }
        System.out.println("#####################################################");
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) FlowElement(org.eclipse.bpmn2.FlowElement)

Example 9 with PathContext

use of org.jbpm.simulation.PathContext in project droolsjbpm-integration by kiegroup.

the class GatewayElementHandler method handleExclusiveGateway.

protected void handleExclusiveGateway(List<SequenceFlow> outgoing) {
    List<PathContext> locked = new ArrayList<PathContext>();
    Stack<PathContext> contextsAtThisNode = manager.getContextsFromStack();
    for (PathContext contextAtThisNode : contextsAtThisNode) {
        for (SequenceFlow seqFlow : outgoing) {
            FlowElement target = seqFlow.getTargetRef();
            if (!contextAtThisNode.getVisitedSplitPoint().contains(seqFlow)) {
                PathContext separatePath = manager.cloneGiven(contextAtThisNode);
                separatePath.addVisitedSplitPoint(seqFlow);
                manager.addToPath(seqFlow, separatePath);
                super.handle(target, manager);
                separatePath.setLocked(true);
                locked.add(separatePath);
            }
        }
    }
    // unlock
    for (PathContext ctx : locked) {
        ctx.setLocked(false);
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList)

Example 10 with PathContext

use of org.jbpm.simulation.PathContext in project droolsjbpm-integration by kiegroup.

the class MainElementHandler method handle.

public boolean handle(FlowElement element, PathContextManager manager) {
    PathContext context = manager.getContextFromStack();
    if (!(element instanceof SubProcess)) {
        manager.addToPath(element, context);
    }
    List<SequenceFlow> outgoing = getOutgoing(element);
    if (outgoing != null && !outgoing.isEmpty()) {
        boolean handled = false;
        if (element instanceof Gateway) {
            Gateway gateway = ((Gateway) element);
            if (gateway.getGatewayDirection() == GatewayDirection.DIVERGING) {
                handled = HandlerRegistry.getHandler(element).handle(element, manager);
            } else {
                if (gateway instanceof ParallelGateway) {
                    handled = HandlerRegistry.getHandler(element).handle(element, manager);
                } else {
                    handled = HandlerRegistry.getHandler().handle(element, manager);
                }
            }
        } else if (element instanceof Activity) {
            handled = HandlerRegistry.getHandler(element).handle(element, manager);
        } else if (element instanceof IntermediateThrowEvent) {
            handled = HandlerRegistry.getHandler(element).handle(element, manager);
        } else {
            handled = HandlerRegistry.getHandler().handle(element, manager);
        }
        if (!handled && BPMN2Utils.isAdHoc(element)) {
            manager.clearCurrentContext();
        }
    } else {
        ElementHandler handelr = HandlerRegistry.getHandler(element);
        if (handelr != null) {
            boolean handled = handelr.handle(element, manager);
            if (!handled) {
                manager.finalizePath();
            }
        } else {
            manager.finalizePath();
        }
    }
    return true;
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Gateway(org.eclipse.bpmn2.Gateway) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) Activity(org.eclipse.bpmn2.Activity) IntermediateThrowEvent(org.eclipse.bpmn2.IntermediateThrowEvent)

Aggregations

PathContext (org.jbpm.simulation.PathContext)15 FlowElement (org.eclipse.bpmn2.FlowElement)10 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)10 ArrayList (java.util.ArrayList)5 Activity (org.eclipse.bpmn2.Activity)2 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)2 StartEvent (org.eclipse.bpmn2.StartEvent)2 SubProcess (org.eclipse.bpmn2.SubProcess)2 WrappedBoundaryEvent (org.jbpm.simulation.util.WrappedBoundaryEvent)2 BigDecimal (java.math.BigDecimal)1 CatchEvent (org.eclipse.bpmn2.CatchEvent)1 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)1 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)1 EventDefinition (org.eclipse.bpmn2.EventDefinition)1 Gateway (org.eclipse.bpmn2.Gateway)1 IntermediateThrowEvent (org.eclipse.bpmn2.IntermediateThrowEvent)1 LinkEventDefinition (org.eclipse.bpmn2.LinkEventDefinition)1 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)1 ParallelGateway (org.eclipse.bpmn2.ParallelGateway)1 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)1