Search in sources :

Example 6 with StateNode

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

the class IntermediateCatchEventHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node
    // can be generated
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleSignalNode(node, element, uri, localName, parser);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleMessageNode(node, element, uri, localName, parser);
            break;
        } else if ("timerEventDefinition".equals(nodeName)) {
            // create new timerNode
            TimerNode timerNode = new TimerNode();
            timerNode.setId(node.getId());
            timerNode.setName(node.getName());
            timerNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = timerNode;
            handleTimerNode(node, element, uri, localName, parser);
            break;
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            // create new stateNode
            StateNode stateNode = new StateNode();
            stateNode.setId(node.getId());
            stateNode.setName(node.getName());
            stateNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = stateNode;
            handleStateNode(node, element, uri, localName, parser);
            break;
        } else if ("linkEventDefinition".equals(nodeName)) {
            CatchLinkNode linkNode = new CatchLinkNode();
            linkNode.setId(node.getId());
            node = linkNode;
            handleLinkNode(element, node, xmlNode, parser);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) TimerNode(org.jbpm.workflow.core.node.TimerNode) StateNode(org.jbpm.workflow.core.node.StateNode) CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.jbpm.workflow.core.Node) StateNode(org.jbpm.workflow.core.node.StateNode) NodeContainer(org.jbpm.workflow.core.NodeContainer) TimerNode(org.jbpm.workflow.core.node.TimerNode)

Example 7 with StateNode

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

the class StateNodeHandler method handleNode.

public 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);
    StateNode stateNode = (StateNode) node;
    for (String eventType : stateNode.getActionTypes()) {
        handleAction(stateNode, element, eventType);
    }
}
Also used : StateNode(org.jbpm.workflow.core.node.StateNode)

Example 8 with StateNode

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

the class StateNodeInstance method internalTrigger.

public void internalTrigger(NodeInstance from, String type) {
    super.internalTrigger(from, type);
    // if node instance was cancelled, abort
    if (getNodeInstanceContainer().getNodeInstance(getId()) == null) {
        return;
    }
    // TODO: composite states trigger
    StateNode stateNode = getStateNode();
    Connection selected = null;
    int priority = Integer.MAX_VALUE;
    for (Connection connection : stateNode.getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
        Constraint constraint = stateNode.getConstraint(connection);
        if (constraint != null && constraint.getPriority() < priority) {
            String rule = "RuleFlowStateNode-" + getProcessInstance().getProcessId() + "-" + getStateNode().getUniqueId() + "-" + connection.getTo().getId() + "-" + connection.getToType();
            boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()).isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId());
            if (isActive) {
                selected = connection;
                priority = constraint.getPriority();
            }
        }
    }
    if (selected != null) {
        ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
        triggerConnection(selected);
    } else {
        addTriggerListener();
        addActivationListener();
    }
}
Also used : InternalAgenda(org.drools.core.common.InternalAgenda) NodeInstanceContainer(org.jbpm.workflow.instance.NodeInstanceContainer) Constraint(org.jbpm.workflow.core.Constraint) StateNode(org.jbpm.workflow.core.node.StateNode) Connection(org.kie.api.definition.process.Connection) Constraint(org.jbpm.workflow.core.Constraint)

Example 9 with StateNode

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

the class ProcessBuilderImpl method generateRules.

private void generateRules(Node[] nodes, Process process, StringBuffer builder) {
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] instanceof Split) {
            Split split = (Split) nodes[i];
            if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
                for (Connection connection : split.getDefaultOutgoingConnections()) {
                    Constraint constraint = split.getConstraint(connection);
                    if (constraint != null && "rule".equals(constraint.getType())) {
                        builder.append(createSplitRule(process, connection, split.getConstraint(connection).getConstraint()));
                    }
                }
            }
        } else if (nodes[i] instanceof MilestoneNode) {
            MilestoneNode milestone = (MilestoneNode) nodes[i];
            builder.append(createMilestoneRule(process, milestone));
        } else if (nodes[i] instanceof StateNode) {
            StateNode state = (StateNode) nodes[i];
            builder.append(createStateRules(process, state));
        } else if (nodes[i] instanceof StartNode) {
            StartNode startNode = (StartNode) nodes[i];
            List<Trigger> triggers = startNode.getTriggers();
            if (triggers != null) {
                for (Trigger trigger : triggers) {
                    if (trigger instanceof ConstraintTrigger) {
                        builder.append(createStartConstraintRule(process, startNode.getNodeContainer(), (ConstraintTrigger) trigger));
                    }
                }
            }
        } else if (nodes[i] instanceof NodeContainer) {
            generateRules(((NodeContainer) nodes[i]).getNodes(), process, builder);
            if (nodes[i] instanceof DynamicNode && "rule".equals(((DynamicNode) nodes[i]).getLanguage())) {
                DynamicNode dynamicNode = (DynamicNode) nodes[i];
                if (dynamicNode.getCompletionExpression() != null) {
                    builder.append(createAdHocCompletionRule(process, dynamicNode));
                }
                if (dynamicNode.getActivationExpression() != null && !dynamicNode.getActivationExpression().isEmpty()) {
                    builder.append(createAdHocActivationRule(process, dynamicNode));
                }
            }
        } else if (nodes[i] instanceof EventNode) {
            EventNode state = (EventNode) nodes[i];
            builder.append(createEventStateRule(process, state));
        }
    }
}
Also used : ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) StartNode(org.jbpm.workflow.core.node.StartNode) Constraint(org.jbpm.workflow.core.Constraint) Connection(org.kie.api.definition.process.Connection) StateNode(org.jbpm.workflow.core.node.StateNode) NodeContainer(org.kie.api.definition.process.NodeContainer) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode) Constraint(org.jbpm.workflow.core.Constraint) EventNode(org.jbpm.workflow.core.node.EventNode) ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) Trigger(org.jbpm.workflow.core.node.Trigger) List(java.util.List) ArrayList(java.util.ArrayList) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) Split(org.jbpm.workflow.core.node.Split)

Example 10 with StateNode

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

the class StateNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    StateNode stateNode = (StateNode) node;
    String condition = (String) stateNode.getMetaData("Condition");
    writeNode("intermediateCatchEvent", stateNode, xmlDump, metaDataType);
    xmlDump.append(">" + EOL);
    writeExtensionElements(node, xmlDump);
    xmlDump.append("      <conditionalEventDefinition>" + EOL);
    xmlDump.append("        <condition xsi:type=\"tFormalExpression\" language=\"" + XmlBPMNProcessDumper.RULE_LANGUAGE + "\">" + XmlDumper.replaceIllegalChars(condition) + "</condition>" + EOL);
    xmlDump.append("      </conditionalEventDefinition>" + EOL);
    endNode("intermediateCatchEvent", xmlDump);
}
Also used : StateNode(org.jbpm.workflow.core.node.StateNode)

Aggregations

StateNode (org.jbpm.workflow.core.node.StateNode)11 EventNode (org.jbpm.workflow.core.node.EventNode)6 Constraint (org.jbpm.workflow.core.Constraint)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 ArrayList (java.util.ArrayList)4 ActionNode (org.jbpm.workflow.core.node.ActionNode)4 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)4 EndNode (org.jbpm.workflow.core.node.EndNode)4 FaultNode (org.jbpm.workflow.core.node.FaultNode)4 MilestoneNode (org.jbpm.workflow.core.node.MilestoneNode)4 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)4 Split (org.jbpm.workflow.core.node.Split)4 SubProcessNode (org.jbpm.workflow.core.node.SubProcessNode)4 TimerNode (org.jbpm.workflow.core.node.TimerNode)4 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)4 List (java.util.List)3 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)3 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)3 Node (org.jbpm.workflow.core.Node)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3