Search in sources :

Example 16 with Split

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

the class XmlBPMNProcessDumper method visitConnection.

public void visitConnection(Connection connection, StringBuilder xmlDump, int metaDataType) {
    // if the connection was generated by a link event, don't dump.
    if (isConnectionRepresentingLinkEvent(connection)) {
        return;
    }
    // if the connection is a hidden one (compensations), don't dump
    Object hidden = ((ConnectionImpl) connection).getMetaData("hidden");
    if (hidden != null && ((Boolean) hidden)) {
        return;
    }
    xmlDump.append("    <sequenceFlow id=\"" + getUniqueNodeId(connection.getFrom()) + "-" + getUniqueNodeId(connection.getTo()) + "\" sourceRef=\"" + getUniqueNodeId(connection.getFrom()) + "\" ");
    // TODO fromType, toType
    xmlDump.append("targetRef=\"" + getUniqueNodeId(connection.getTo()) + "\" ");
    if (metaDataType == META_DATA_AS_NODE_PROPERTY) {
        String bendpoints = (String) connection.getMetaData().get("bendpoints");
        if (bendpoints != null) {
            xmlDump.append("g:bendpoints=\"" + bendpoints + "\" ");
        }
    }
    if (connection.getFrom() instanceof Split) {
        Split split = (Split) connection.getFrom();
        if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
            Constraint constraint = split.getConstraint(connection);
            if (constraint == null) {
                xmlDump.append(">" + EOL + "      <conditionExpression xsi:type=\"tFormalExpression\" />");
            } else {
                if (constraint.getName() != null && constraint.getName().trim().length() > 0) {
                    xmlDump.append("name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(constraint.getName()) + "\" ");
                }
                if (constraint.getPriority() != 0) {
                    xmlDump.append("tns:priority=\"" + constraint.getPriority() + "\" ");
                }
                xmlDump.append(">" + EOL + "      <conditionExpression xsi:type=\"tFormalExpression\" ");
                if ("code".equals(constraint.getType())) {
                    if ("java".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + JAVA_LANGUAGE + "\" ");
                    } else if ("XPath".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + XPATH_LANGUAGE + "\" ");
                    } else if ("JavaScript".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + JAVASCRIPT_LANGUAGE + "\" ");
                    } else if ("FEEL".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + FEEL_LANGUAGE + "\" ");
                    }
                } else {
                    xmlDump.append("language=\"" + RULE_LANGUAGE + "\" ");
                }
                String constraintString = constraint.getConstraint();
                if (constraintString == null) {
                    constraintString = "";
                }
                xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
            }
            xmlDump.append(EOL + "    </sequenceFlow>" + EOL);
        } else {
            xmlDump.append("/>" + EOL);
        }
    } else {
        xmlDump.append("/>" + EOL);
    }
}
Also used : Constraint(io.automatiko.engine.workflow.process.core.Constraint) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) Split(io.automatiko.engine.workflow.process.core.node.Split)

Example 17 with Split

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

the class XmlBPMNProcessDumper method visitNodesDi.

private void visitNodesDi(Node[] nodes, StringBuilder xmlDump) {
    for (Node node : nodes) {
        Integer x = (Integer) node.getMetaData().get("x");
        Integer y = (Integer) node.getMetaData().get("y");
        Integer width = (Integer) node.getMetaData().get("width");
        Integer height = (Integer) node.getMetaData().get("height");
        if (x == null) {
            x = 0;
        }
        if (y == null) {
            y = 0;
        }
        if (width == null) {
            width = 48;
        }
        if (height == null) {
            height = 48;
        }
        if (node instanceof StartNode || node instanceof EndNode || node instanceof EventNode || node instanceof FaultNode) {
            int offsetX = (int) ((width - 48) / 2);
            width = 48;
            x = x + offsetX;
            int offsetY = (int) ((height - 48) / 2);
            y = y + offsetY;
            height = 48;
        } else if (node instanceof Join || node instanceof Split) {
            int offsetX = (int) ((width - 48) / 2);
            width = 48;
            x = x + offsetX;
            int offsetY = (int) ((height - 48) / 2);
            y = y + offsetY;
            height = 48;
        }
        int parentOffsetX = 0;
        int parentOffsetY = 0;
        NodeContainer nodeContainer = node.getParentContainer();
        while (nodeContainer instanceof CompositeNode) {
            CompositeNode parent = (CompositeNode) nodeContainer;
            Integer parentX = (Integer) parent.getMetaData().get("x");
            if (parentX != null) {
                parentOffsetX += parentX;
            }
            Integer parentY = (Integer) parent.getMetaData().get("y");
            if (parentY != null) {
                parentOffsetY += (Integer) parent.getMetaData().get("y");
            }
            nodeContainer = parent.getParentContainer();
        }
        x += parentOffsetX;
        y += parentOffsetY;
        xmlDump.append("      <bpmndi:BPMNShape bpmnElement=\"" + getUniqueNodeId(node) + "\" >" + EOL + "        <dc:Bounds x=\"" + x + "\" " + "y=\"" + y + "\" " + "width=\"" + width + "\" " + "height=\"" + height + "\" />" + EOL + "      </bpmndi:BPMNShape>" + EOL);
        if (node instanceof CompositeNode) {
            visitNodesDi(((CompositeNode) node).getNodes(), xmlDump);
        }
    }
}
Also used : FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) 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) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) 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) 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) Join(io.automatiko.engine.workflow.process.core.node.Join) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) Split(io.automatiko.engine.workflow.process.core.node.Split) Constraint(io.automatiko.engine.workflow.process.core.Constraint)

Example 18 with Split

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

the class SplitHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    Split split = (Split) node;
    String type = null;
    switch(split.getType()) {
        case Split.TYPE_AND:
            type = "parallelGateway";
            writeNode(type, node, xmlDump, metaDataType);
            break;
        case Split.TYPE_XOR:
            type = "exclusiveGateway";
            writeNode(type, node, xmlDump, metaDataType);
            for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
                if (entry.getValue() != null && entry.getValue().isDefault()) {
                    xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getParentContainer().getNode(entry.getKey().getNodeId())) + "\" ");
                    break;
                }
            }
            break;
        case Split.TYPE_OR:
            type = "inclusiveGateway";
            writeNode(type, node, xmlDump, metaDataType);
            for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
                if (entry.getValue() != null && entry.getValue().isDefault()) {
                    xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getParentContainer().getNode(entry.getKey().getNodeId())) + "\" ");
                    break;
                }
            }
            break;
        case Split.TYPE_XAND:
            type = "eventBasedGateway";
            writeNode(type, node, xmlDump, metaDataType);
            break;
        default:
            type = "complexGateway";
            writeNode(type, node, xmlDump, metaDataType);
    }
    xmlDump.append("gatewayDirection=\"Diverging\" >" + EOL);
    writeExtensionElements(node, xmlDump);
    endNode(type, xmlDump);
}
Also used : Constraint(io.automatiko.engine.workflow.process.core.Constraint) Split(io.automatiko.engine.workflow.process.core.node.Split) Map(java.util.Map) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 19 with Split

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

the class ExecutableProcessValidator method validateNodes.

private void validateNodes(Node[] nodes, List<ProcessValidationError> errors, ExecutableProcess process) {
    String isForCompensation = "isForCompensation";
    for (int i = 0; i < nodes.length; i++) {
        final Node node = nodes[i];
        if (node instanceof StartNode) {
            final StartNode startNode = (StartNode) node;
            if (startNode.getTo() == null) {
                addErrorMessage(process, node, errors, "Start has no outgoing connection.");
            }
            if (startNode.getTimer() != null) {
                validateTimer(startNode.getTimer(), node, process, errors);
            }
        } else if (node instanceof EndNode) {
            final EndNode endNode = (EndNode) node;
            if (endNode.getFrom() == null) {
                addErrorMessage(process, node, errors, "End has no incoming connection.");
            }
            validateCompensationIntermediateOrEndEvent(endNode, process, errors);
        } else if (node instanceof RuleSetNode) {
            final RuleSetNode ruleSetNode = (RuleSetNode) node;
            if (ruleSetNode.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "RuleSet has no incoming connection.");
            }
            if (ruleSetNode.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                addErrorMessage(process, node, errors, "RuleSet has no outgoing connection.");
            }
            final String language = ruleSetNode.getLanguage();
            RuleSetNode.RuleType ruleType = ruleSetNode.getRuleType();
            if (RuleSetNode.DMN_LANG.equals(language) || RuleSetNode.CMMN_DMN_LANG.equals(language)) {
                RuleSetNode.RuleType.Decision decision = (RuleSetNode.RuleType.Decision) ruleType;
                final String namespace = decision.getNamespace();
                if (namespace == null || "".equals(namespace)) {
                    addErrorMessage(process, node, errors, "RuleSet (DMN) has no namespace.");
                }
                final String model = decision.getModel();
                if (model == null || "".equals(model)) {
                    addErrorMessage(process, node, errors, "RuleSet (DMN) has no model.");
                }
            } else {
                addErrorMessage(process, node, errors, "Unsupported rule language '" + language + "'");
            }
            if (ruleSetNode.getTimers() != null) {
                for (Timer timer : ruleSetNode.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                }
            }
        } else if (node instanceof Split) {
            final Split split = (Split) node;
            if (split.getType() == Split.TYPE_UNDEFINED) {
                addErrorMessage(process, node, errors, "Split has no type.");
            }
            if (split.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Split has no incoming connection.");
            }
            // }
            if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
                for (final Iterator<Connection> it = split.getDefaultOutgoingConnections().iterator(); it.hasNext(); ) {
                    final Connection connection = it.next();
                    if (split.getConstraint(connection) == null && !split.isDefault(connection) || (!split.isDefault(connection) && (split.getConstraint(connection).getConstraint() == null || split.getConstraint(connection).getConstraint().trim().length() == 0))) {
                        addErrorMessage(process, node, errors, "Split does not have a constraint for " + connection.toString() + ".");
                    }
                }
            }
        } else if (node instanceof Join) {
            final Join join = (Join) node;
            if (join.getType() == Join.TYPE_UNDEFINED) {
                addErrorMessage(process, node, errors, "Join has no type.");
            }
            // }
            if (join.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                addErrorMessage(process, node, errors, "Join has no outgoing connection.");
            }
            if (join.getType() == Join.TYPE_N_OF_M) {
                String n = join.getN();
                if (!n.startsWith("#{") || !n.endsWith("}")) {
                    try {
                        Integer.parseInt(n);
                    } catch (NumberFormatException e) {
                        addErrorMessage(process, node, errors, "Join has illegal n value: " + n);
                    }
                }
            }
        } else if (node instanceof MilestoneNode) {
            final MilestoneNode milestone = (MilestoneNode) node;
            if (milestone.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Milestone has no incoming connection.");
            }
            if (milestone.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                addErrorMessage(process, node, errors, "Milestone has no outgoing connection.");
            }
            if (milestone.getTimers() != null) {
                for (Timer timer : milestone.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                }
            }
        } else if (node instanceof StateNode) {
            final StateNode stateNode = (StateNode) node;
            if (stateNode.getDefaultIncomingConnections().isEmpty() && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "State has no incoming connection");
            }
        } else if (node instanceof SubProcessNode) {
            final SubProcessNode subProcess = (SubProcessNode) node;
            if (subProcess.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "SubProcess has no incoming connection.");
            }
            if (subProcess.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                Object compensationObj = subProcess.getMetaData(isForCompensation);
                if (compensationObj == null || !((Boolean) compensationObj)) {
                    addErrorMessage(process, node, errors, "SubProcess has no outgoing connection.");
                }
            }
            if (subProcess.getProcessId() == null && subProcess.getProcessName() == null) {
                addErrorMessage(process, node, errors, "SubProcess has no process id.");
            }
            if (subProcess.getTimers() != null) {
                for (Timer timer : subProcess.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                }
            }
            if (!subProcess.isIndependent() && !subProcess.isWaitForCompletion()) {
                addErrorMessage(process, node, errors, "SubProcess you can only set " + "independent to 'false' only when 'Wait for completion' is set to true.");
            }
        } else if (node instanceof ActionNode) {
            final ActionNode actionNode = (ActionNode) node;
            if (actionNode.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Action has no incoming connection.");
            }
            if (actionNode.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                Object compensationObj = actionNode.getMetaData(isForCompensation);
                if (compensationObj == null || !((Boolean) compensationObj)) {
                    addErrorMessage(process, node, errors, "Action has no outgoing connection.");
                }
            }
            // but not in Kogito)
            if (actionNode.getAction() instanceof ConsequenceAction) {
                ConsequenceAction processAction = (ConsequenceAction) actionNode.getAction();
                String actionString = processAction.getConsequence();
                if (actionString == null) {
                    addErrorMessage(process, node, errors, "Action has empty action.");
                } else if ("mvel".equals(processAction.getDialect())) {
                    try {
                        ParserContext parserContext = new ParserContext();
                        ExpressionCompiler compiler = new ExpressionCompiler(actionString, parserContext);
                        compiler.setVerifying(true);
                        compiler.compile();
                        List<ErrorDetail> mvelErrors = parserContext.getErrorList();
                        if (mvelErrors != null) {
                            for (Iterator<ErrorDetail> iterator = mvelErrors.iterator(); iterator.hasNext(); ) {
                                ErrorDetail error = iterator.next();
                                addErrorMessage(process, node, errors, "Action has invalid action: " + error.getMessage() + ".");
                            }
                        }
                    } catch (Throwable t) {
                        addErrorMessage(process, node, errors, "Action has invalid action: " + t.getMessage() + ".");
                    }
                }
                validateCompensationIntermediateOrEndEvent(actionNode, process, errors);
            }
        } else if (node instanceof WorkItemNode) {
            final WorkItemNode workItemNode = (WorkItemNode) node;
            if (workItemNode.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Task has no incoming connection.");
            }
            if (workItemNode.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                Object compensationObj = workItemNode.getMetaData(isForCompensation);
                if (compensationObj == null || !((Boolean) compensationObj)) {
                    addErrorMessage(process, node, errors, "Task has no outgoing connection.");
                }
            }
            if (workItemNode.getWork() == null) {
                addErrorMessage(process, node, errors, "Task has no work specified.");
            } else {
                Work work = workItemNode.getWork();
                if (work.getName() == null || work.getName().trim().length() == 0) {
                    addErrorMessage(process, node, errors, "Task has no task type.");
                }
            }
            if (workItemNode.getTimers() != null) {
                for (Timer timer : workItemNode.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                }
            }
        } else if (node instanceof ForEachNode) {
            final ForEachNode forEachNode = (ForEachNode) node;
            String variableName = forEachNode.getVariableName();
            if (variableName == null || "".equals(variableName)) {
                addErrorMessage(process, node, errors, "ForEach has no variable name");
            }
            String collectionExpression = forEachNode.getCollectionExpression();
            if (collectionExpression == null || "".equals(collectionExpression)) {
                addErrorMessage(process, node, errors, "ForEach has no collection expression");
            }
            if (forEachNode.getDefaultIncomingConnections().isEmpty() && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "ForEach has no incoming connection");
            }
            if (forEachNode.getDefaultOutgoingConnections().isEmpty() && !acceptsNoOutgoingConnections(node)) {
                addErrorMessage(process, node, errors, "ForEach has no outgoing connection");
            }
            final List<Node> start = ExecutableProcess.getStartNodes(forEachNode.getNodes());
            if (start != null) {
                for (Node s : start) {
                    if (((StartNode) s).getTriggers() != null && !((StartNode) s).getTriggers().isEmpty() || ((StartNode) s).getTimer() != null) {
                        addErrorMessage(process, node, errors, "MultiInstance subprocess can only have none start event.");
                    }
                }
            }
            validateNodes(forEachNode.getNodes(), errors, process);
        } else if (node instanceof DynamicNode) {
            final DynamicNode dynamicNode = (DynamicNode) node;
            if (dynamicNode.getDefaultIncomingConnections().isEmpty() && !acceptsNoIncomingConnections(dynamicNode)) {
                addErrorMessage(process, node, errors, "Dynamic has no incoming connection");
            }
            if (dynamicNode.getDefaultOutgoingConnections().isEmpty() && !acceptsNoOutgoingConnections(dynamicNode)) {
                addErrorMessage(process, node, errors, "Dynamic has no outgoing connection");
            }
            if (!dynamicNode.hasCompletionCondition() && !dynamicNode.isAutoComplete()) {
                addErrorMessage(process, node, errors, "Dynamic has no completion condition set");
            }
            validateNodes(dynamicNode.getNodes(), errors, process);
        } else if (node instanceof CompositeNode) {
            final CompositeNode compositeNode = (CompositeNode) node;
            for (Map.Entry<String, NodeAndType> inType : compositeNode.getLinkedIncomingNodes().entrySet()) {
                if (compositeNode.getIncomingConnections(inType.getKey()).isEmpty() && !acceptsNoIncomingConnections(node)) {
                    addErrorMessage(process, node, errors, "Composite has no incoming connection for type " + inType.getKey());
                }
                if (inType.getValue().getNode() == null && !acceptsNoOutgoingConnections(node)) {
                    addErrorMessage(process, node, errors, "Composite has invalid linked incoming node for type " + inType.getKey());
                }
            }
            for (Map.Entry<String, NodeAndType> outType : compositeNode.getLinkedOutgoingNodes().entrySet()) {
                if (compositeNode.getOutgoingConnections(outType.getKey()).isEmpty()) {
                    addErrorMessage(process, node, errors, "Composite has no outgoing connection for type " + outType.getKey());
                }
                if (outType.getValue().getNode() == null) {
                    addErrorMessage(process, node, errors, "Composite has invalid linked outgoing node for type " + outType.getKey());
                }
            }
            if (compositeNode.getLinkedIncomingNodes().values().isEmpty()) {
                boolean foundStartNode = false;
                for (Node internalNode : compositeNode.getNodes()) {
                    if (internalNode instanceof StartNode) {
                        foundStartNode = true;
                    }
                }
                if (!foundStartNode) {
                    addErrorMessage(process, node, errors, "Composite has no start node defined.");
                }
            }
            if (compositeNode instanceof EventSubProcessNode) {
                if (compositeNode.getIncomingConnections().size() > 0) {
                    addErrorMessage(process, node, errors, "Event subprocess is not allowed to have any incoming connections.");
                }
                if (compositeNode.getOutgoingConnections().size() > 0) {
                    addErrorMessage(process, node, errors, "Event subprocess is not allowed to have any outgoing connections.");
                }
                Node[] eventSubProcessNodes = compositeNode.getNodes();
                int startEventCount = 0;
                for (int j = 0; j < eventSubProcessNodes.length; ++j) {
                    if (eventSubProcessNodes[j] instanceof StartNode) {
                        StartNode startNode = (StartNode) eventSubProcessNodes[j];
                        if (++startEventCount == 2) {
                            addErrorMessage(process, compositeNode, errors, "Event subprocess is not allowed to have more than one start node.");
                        }
                        if (startNode.getTimer() == null && (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) && !startNode.hasCondition()) {
                            addErrorMessage(process, startNode, errors, "Start in Event SubProcess '" + compositeNode.getName() + "' [" + compositeNode.getId() + "] must contain a trigger (event definition).");
                        }
                    }
                }
            } else {
                Boolean isForCompensationObject = (Boolean) compositeNode.getMetaData("isForCompensation");
                if (compositeNode.getIncomingConnections().size() == 0 && !Boolean.TRUE.equals(isForCompensationObject)) {
                    addErrorMessage(process, node, errors, "Embedded subprocess does not have incoming connection.");
                }
                if (compositeNode.getOutgoingConnections().size() == 0 && !Boolean.TRUE.equals(isForCompensationObject)) {
                    addErrorMessage(process, node, errors, "Embedded subprocess does not have outgoing connection.");
                }
                final List<Node> start = ExecutableProcess.getStartNodes(compositeNode.getNodes());
                if (start != null) {
                    for (Node s : start) {
                        if (((StartNode) s).getTriggers() != null && !((StartNode) s).getTriggers().isEmpty() || ((StartNode) s).getTimer() != null) {
                            addErrorMessage(process, node, errors, "Embedded subprocess can only have none start event.");
                        }
                    }
                }
            }
            if (compositeNode.getTimers() != null) {
                for (Timer timer : compositeNode.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                }
            }
            validateNodes(compositeNode.getNodes(), errors, process);
        } else if (node instanceof EventNode) {
            final EventNode eventNode = (EventNode) node;
            if (eventNode.getEventFilters().isEmpty()) {
                addErrorMessage(process, node, errors, "Event should specify an event type");
            }
            if (eventNode.getDefaultOutgoingConnections().isEmpty()) {
                addErrorMessage(process, node, errors, "Event has no outgoing connection");
            } else {
                List<EventFilter> eventFilters = eventNode.getEventFilters();
                boolean compensationHandler = false;
                for (EventFilter eventFilter : eventFilters) {
                    if (((EventTypeFilter) eventFilter).getType().startsWith("Compensation")) {
                        compensationHandler = true;
                        break;
                    }
                }
                if (compensationHandler && eventNode instanceof BoundaryEventNode) {
                    Connection connection = eventNode.getDefaultOutgoingConnections().get(0);
                    Boolean isAssociation = (Boolean) connection.getMetaData().get("association");
                    if (isAssociation == null) {
                        isAssociation = false;
                    }
                    if (!(eventNode.getDefaultOutgoingConnections().size() == 1 && connection != null && isAssociation)) {
                        addErrorMessage(process, node, errors, "Compensation Boundary Event is only allowed to have 1 association to 1 compensation activity.");
                    }
                }
            }
        } else if (node instanceof FaultNode) {
            final FaultNode faultNode = (FaultNode) node;
            if (faultNode.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Fault has no incoming connection.");
            }
            if (faultNode.getFaultName() == null) {
                addErrorMessage(process, node, errors, "Fault has no fault name.");
            }
        } else if (node instanceof TimerNode) {
            TimerNode timerNode = (TimerNode) node;
            if (timerNode.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                addErrorMessage(process, node, errors, "Timer has no incoming connection.");
            }
            if (timerNode.getTo() == null && !acceptsNoOutgoingConnections(node)) {
                addErrorMessage(process, node, errors, "Timer has no outgoing connection.");
            }
            if (timerNode.getTimer() == null) {
                addErrorMessage(process, node, errors, "Timer has no timer specified.");
            } else {
                validateTimer(timerNode.getTimer(), node, process, errors);
            }
        } else if (node instanceof CatchLinkNode) {
        // catchlink validation here, there also are validations in
        // ProcessHandler regarding connection issues
        } else if (node instanceof ThrowLinkNode) {
        // throw validation here, there also are validations in
        // ProcessHandler regarding connection issues
        } else {
            errors.add(new ProcessValidationErrorImpl(process, "Unknown node type '" + node.getClass().getName() + "'"));
        }
    }
}
Also used : 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) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) ErrorDetail(org.mvel2.ErrorDetail) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Work(io.automatiko.engine.workflow.base.core.Work) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ThrowLinkNode(io.automatiko.engine.workflow.process.core.node.ThrowLinkNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ProcessValidationErrorImpl(io.automatiko.engine.workflow.base.core.validation.impl.ProcessValidationErrorImpl) ExpressionCompiler(org.mvel2.compiler.ExpressionCompiler) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) Split(io.automatiko.engine.workflow.process.core.node.Split) ParserContext(org.mvel2.ParserContext) Map(java.util.Map) HashMap(java.util.HashMap) NodeAndType(io.automatiko.engine.workflow.process.core.node.CompositeNode.NodeAndType) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) 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) Iterator(java.util.Iterator) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Connection(io.automatiko.engine.api.definition.process.Connection) Join(io.automatiko.engine.workflow.process.core.node.Join) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode)

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