Search in sources :

Example 1 with Node

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

the class WorkingMemoryLogger method createNodeId.

private String createNodeId(NodeInstance nodeInstance) {
    Node node = nodeInstance.getNode();
    if (node == null) {
        return "";
    }
    Object uniqueIdObj = node.getMetaData().get("UniqueId");
    String nodeId;
    if (uniqueIdObj == null) {
        nodeId = "" + node.getId();
    } else {
        nodeId = (String) uniqueIdObj;
    }
    NodeContainer nodeContainer = node.getNodeContainer();
    while (nodeContainer != null) {
        if (nodeContainer instanceof Node) {
            node = (Node) nodeContainer;
            nodeContainer = node.getNodeContainer();
            // TODO fix this filter out hidden compositeNode inside ForEach node
            if (!(nodeContainer.getClass().getName().endsWith("ForEachNode"))) {
                nodeId = node.getId() + ":" + nodeId;
            }
        } else {
            break;
        }
    }
    return nodeId;
}
Also used : Node(org.kie.api.definition.process.Node) NodeContainer(org.kie.api.definition.process.NodeContainer)

Example 2 with Node

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

the class ProcessBuilderImpl method generateRules.

private String generateRules(final Process process) {
    StringBuffer builder = new StringBuffer();
    if (process instanceof WorkflowProcessImpl) {
        WorkflowProcessImpl ruleFlow = (WorkflowProcessImpl) process;
        builder.append("package " + ruleFlow.getPackageName() + "\n");
        Set<String> imports = ruleFlow.getImports();
        if (imports != null) {
            for (String importString : imports) {
                builder.append("import " + importString + ";\n");
            }
        }
        List<String> functionImports = ruleFlow.getFunctionImports();
        if (functionImports != null) {
            for (String importString : functionImports) {
                builder.append("import function " + importString + ";\n");
            }
        }
        Map<String, String> globals = ruleFlow.getGlobals();
        if (globals != null) {
            for (Map.Entry<String, String> entry : globals.entrySet()) {
                builder.append("global " + entry.getValue() + " " + entry.getKey() + ";\n");
            }
        }
        Node[] nodes = ruleFlow.getNodes();
        generateRules(nodes, process, builder);
    }
    return builder.toString();
}
Also used : DynamicNode(org.jbpm.workflow.core.node.DynamicNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateNode(org.jbpm.workflow.core.node.StateNode) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) WorkflowProcessImpl(org.jbpm.workflow.core.impl.WorkflowProcessImpl) Map(java.util.Map)

Example 3 with Node

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

the class XmlWorkflowProcessDumper method visitConnections.

private void visitConnections(Node[] nodes, StringBuilder xmlDump, boolean includeMeta) {
    List<Connection> connections = new ArrayList<Connection>();
    for (Node node : nodes) {
        for (List<Connection> connectionList : node.getIncomingConnections().values()) {
            connections.addAll(connectionList);
        }
    }
    xmlDump.append("  <connections>" + EOL);
    for (Connection connection : connections) {
        visitConnection(connection, xmlDump, includeMeta);
    }
    xmlDump.append("  </connections>" + EOL + EOL);
}
Also used : Node(org.kie.api.definition.process.Node) Connection(org.kie.api.definition.process.Connection) ArrayList(java.util.ArrayList)

Example 4 with Node

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

the class ChecklistItemFactory method getRelevantNodes.

private static void getRelevantNodes(NodeContainer container, Map<String, String> result) {
    for (Node node : container.getNodes()) {
        if (node instanceof NodeContainer) {
            getRelevantNodes((NodeContainer) node, result);
        }
        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);
                String nodeId = (String) node.getMetaData().get("UniqueId");
                if (nodeId == null) {
                    nodeId = ((NodeImpl) node).getUniqueId();
                }
                result.put(nodeId, orderingNumber);
            }
        }
    }
}
Also used : HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) StartNode(org.jbpm.workflow.core.node.StartNode) Node(org.kie.api.definition.process.Node) NodeContainer(org.kie.api.definition.process.NodeContainer)

Example 5 with Node

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

the class ProcessServiceImpl method getActiveBoundaryNodesSignals.

protected List<String> getActiveBoundaryNodesSignals(ProcessInstance processInstance, Collection<NodeInstance> activeNodes) {
    WorkflowProcessInstance workflowProcessInstance = (WorkflowProcessInstance) processInstance;
    ArrayList<Node> processNodesList = new ArrayList(Arrays.asList(((RuleFlowProcessInstance) workflowProcessInstance).getNodeContainer().getNodes()));
    List<String> activeBoundaryNodesSignals = new ArrayList<>();
    Map<String, NodeInstance> uniqueIdNodeInstanceMap = new HashMap<>();
    for (NodeInstance activeNode : activeNodes) {
        uniqueIdNodeInstanceMap.put((String) activeNode.getNode().getMetaData().get("UniqueId"), activeNode);
    }
    try {
        for (Node processNode : processNodesList) {
            if (processNode instanceof BoundaryEventNode && uniqueIdNodeInstanceMap.containsKey(((BoundaryEventNode) processNode).getAttachedToNodeId())) {
                activeBoundaryNodesSignals.add(VariableUtil.resolveVariable((String) processNode.getMetaData().get("SignalName"), uniqueIdNodeInstanceMap.get(((BoundaryEventNode) processNode).getAttachedToNodeId())));
            }
        }
        return activeBoundaryNodesSignals;
    } catch (Exception e) {
        logger.debug("Unable to retrieve boundary event nodes for active nodes in processInstance {}", processInstance.getId());
        return new ArrayList<>();
    }
}
Also used : HashMap(java.util.HashMap) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) Node(org.kie.api.definition.process.Node) ArrayList(java.util.ArrayList) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) NodeInstance(org.kie.api.runtime.process.NodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException)

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