Search in sources :

Example 6 with Join

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

the class SvgBpmnProcessImageGenerator method buildNodeContainer.

/*
     * Build methods
     */
protected void buildNodeContainer(int x, int y, NodeContainer nodeContainer, SVGGraphics2D g2) {
    try {
        for (Node node : nodeContainer.getNodes()) {
            if (node instanceof StartNode) {
                buildStartEvent(x, y, (StartNode) node, g2);
            } else if (node instanceof EndNode) {
                buildEndEvent(x, y, (EndNode) node, g2);
            } else if (node instanceof FaultNode) {
                buildErrorEndEvent(x, y, (FaultNode) node, g2);
            } else if (node instanceof BoundaryEventNode) {
                buildBoundaryEvent(x, y, node, g2);
            } else if (node instanceof EventNode || node instanceof StateNode) {
                buildIntermediateEvent(x, y, node, g2);
            } else if (node instanceof HumanTaskNode) {
                buildHumanTaskNode(x, y, (HumanTaskNode) node, g2);
            } else if (node instanceof ActionNode) {
                buildScriptTaskNode(x, y, (ActionNode) node, g2);
            } else if (node instanceof WorkItemNode) {
                buildServiceTaskNode(x, y, (WorkItemNode) node, g2);
            } else if (node instanceof Split || node instanceof Join) {
                buildGateway(x, y, node, g2);
            } else if (node instanceof ForEachNode) {
                buildNodeContainer(x(node), y(node), ((ForEachNode) node).getCompositeNode(), g2);
            } else if (node instanceof CompositeNode) {
                buildSubprocessNode(x, y, (CompositeNode) node, g2);
                int sx = x(node);
                int sy = y(node);
                buildNodeContainer(sx, sy, (CompositeNode) node, g2);
            } else if (node instanceof RuleSetNode) {
                buildBusinessRuleTaskNode(x, y, (RuleSetNode) node, g2);
            } else if (node instanceof TimerNode) {
                buildTimerEvent(x, y, (TimerNode) node, g2);
            } else if (node instanceof SubProcessNode) {
                buildCallActivity(x, y, (SubProcessNode) node, g2);
            }
            buildSequenceFlow(x, y, node, g2);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) 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) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) 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) 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) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Join(io.automatiko.engine.workflow.process.core.node.Join) UncheckedIOException(java.io.UncheckedIOException) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) Split(io.automatiko.engine.workflow.process.core.node.Split) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode)

Example 7 with Join

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

the class JoinHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    Join join = (Join) node;
    String type = null;
    switch(join.getType()) {
        case Join.TYPE_AND:
            type = "parallelGateway";
            break;
        case Join.TYPE_XOR:
            type = "exclusiveGateway";
            break;
        case Join.TYPE_OR:
            type = "inclusiveGateway";
            break;
        default:
            type = "complexGateway";
    }
    writeNode(type, node, xmlDump, metaDataType);
    xmlDump.append("gatewayDirection=\"Converging\" >" + EOL);
    writeExtensionElements(join, xmlDump);
    endNode(type, xmlDump);
}
Also used : Join(io.automatiko.engine.workflow.process.core.node.Join)

Example 8 with Join

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

the class JoinInstance 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("An ActionNode only accepts default incoming connections!");
    }
    triggerTime = new Date();
    final Join join = getJoin();
    switch(join.getType()) {
        case Join.TYPE_XOR:
            triggerCompleted();
            break;
        case Join.TYPE_AND:
            Integer count = (Integer) this.triggers.get(from.getNodeId());
            if (count == null) {
                this.triggers.put(from.getNodeId(), 1);
            } else {
                this.triggers.put(from.getNodeId(), count.intValue() + 1);
            }
            if (checkAllActivated()) {
                decreaseAllTriggers();
                triggerCompleted();
            }
            break;
        case Join.TYPE_DISCRIMINATOR:
            boolean triggerCompleted = triggers.isEmpty();
            triggers.put(from.getNodeId(), new Integer(1));
            if (checkAllActivated()) {
                resetAllTriggers();
            }
            if (triggerCompleted) {
                triggerCompleted();
            }
            break;
        case Join.TYPE_N_OF_M:
            count = (Integer) this.triggers.get(from.getNodeId());
            if (count == null) {
                this.triggers.put(from.getNodeId(), 1);
            } else {
                this.triggers.put(from.getNodeId(), count.intValue() + 1);
            }
            int counter = 0;
            for (final Connection connection : getJoin().getDefaultIncomingConnections()) {
                if (this.triggers.get(connection.getFrom().getId()) != null) {
                    counter++;
                }
            }
            String n = join.getN();
            Integer number = null;
            if (n.startsWith("#{") && n.endsWith("}")) {
                n = n.substring(2, n.length() - 1);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, n);
                if (variableScopeInstance == null) {
                    throw new IllegalArgumentException("Could not find variable " + n + " when executing join.");
                }
                Object value = variableScopeInstance.getVariable(n);
                if (value instanceof Number) {
                    number = ((Number) value).intValue();
                } else {
                    throw new IllegalArgumentException("Variable " + n + " did not return a number when executing join: " + value);
                }
            } else {
                number = Integer.parseInt(n);
            }
            if (counter >= number) {
                resetAllTriggers();
                NodeInstanceContainer nodeInstanceContainer = (NodeInstanceContainer) getNodeInstanceContainer();
                cancelRemainingDirectFlows(nodeInstanceContainer, getJoin());
                triggerCompleted();
            }
            break;
        case Join.TYPE_OR:
            NodeInstanceContainer nodeInstanceContainer = (NodeInstanceContainer) getNodeInstanceContainer();
            boolean activePathExists = existsActiveDirectFlow(nodeInstanceContainer, getJoin());
            if (!activePathExists) {
                triggerCompleted();
            }
            break;
        default:
            throw new IllegalArgumentException("Illegal join type " + join.getType());
    }
}
Also used : NodeInstanceContainer(io.automatiko.engine.api.runtime.process.NodeInstanceContainer) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) Connection(io.automatiko.engine.api.definition.process.Connection) Join(io.automatiko.engine.workflow.process.core.node.Join) Date(java.util.Date)

Example 9 with Join

use of io.automatiko.engine.workflow.process.core.node.Join 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 Join

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

the class ComplexGatewayHandler method createNode.

protected Node createNode(Attributes attrs) {
    final String type = attrs.getValue("gatewayDirection");
    if ("Converging".equals(type)) {
        Join join = new Join();
        join.setType(Join.TYPE_UNDEFINED);
        return join;
    } else if ("Diverging".equals(type)) {
        Split split = new Split();
        split.setType(Split.TYPE_UNDEFINED);
        return split;
    } else {
        throw new IllegalArgumentException("Unknown gateway direction: " + type);
    }
}
Also used : Join(io.automatiko.engine.workflow.process.core.node.Join) Split(io.automatiko.engine.workflow.process.core.node.Split)

Aggregations

Join (io.automatiko.engine.workflow.process.core.node.Join)14 Split (io.automatiko.engine.workflow.process.core.node.Split)9 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)4 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)4 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)4 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)4 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)4 Connection (io.automatiko.engine.api.definition.process.Connection)3 Node (io.automatiko.engine.api.definition.process.Node)3 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)3 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)3 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)3 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)3 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)3 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)3 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)2 HumanTaskNode (io.automatiko.engine.workflow.process.core.node.HumanTaskNode)2 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)2 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)2 IOException (java.io.IOException)2