Search in sources :

Example 26 with CompositeNode

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

the class ExecutableProcessValidator method checkAllNodesConnectedToStart.

private void checkAllNodesConnectedToStart(final NodeContainer container, boolean isDynamic, final List<ProcessValidationError> errors, ExecutableProcess process) {
    final Map<Node, Boolean> processNodes = new HashMap<>();
    final Node[] nodes;
    if (container instanceof CompositeNode) {
        nodes = ((CompositeNode) container).internalGetNodes();
    } else {
        nodes = container.getNodes();
    }
    List<Node> eventNodes = new ArrayList<>();
    List<CompositeNode> compositeNodes = new ArrayList<>();
    for (int i = 0; i < nodes.length; i++) {
        final Node node = nodes[i];
        processNodes.put(node, Boolean.FALSE);
        if (node instanceof EventNode) {
            eventNodes.add(node);
        }
        if (node instanceof CompositeNode) {
            compositeNodes.add((CompositeNode) node);
        }
    }
    if (isDynamic) {
        for (Node node : nodes) {
            if (node.getIncomingConnections(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE).isEmpty()) {
                processNode(node, processNodes);
            }
        }
    } else {
        final List<Node> start = ExecutableProcess.getStartNodes(nodes);
        if (start != null) {
            for (Node s : start) {
                processNode(s, processNodes);
            }
        }
        if (container instanceof CompositeNode) {
            for (CompositeNode.NodeAndType nodeAndTypes : ((CompositeNode) container).getLinkedIncomingNodes().values()) {
                processNode(nodeAndTypes.getNode(), processNodes);
            }
        }
    }
    for (Node eventNode : eventNodes) {
        processNode(eventNode, processNodes);
    }
    for (CompositeNode compositeNode : compositeNodes) {
        checkAllNodesConnectedToStart(compositeNode, compositeNode instanceof DynamicNode, errors, process);
    }
    for (final Iterator<Node> it = processNodes.keySet().iterator(); it.hasNext(); ) {
        final Node node = it.next();
        if (Boolean.FALSE.equals(processNodes.get(node)) && !(node instanceof StartNode) && !(node instanceof EventSubProcessNode)) {
            addErrorMessage(process, node, errors, "Has no connection to the start node.");
        }
    }
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) HashMap(java.util.HashMap) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) ForEachSplitNode(io.automatiko.engine.workflow.process.core.node.ForEachNode.ForEachSplitNode) 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) ForEachJoinNode(io.automatiko.engine.workflow.process.core.node.ForEachNode.ForEachJoinNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) ThrowLinkNode(io.automatiko.engine.workflow.process.core.node.ThrowLinkNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) Node(io.automatiko.engine.api.definition.process.Node) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) 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) ArrayList(java.util.ArrayList) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) NodeAndType(io.automatiko.engine.workflow.process.core.node.CompositeNode.NodeAndType) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode)

Example 27 with CompositeNode

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

the class ExecutableProcessFactory method linkBoundaryEvents.

protected void linkBoundaryEvents(NodeContainer nodeContainer) {
    for (Node node : nodeContainer.getNodes()) {
        if (node instanceof CompositeNode) {
            CompositeNode compositeNode = (CompositeNode) node;
            linkBoundaryEvents(compositeNode.getNodeContainer());
        }
        if (node instanceof EventNode) {
            final String attachedTo = (String) node.getMetaData().get(ATTACHED_TO);
            if (attachedTo != null) {
                Node attachedNode = findNodeByIdOrUniqueIdInMetadata(nodeContainer, attachedTo, "Could not find node to attach to: " + attachedTo);
                for (EventFilter filter : ((EventNode) node).getEventFilters()) {
                    String type = ((EventTypeFilter) filter).getType();
                    if (type.startsWith("Timer-")) {
                        linkBoundaryTimerEvent(node, attachedTo, attachedNode);
                    } else if (node.getMetaData().get(SIGNAL_NAME) != null || type.startsWith("Message-")) {
                        linkBoundarySignalEvent(node, attachedTo);
                    } else if (type.startsWith("Error-")) {
                        linkBoundaryErrorEvent(nodeContainer, node, attachedTo, attachedNode);
                    } else if (type.startsWith("Condition-") || type.startsWith("RuleFlowStateEvent-")) {
                        linkBoundaryConditionEvent(nodeContainer, node, attachedTo, attachedNode);
                    } else if (type.startsWith("Compensation")) {
                        addCompensationScope(getExecutableProcess(), node, nodeContainer, attachedTo);
                    }
                }
            }
        }
    }
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) 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) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter)

Aggregations

CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)27 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)16 ArrayList (java.util.ArrayList)15 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)14 Node (io.automatiko.engine.api.definition.process.Node)13 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)12 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)12 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)11 List (java.util.List)11 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)10 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)9 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)8 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)8 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)8 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)8 NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)7 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)7 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)6