Search in sources :

Example 46 with Node

use of org.kie.api.definition.process.Node in project jbpm by kiegroup.

the class CompositeNode method removeOutgoingConnection.

public void removeOutgoingConnection(String type, Connection connection) {
    super.removeOutgoingConnection(type, connection);
    CompositeNode.NodeAndType nodeAndType = internalGetLinkedOutgoingNode(type);
    if (nodeAndType != null) {
        for (Connection outConnection : nodeAndType.getNode().getOutgoingConnections(nodeAndType.getType())) {
            if (((CompositeNodeEnd) outConnection.getTo()).getOutNodeId() == connection.getTo().getId()) {
                Node compositeNodeEnd = outConnection.getTo();
                ((ConnectionImpl) outConnection).terminate();
                internalRemoveNode(compositeNodeEnd);
                return;
            }
        }
        throw new IllegalArgumentException("Could not find internal outgoing connection for node");
    }
}
Also used : Node(org.kie.api.definition.process.Node) Connection(org.kie.api.definition.process.Connection) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl)

Example 47 with Node

use of org.kie.api.definition.process.Node in project jbpm by kiegroup.

the class XmlWorkflowProcessDumper method visitNodes.

private void visitNodes(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) {
    xmlDump.append("  <nodes>" + EOL);
    for (Node node : process.getNodes()) {
        visitNode(node, xmlDump, includeMeta);
    }
    xmlDump.append("  </nodes>" + EOL + EOL);
}
Also used : Node(org.kie.api.definition.process.Node)

Example 48 with Node

use of org.kie.api.definition.process.Node in project jbpm by kiegroup.

the class ConnectionHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    String fromId = attrs.getValue("from");
    emptyAttributeCheck(localName, "from", fromId, parser);
    String toId = attrs.getValue("to");
    emptyAttributeCheck(localName, "to", toId, parser);
    String bendpoints = attrs.getValue("bendpoints");
    String fromType = attrs.getValue("fromType");
    if (fromType == null || fromType.trim().length() == 0) {
        fromType = NodeImpl.CONNECTION_DEFAULT_TYPE;
    }
    String toType = attrs.getValue("toType");
    if (toType == null || toType.trim().length() == 0) {
        toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    Node fromNode = nodeContainer.getNode(new Long(fromId));
    Node toNode = nodeContainer.getNode(new Long(toId));
    if (fromNode == null) {
        throw new SAXParseException("Node '" + fromId + "'cannot be found", parser.getLocator());
    }
    if (toNode == null) {
        throw new SAXParseException("Node '" + toId + "' cannot be found", parser.getLocator());
    }
    ConnectionImpl connection = new ConnectionImpl(fromNode, fromType, toNode, toType);
    connection.setMetaData("bendpoints", bendpoints);
    return connection;
}
Also used : SAXParseException(org.xml.sax.SAXParseException) Node(org.kie.api.definition.process.Node) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) NodeContainer(org.jbpm.workflow.core.NodeContainer)

Example 49 with Node

use of org.kie.api.definition.process.Node in project jbpm by kiegroup.

the class ChecklistItemFactory method getPendingChecklistItems.

private static void getPendingChecklistItems(NodeContainer container, List<ChecklistItem> result, String processId) {
    for (Node node : container.getNodes()) {
        if (node instanceof HumanTaskNode) {
            Work workItem = ((HumanTaskNode) node).getWork();
            int priority = 0;
            String priorityString = (String) workItem.getParameter("Priority");
            if (priorityString != null) {
                try {
                    priority = new Integer(priorityString);
                } catch (NumberFormatException e) {
                // Do nothing
                }
            }
            String actorId = (String) workItem.getParameter("ActorId");
            if (actorId != null && actorId.trim().length() == 0) {
                actorId = null;
            }
            String groupId = (String) workItem.getParameter("GroupId");
            if (groupId != null && groupId.trim().length() == 0) {
                groupId = null;
            }
            String actors = null;
            if (actorId == null) {
                if (groupId == null) {
                    actors = "";
                } else {
                    actors = groupId;
                }
            } else {
                if (groupId == null) {
                    actors = actorId;
                } else {
                    actors = actorId + "," + groupId;
                }
            }
            Status status = Status.Pending;
            if (((HumanTaskNode) node).getDefaultIncomingConnections().size() == 0) {
                status = Status.Optional;
            }
            result.add(createChecklistItem((String) workItem.getParameter("TaskName"), "HumanTaskNode", actors, (String) workItem.getParameter("Comment"), priority, processId, status));
        } else if (node instanceof NodeContainer) {
            getPendingChecklistItems((NodeContainer) node, result, processId);
        } else {
            String docs = (String) node.getMetaData().get("Documentation");
            if (docs != null) {
                int position = docs.indexOf("OrderingNb=");
                if (position >= 0) {
                    int end = docs.indexOf(";", position + 1);
                    String orderingNumber = docs.substring(position + 11, end);
                    Status status = Status.Pending;
                    if (((NodeImpl) node).getDefaultIncomingConnections().size() == 0 && !(node instanceof StartNode)) {
                        status = Status.Optional;
                    }
                    result.add(createChecklistItem(node.getName(), node.getClass().getSimpleName(), "", orderingNumber, 0, processId, status));
                }
            }
        }
    }
}
Also used : Status(org.jbpm.examples.checklist.ChecklistItem.Status) StartNode(org.jbpm.workflow.core.node.StartNode) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) StartNode(org.jbpm.workflow.core.node.StartNode) Node(org.kie.api.definition.process.Node) Work(org.jbpm.process.core.Work) NodeContainer(org.kie.api.definition.process.NodeContainer) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode)

Example 50 with Node

use of org.kie.api.definition.process.Node in project jbpm by kiegroup.

the class ProcessRuntimeImpl method initProcessEventListener.

private void initProcessEventListener(Process process) {
    if (process instanceof RuleFlowProcess) {
        for (Node node : ((RuleFlowProcess) process).getNodes()) {
            if (node instanceof StartNode) {
                StartNode startNode = (StartNode) node;
                if (startNode != null) {
                    List<Trigger> triggers = startNode.getTriggers();
                    if (triggers != null) {
                        for (Trigger trigger : triggers) {
                            if (trigger instanceof EventTrigger) {
                                final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
                                String type = null;
                                for (EventFilter filter : filters) {
                                    if (filter instanceof EventTypeFilter) {
                                        type = ((EventTypeFilter) filter).getType();
                                    }
                                }
                                StartProcessEventListener listener = new StartProcessEventListener(process.getId(), filters, trigger.getInMappings(), startNode.getEventTransformer());
                                signalManager.addEventListener(type, listener);
                                ((RuleFlowProcess) process).getRuntimeMetaData().put("StartProcessEventType", type);
                                ((RuleFlowProcess) process).getRuntimeMetaData().put("StartProcessEventListener", listener);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) Trigger(org.jbpm.workflow.core.node.Trigger) StartNode(org.jbpm.workflow.core.node.StartNode) Node(org.kie.api.definition.process.Node) EventFilter(org.jbpm.process.core.event.EventFilter) EventTrigger(org.jbpm.workflow.core.node.EventTrigger)

Aggregations

Node (org.kie.api.definition.process.Node)70 StartNode (org.jbpm.workflow.core.node.StartNode)27 EventNode (org.jbpm.workflow.core.node.EventNode)26 ActionNode (org.jbpm.workflow.core.node.ActionNode)25 EndNode (org.jbpm.workflow.core.node.EndNode)25 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)22 ArrayList (java.util.ArrayList)20 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)20 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)19 FaultNode (org.jbpm.workflow.core.node.FaultNode)17 HumanTaskNode (org.jbpm.workflow.core.node.HumanTaskNode)17 StateBasedNode (org.jbpm.workflow.core.node.StateBasedNode)15 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)13 NodeContainer (org.kie.api.definition.process.NodeContainer)13 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)11 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)11 StateNode (org.jbpm.workflow.core.node.StateNode)11 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)10 SubProcessNode (org.jbpm.workflow.core.node.SubProcessNode)10 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)10