Search in sources :

Example 6 with Split

use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.

the class ProcessHandler method linkConnections.

public void linkConnections(NodeContainer nodeContainer, List<SequenceFlow> connections) {
    if (connections != null) {
        for (SequenceFlow connection : connections) {
            String sourceRef = connection.getSourceRef();
            Node source = findNodeByIdOrUniqueIdInMetadata(nodeContainer, sourceRef, "Could not find source node for connection:" + sourceRef);
            if (source instanceof EventNode) {
                for (EventFilter eventFilter : ((EventNode) source).getEventFilters()) {
                    if (eventFilter instanceof EventTypeFilter) {
                        if ("Compensation".equals(((EventTypeFilter) eventFilter).getType())) {
                            // BPMN Method & Style, 2nd Ed. (Silver), states this on P. 131
                            throw new IllegalArgumentException("A Compensation Boundary Event can only be *associated* with a compensation activity via an Association, not via a Sequence Flow element.");
                        }
                    }
                }
            }
            String targetRef = connection.getTargetRef();
            Node target = findNodeByIdOrUniqueIdInMetadata(nodeContainer, targetRef, "Could not find target node for connection:" + targetRef);
            Connection result = new ConnectionImpl(source, NodeImpl.CONNECTION_DEFAULT_TYPE, target, NodeImpl.CONNECTION_DEFAULT_TYPE);
            result.setMetaData("bendpoints", connection.getBendpoints());
            result.setMetaData("UniqueId", connection.getId());
            if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) {
                NodeImpl nodeImpl = (NodeImpl) source;
                Constraint constraint = buildConstraint(connection, nodeImpl);
                if (constraint != null) {
                    nodeImpl.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
                }
            } else if (source instanceof Split) {
                Split split = (Split) source;
                Constraint constraint = buildConstraint(connection, split);
                split.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
            }
        }
    }
}
Also used : NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) Constraint(io.automatiko.engine.workflow.process.core.Constraint) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Connection(io.automatiko.engine.workflow.process.core.Connection) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Split(io.automatiko.engine.workflow.process.core.node.Split) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 7 with Split

use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.

the class JoinInstance method checkNodes.

private boolean checkNodes(Set<Long> vistedNodes, Node startAt, Node currentNode, Node lookFor) {
    if (currentNode == null) {
        // for dynamic/ad hoc task there is no node
        return false;
    }
    List<Connection> connections = currentNode.getOutgoingConnections(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
    // special handling for XOR split as it usually is used for arbitrary loops
    if (currentNode instanceof Split && ((Split) currentNode).getType() == Split.TYPE_XOR) {
        if (vistedNodes.contains(startAt.getId())) {
            return false;
        }
        for (Connection conn : connections) {
            Set<Long> xorCopy = new HashSet<Long>(vistedNodes);
            Node nextNode = conn.getTo();
            if (nextNode == null) {
                continue;
            } else {
                xorCopy.add(nextNode.getId());
                if (nextNode.getId() != lookFor.getId()) {
                    checkNodes(xorCopy, currentNode, nextNode, lookFor);
                }
            }
            if (xorCopy.contains(lookFor.getId())) {
                vistedNodes.addAll(xorCopy);
                return true;
            }
        }
    } else {
        for (Connection conn : connections) {
            Node nextNode = conn.getTo();
            if (nextNode == null) {
                continue;
            } else {
                if (vistedNodes.contains(nextNode.getId())) {
                    // we have already been here so let's continue
                    continue;
                }
                if (nextNode.getId() == lookFor.getId()) {
                    // we found the node that we are looking for, add it and continue to find out
                    // other parts
                    // as it could be part of a loop
                    vistedNodes.add(nextNode.getId());
                    continue;
                }
                vistedNodes.add(nextNode.getId());
                if (startAt.getId() == nextNode.getId()) {
                    return true;
                } else {
                    boolean nestedCheck = checkNodes(vistedNodes, startAt, nextNode, lookFor);
                    if (nestedCheck) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Node(io.automatiko.engine.api.definition.process.Node) Connection(io.automatiko.engine.api.definition.process.Connection) Split(io.automatiko.engine.workflow.process.core.node.Split) HashSet(java.util.HashSet)

Example 8 with Split

use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.

the class SplitInstance method internalTrigger.

public void internalTrigger(final NodeInstance from, String type) {
    if (!io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
        throw new IllegalArgumentException("A Split only accepts default incoming connections!");
    }
    triggerTime = new Date();
    final Split split = getSplit();
    try {
        executeStrategy(split, type);
    } catch (WorkflowRuntimeException wre) {
        throw wre;
    } catch (Exception e) {
        throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Split: " + e.getMessage(), e);
    }
}
Also used : WorkflowRuntimeException(io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException) Split(io.automatiko.engine.workflow.process.core.node.Split) Date(java.util.Date) WorkflowRuntimeException(io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException)

Example 9 with Split

use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.

the class SvgBpmnProcessImageGenerator method buildGateway.

protected void buildGateway(int x, int y, Node node, SVGGraphics2D g2) throws IOException {
    setNodeId(node, g2);
    x += x(node);
    y += y(node);
    int width = width(node);
    int height = height(node);
    Polygon p = new Polygon();
    p.addPoint(x, y + (height / 2));
    p.addPoint(x + (width / 2), y);
    p.addPoint(x + width, y + (height / 2));
    p.addPoint(x + (width / 2), y + height);
    g2.drawPolygon(p);
    setTextNodeId(node, g2);
    drawCenteredString(g2, node.getName(), p.getBounds(), g2.getFont(), (height(node) / 2) + 10);
    Font current = g2.getFont();
    g2.setFont(new Font("Montserrat", Font.BOLD, 25));
    String gatewayMarker = "";
    if (node instanceof Split) {
        switch(((Split) node).getType()) {
            case Split.TYPE_XOR:
                gatewayMarker = "X";
                break;
            case Split.TYPE_AND:
                gatewayMarker = "+";
                break;
            case Split.TYPE_OR:
                gatewayMarker = "o";
                break;
            default:
                break;
        }
    } else if (node instanceof Join) {
        switch(((Join) node).getType()) {
            case Join.TYPE_XOR:
                gatewayMarker = "X";
                break;
            case Join.TYPE_AND:
                gatewayMarker = "+";
                break;
            case Join.TYPE_OR:
                gatewayMarker = "o";
                break;
            default:
                break;
        }
    }
    drawCenteredString(g2, gatewayMarker, p.getBounds(), g2.getFont(), 0);
    g2.setFont(current);
}
Also used : Join(io.automatiko.engine.workflow.process.core.node.Join) Polygon(java.awt.Polygon) Split(io.automatiko.engine.workflow.process.core.node.Split) Font(java.awt.Font)

Example 10 with Split

use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.

the class ServerlessWorkflowFactory method eventBasedSplit.

public Split eventBasedSplit(long id, String name, NodeContainer nodeContainer) {
    Split split = new Split();
    split.setId(id);
    split.setName(name);
    split.setType(Split.TYPE_XAND);
    split.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
    split.setMetaData(EVENTBASED_PARAM, "true");
    nodeContainer.addNode(split);
    return split;
}
Also used : Split(io.automatiko.engine.workflow.process.core.node.Split)

Aggregations

Split (io.automatiko.engine.workflow.process.core.node.Split)19 Join (io.automatiko.engine.workflow.process.core.node.Join)9 Node (io.automatiko.engine.api.definition.process.Node)5 Constraint (io.automatiko.engine.workflow.process.core.Constraint)5 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)5 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)5 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)5 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)5 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)5 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)4 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)4 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)4 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)4 Connection (io.automatiko.engine.api.definition.process.Connection)3 ConnectionRef (io.automatiko.engine.workflow.process.core.impl.ConnectionRef)3 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)3 HumanTaskNode (io.automatiko.engine.workflow.process.core.node.HumanTaskNode)3 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)3 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)3 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)3