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;
}
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("#####################################################");
}
}
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("#####################################################");
}
}
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);
}
}
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;
}
Aggregations