Search in sources :

Example 41 with StartNode

use of org.jbpm.workflow.core.node.StartNode in project jbpm by kiegroup.

the class StartEventHandler method handleNode.

@SuppressWarnings("unchecked")
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    StartNode startNode = (StartNode) node;
    // TODO: StartEventHandler.handleNode(): the parser doesn't discriminate between the schema default and the actual set value
    // However, while the schema says the "isInterrupting" attr should default to true
    // The spec says that Escalation start events should default to not interrupting..
    startNode.setInterrupting(Boolean.parseBoolean(element.getAttribute("isInterrupting")));
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataOutput".equals(nodeName)) {
            readDataOutput(xmlNode, startNode);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, startNode);
        } else if ("outputSet".equals(nodeName)) {
            // p. 225, BPMN2 spec (2011-01-03)
            // InputSet and OutputSet elements imply that process execution should wait for them to be filled
            // and are therefore not applicable to catch events
            String message = "Ignoring <" + nodeName + "> element: " + "<" + nodeName + "> elements should not be used on start or other catch events.";
            SAXParseException saxpe = new SAXParseException(message, parser.getLocator());
            parser.warning(saxpe);
        // no exception thrown for backwards compatibility (we used to ignore these elements)
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            String constraint = null;
            org.w3c.dom.Node subNode = xmlNode.getFirstChild();
            while (subNode != null) {
                String subnodeName = subNode.getNodeName();
                if ("condition".equals(subnodeName)) {
                    constraint = xmlNode.getTextContent();
                    break;
                }
                subNode = subNode.getNextSibling();
            }
            ConstraintTrigger trigger = new ConstraintTrigger();
            trigger.setConstraint(constraint);
            startNode.addTrigger(trigger);
            break;
        } else if ("signalEventDefinition".equals(nodeName)) {
            String type = ((Element) xmlNode).getAttribute("signalRef");
            type = checkSignalAndConvertToRealSignalNam(parser, type);
            if (type != null && type.trim().length() > 0) {
                addTriggerWithInMappings(startNode, type);
            }
        } else if ("messageEventDefinition".equals(nodeName)) {
            String messageRef = ((Element) xmlNode).getAttribute("messageRef");
            Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
            if (messages == null) {
                throw new IllegalArgumentException("No messages found");
            }
            Message message = messages.get(messageRef);
            if (message == null) {
                throw new IllegalArgumentException("Could not find message " + messageRef);
            }
            startNode.setMetaData("MessageType", message.getType());
            addTriggerWithInMappings(startNode, "Message-" + messageRef);
        } else if ("timerEventDefinition".equals(nodeName)) {
            handleTimerNode(startNode, element, uri, localName, parser);
        // following event definitions are only for event sub process and will be validated to not be included in top process definitions
        } else if ("errorEventDefinition".equals(nodeName)) {
            if (!startNode.isInterrupting()) {
                // BPMN2 spec (p.245-246, (2011-01-03)) implies that
                // - a <startEvent> in an Event Sub-Process
                // - *without* the 'isInterupting' attribute always interrupts (containing process)
                String errorMsg = "Error Start Events in an Event Sub-Process always interrupt the containing (sub)process(es).";
                throw new IllegalArgumentException(errorMsg);
            }
            String errorRef = ((Element) xmlNode).getAttribute("errorRef");
            if (errorRef != null && errorRef.trim().length() > 0) {
                List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
                if (errors == null) {
                    throw new IllegalArgumentException("No errors found");
                }
                Error error = null;
                for (Error listError : errors) {
                    if (errorRef.equals(listError.getId())) {
                        error = listError;
                    }
                }
                if (error == null) {
                    throw new IllegalArgumentException("Could not find error " + errorRef);
                }
                startNode.setMetaData("FaultCode", error.getErrorCode());
                addTriggerWithInMappings(startNode, "Error-" + error.getErrorCode());
            }
        } else if ("escalationEventDefinition".equals(nodeName)) {
            String escalationRef = ((Element) xmlNode).getAttribute("escalationRef");
            if (escalationRef != null && escalationRef.trim().length() > 0) {
                Map<String, Escalation> escalations = (Map<String, Escalation>) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.ESCALATIONS);
                if (escalations == null) {
                    throw new IllegalArgumentException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new IllegalArgumentException("Could not find escalation " + escalationRef);
                }
                addTriggerWithInMappings(startNode, "Escalation-" + escalation.getEscalationCode());
            }
        } else if ("compensateEventDefinition".equals(nodeName)) {
            handleCompensationNode(startNode, element, xmlNode, parser);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) StartNode(org.jbpm.workflow.core.node.StartNode) Message(org.jbpm.bpmn2.core.Message) StartNode(org.jbpm.workflow.core.node.StartNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) Node(org.jbpm.workflow.core.Node) Element(org.w3c.dom.Element) Escalation(org.jbpm.bpmn2.core.Escalation) Error(org.jbpm.bpmn2.core.Error) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) SAXParseException(org.xml.sax.SAXParseException) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 42 with StartNode

use of org.jbpm.workflow.core.node.StartNode in project jbpm by kiegroup.

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.getNodeContainer();
        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.getNodeContainer();
        }
        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(org.jbpm.workflow.core.node.FaultNode) StartNode(org.jbpm.workflow.core.node.StartNode) EventNode(org.jbpm.workflow.core.node.EventNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EndNode(org.jbpm.workflow.core.node.EndNode) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) Join(org.jbpm.workflow.core.node.Join) NodeContainer(org.kie.api.definition.process.NodeContainer) Split(org.jbpm.workflow.core.node.Split) Constraint(org.jbpm.workflow.core.Constraint)

Example 43 with StartNode

use of org.jbpm.workflow.core.node.StartNode in project jbpm by kiegroup.

the class XmlBPMNProcessDumper method visitInterfaces.

protected void visitInterfaces(Node[] nodes, StringBuilder xmlDump) {
    for (Node node : nodes) {
        if (node instanceof WorkItemNode) {
            Work work = ((WorkItemNode) node).getWork();
            if (work != null) {
                if ("Service Task".equals(work.getName())) {
                    String interfaceName = (String) work.getParameter("Interface");
                    if (interfaceName == null) {
                        interfaceName = "";
                    }
                    String interfaceRef = (String) work.getParameter("interfaceImplementationRef");
                    if (interfaceRef == null) {
                        interfaceRef = "";
                    }
                    String operationName = (String) work.getParameter("Operation");
                    if (operationName == null) {
                        operationName = "";
                    }
                    String operationRef = (String) work.getParameter("operationImplementationRef");
                    if (operationRef == null) {
                        operationRef = "";
                    }
                    String parameterType = (String) work.getParameter("ParameterType");
                    if (parameterType == null) {
                        parameterType = "";
                    }
                    xmlDump.append("  <itemDefinition id=\"" + getUniqueNodeId(node) + "_InMessageType\" " + ("".equals(parameterType) || "java.lang.Object".equals(parameterType) ? "" : "structureRef=\"" + parameterType + "\" ") + "/>" + EOL + "  <message id=\"" + getUniqueNodeId(node) + "_InMessage\" itemRef=\"" + getUniqueNodeId(node) + "_InMessageType\" />" + EOL + "  <interface id=\"" + getUniqueNodeId(node) + "_ServiceInterface\" name=\"" + interfaceName + "\" implementationRef=\"" + interfaceRef + "\" >" + EOL + "    <operation id=\"" + getUniqueNodeId(node) + "_ServiceOperation\" name=\"" + operationName + "\" implementationRef=\"" + operationRef + "\" >" + EOL + "      <inMessageRef>" + getUniqueNodeId(node) + "_InMessage</inMessageRef>" + EOL + "    </operation>" + EOL + "  </interface>" + EOL + EOL);
                } else if ("Send Task".equals(work.getName())) {
                    String messageType = (String) work.getParameter("MessageType");
                    if (messageType == null) {
                        messageType = "";
                    }
                    xmlDump.append("  <itemDefinition id=\"" + getUniqueNodeId(node) + "_MessageType\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + getUniqueNodeId(node) + "_Message\" itemRef=\"" + getUniqueNodeId(node) + "_MessageType\" />" + EOL + EOL);
                } else if ("Receive Task".equals(work.getName())) {
                    String messageId = (String) work.getParameter("MessageId");
                    String messageType = (String) work.getParameter("MessageType");
                    if (messageType == null) {
                        messageType = "";
                    }
                    xmlDump.append("  <itemDefinition id=\"" + getUniqueNodeId(node) + "_MessageType\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + messageId + "\" itemRef=\"" + getUniqueNodeId(node) + "_MessageType\" />" + EOL + EOL);
                }
            }
        } else if (node instanceof EndNode) {
            String messageType = (String) node.getMetaData().get("MessageType");
            if (messageType != null) {
                xmlDump.append("  <itemDefinition id=\"" + getUniqueNodeId(node) + "_MessageType\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + getUniqueNodeId(node) + "_Message\" itemRef=\"" + getUniqueNodeId(node) + "_MessageType\" />" + EOL + EOL);
            }
        } else if (node instanceof ActionNode) {
            String messageType = (String) node.getMetaData().get("MessageType");
            if (messageType != null) {
                xmlDump.append("  <itemDefinition id=\"" + getUniqueNodeId(node) + "_MessageType\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + getUniqueNodeId(node) + "_Message\" itemRef=\"" + getUniqueNodeId(node) + "_MessageType\" />" + EOL + EOL);
            }
        } else if (node instanceof EventNode) {
            List<EventFilter> filters = ((EventNode) node).getEventFilters();
            if (filters.size() > 0) {
                String messageRef = ((EventTypeFilter) filters.get(0)).getType();
                if (messageRef.startsWith("Message-")) {
                    messageRef = messageRef.substring(8);
                    String messageType = (String) node.getMetaData().get("MessageType");
                    xmlDump.append("  <itemDefinition id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageRef) + "Type\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageRef) + "\" itemRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageRef) + "Type\" />" + EOL + EOL);
                }
            }
        } else if (node instanceof StartNode) {
            StartNode startNode = (StartNode) node;
            if (startNode.getTriggers() != null && !startNode.getTriggers().isEmpty()) {
                Trigger trigger = startNode.getTriggers().get(0);
                if (trigger instanceof EventTrigger) {
                    String eventType = ((EventTypeFilter) ((EventTrigger) trigger).getEventFilters().get(0)).getType();
                    if (eventType.startsWith("Message-")) {
                        eventType = eventType.substring(8);
                        String messageType = (String) node.getMetaData().get("MessageType");
                        xmlDump.append("  <itemDefinition id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(eventType) + "Type\" " + ("".equals(messageType) || "java.lang.Object".equals(messageType) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(messageType) + "\" ") + "/>" + EOL + "  <message id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(eventType) + "\" itemRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(eventType) + "Type\" />" + EOL + EOL);
                    }
                }
            }
        } else if (node instanceof ForEachNode) {
            ForEachNode forEachNode = (ForEachNode) node;
            String type = null;
            if (forEachNode.getVariableType() instanceof ObjectDataType) {
                type = ((ObjectDataType) forEachNode.getVariableType()).getClassName();
            }
            xmlDump.append("  <itemDefinition id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_multiInstanceItemType\" " + (type == null || "java.lang.Object".equals(type) ? "" : "structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\" ") + "/>" + EOL + EOL);
        }
        if (node instanceof CompositeNode) {
            visitInterfaces(((CompositeNode) node).getNodes(), xmlDump);
        }
    }
}
Also used : StartNode(org.jbpm.workflow.core.node.StartNode) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) EventNode(org.jbpm.workflow.core.node.EventNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) Trigger(org.jbpm.workflow.core.node.Trigger) EndNode(org.jbpm.workflow.core.node.EndNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Work(org.jbpm.process.core.Work) List(java.util.List) ArrayList(java.util.ArrayList) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) EventTrigger(org.jbpm.workflow.core.node.EventTrigger)

Example 44 with StartNode

use of org.jbpm.workflow.core.node.StartNode in project jbpm by kiegroup.

the class ProcessHandler method postProcessNodes.

private void postProcessNodes(RuleFlowProcess process, NodeContainer container) {
    List<String> eventSubProcessHandlers = new ArrayList<String>();
    for (Node node : container.getNodes()) {
        if (node instanceof StateNode) {
            StateNode stateNode = (StateNode) node;
            String condition = (String) stateNode.getMetaData("Condition");
            Constraint constraint = new ConstraintImpl();
            constraint.setConstraint(condition);
            constraint.setType("rule");
            for (org.kie.api.definition.process.Connection connection : stateNode.getDefaultOutgoingConnections()) {
                stateNode.setConstraint(connection, constraint);
            }
        } else if (node instanceof NodeContainer) {
            // prepare event sub process
            if (node instanceof EventSubProcessNode) {
                EventSubProcessNode eventSubProcessNode = (EventSubProcessNode) node;
                Node[] nodes = eventSubProcessNode.getNodes();
                for (Node subNode : nodes) {
                    // avoids cyclomatic complexity
                    if (subNode == null || !(subNode instanceof StartNode)) {
                        continue;
                    }
                    List<Trigger> triggers = ((StartNode) subNode).getTriggers();
                    if (triggers == null) {
                        continue;
                    }
                    for (Trigger trigger : triggers) {
                        if (trigger instanceof EventTrigger) {
                            final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
                            for (EventFilter filter : filters) {
                                if (filter instanceof EventTypeFilter) {
                                    eventSubProcessNode.addEvent((EventTypeFilter) filter);
                                    String type = ((EventTypeFilter) filter).getType();
                                    if (type.startsWith("Error-") || type.startsWith("Escalation")) {
                                        String faultCode = (String) subNode.getMetaData().get("FaultCode");
                                        String replaceRegExp = "Error-|Escalation-";
                                        final String signalType = type;
                                        ExceptionScope exceptionScope = (ExceptionScope) ((ContextContainer) eventSubProcessNode.getNodeContainer()).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
                                        if (exceptionScope == null) {
                                            exceptionScope = new ExceptionScope();
                                            ((ContextContainer) eventSubProcessNode.getNodeContainer()).addContext(exceptionScope);
                                            ((ContextContainer) eventSubProcessNode.getNodeContainer()).setDefaultContext(exceptionScope);
                                        }
                                        String faultVariable = null;
                                        if (trigger.getInAssociations() != null && !trigger.getInAssociations().isEmpty()) {
                                            faultVariable = trigger.getInAssociations().get(0).getTarget();
                                        }
                                        ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
                                        DroolsConsequenceAction action = new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + signalType + "\", " + (faultVariable == null ? "null" : "kcontext.getVariable(\"" + faultVariable + "\")") + ");");
                                        exceptionHandler.setAction(action);
                                        exceptionHandler.setFaultVariable(faultVariable);
                                        if (faultCode != null) {
                                            String trimmedType = type.replaceFirst(replaceRegExp, "");
                                            exceptionScope.setExceptionHandler(trimmedType, exceptionHandler);
                                            eventSubProcessHandlers.add(trimmedType);
                                        } else {
                                            exceptionScope.setExceptionHandler(faultCode, exceptionHandler);
                                        }
                                    } else if (type.equals("Compensation")) {
                                        // 1. Find the parent sub-process to this event sub-process
                                        NodeContainer parentSubProcess;
                                        NodeContainer subProcess = eventSubProcessNode.getNodeContainer();
                                        Object isForCompensationObj = eventSubProcessNode.getMetaData("isForCompensation");
                                        if (isForCompensationObj == null) {
                                            eventSubProcessNode.setMetaData("isForCompensation", true);
                                            logger.warn("Overriding empty or false value of \"isForCompensation\" attribute on Event Sub-Process [" + eventSubProcessNode.getMetaData("UniqueId") + "] and setting it to true.");
                                        }
                                        if (subProcess instanceof RuleFlowProcess) {
                                            // ..how do you expect to signal compensation on the completed process (instance)?!?
                                            throw new IllegalArgumentException("Compensation Event Sub-Processes at the process level are not supported.");
                                        }
                                        parentSubProcess = ((Node) subProcess).getNodeContainer();
                                        // 2. The event filter (never fires, purely for dumping purposes) has already been added
                                        // 3. Add compensation scope
                                        String compensationHandlerId = (String) ((CompositeNode) subProcess).getMetaData("UniqueId");
                                        addCompensationScope(process, eventSubProcessNode, parentSubProcess, compensationHandlerId);
                                    }
                                }
                            }
                        } else if (trigger instanceof ConstraintTrigger) {
                            ConstraintTrigger constraintTrigger = (ConstraintTrigger) trigger;
                            if (constraintTrigger.getConstraint() != null) {
                                String processId = ((RuleFlowProcess) container).getId();
                                String type = "RuleFlowStateEventSubProcess-Event-" + processId + "-" + eventSubProcessNode.getUniqueId();
                                EventTypeFilter eventTypeFilter = new EventTypeFilter();
                                eventTypeFilter.setType(type);
                                eventSubProcessNode.addEvent(eventTypeFilter);
                            }
                        }
                    }
                }
            // for( Node subNode : nodes)
            }
            postProcessNodes(process, (NodeContainer) node);
        } else if (node instanceof EndNode) {
            handleIntermediateOrEndThrowCompensationEvent((EndNode) node);
        } else if (node instanceof ActionNode) {
            handleIntermediateOrEndThrowCompensationEvent((ActionNode) node);
        } else if (node instanceof EventNode) {
            final EventNode eventNode = (EventNode) node;
            if (!(eventNode instanceof BoundaryEventNode) && eventNode.getDefaultIncomingConnections().size() == 0) {
                throw new IllegalArgumentException("Event node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection");
            }
        }
    }
    // process fault node to disable termnate parent if there is event subprocess handler
    for (Node node : container.getNodes()) {
        if (node instanceof FaultNode) {
            FaultNode faultNode = (FaultNode) node;
            if (eventSubProcessHandlers.contains(faultNode.getFaultName())) {
                faultNode.setTerminateParent(false);
            }
        }
    }
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) Constraint(org.jbpm.workflow.core.Constraint) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateNode(org.jbpm.workflow.core.node.StateNode) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) ArrayList(java.util.ArrayList) StateNode(org.jbpm.workflow.core.node.StateNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) NodeContainer(org.kie.api.definition.process.NodeContainer) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) Trigger(org.jbpm.workflow.core.node.Trigger) ConstraintImpl(org.jbpm.workflow.core.impl.ConstraintImpl) List(java.util.List) ArrayList(java.util.ArrayList) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) StartNode(org.jbpm.workflow.core.node.StartNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) FaultNode(org.jbpm.workflow.core.node.FaultNode) ContextContainer(org.jbpm.process.core.ContextContainer) EndNode(org.jbpm.workflow.core.node.EndNode)

Example 45 with StartNode

use of org.jbpm.workflow.core.node.StartNode in project jbpm by kiegroup.

the class SingleSessionCommandServiceTest method getProcessTimer2.

private List<KiePackage> getProcessTimer2() {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.test.TestProcess");
    process.setName("TestProcess");
    process.setPackageName("org.drools.test");
    StartNode start = new StartNode();
    start.setId(1);
    start.setName("Start");
    process.addNode(start);
    TimerNode timerNode = new TimerNode();
    timerNode.setId(2);
    timerNode.setName("Timer");
    Timer timer = new Timer();
    timer.setDelay("0");
    timerNode.setTimer(timer);
    process.addNode(timerNode);
    new ConnectionImpl(start, Node.CONNECTION_DEFAULT_TYPE, timerNode, Node.CONNECTION_DEFAULT_TYPE);
    ActionNode actionNode = new ActionNode();
    actionNode.setId(3);
    actionNode.setName("Action");
    DroolsConsequenceAction action = new DroolsConsequenceAction();
    action.setDialect("java");
    action.setConsequence("try { Thread.sleep(1000); } catch (Throwable t) {} System.out.println(\"Executed action\");");
    actionNode.setAction(action);
    process.addNode(actionNode);
    new ConnectionImpl(timerNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
    EndNode end = new EndNode();
    end.setId(6);
    end.setName("End");
    process.addNode(end);
    new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, end, Node.CONNECTION_DEFAULT_TYPE);
    KnowledgeBuilderImpl packageBuilder = new KnowledgeBuilderImpl();
    ProcessBuilderImpl processBuilder = new ProcessBuilderImpl(packageBuilder);
    processBuilder.buildProcess(process, null);
    return Arrays.asList(packageBuilder.getPackages());
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) Timer(org.jbpm.process.core.timer.Timer) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) EndNode(org.jbpm.workflow.core.node.EndNode) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) ActionNode(org.jbpm.workflow.core.node.ActionNode) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) TimerNode(org.jbpm.workflow.core.node.TimerNode) ProcessBuilderImpl(org.jbpm.compiler.ProcessBuilderImpl)

Aggregations

StartNode (org.jbpm.workflow.core.node.StartNode)47 EndNode (org.jbpm.workflow.core.node.EndNode)34 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)32 ActionNode (org.jbpm.workflow.core.node.ActionNode)30 ArrayList (java.util.ArrayList)25 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)24 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)19 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)18 Test (org.junit.Test)18 DroolsAction (org.jbpm.workflow.core.DroolsAction)17 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)17 Action (org.jbpm.process.instance.impl.Action)16 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)16 EventNode (org.jbpm.workflow.core.node.EventNode)16 KieSession (org.kie.api.runtime.KieSession)16 ProcessContext (org.kie.api.runtime.process.ProcessContext)16 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)15 Variable (org.jbpm.process.core.context.variable.Variable)14 Work (org.jbpm.process.core.Work)11 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)11