Search in sources :

Example 21 with Connection

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

the class CompositeNode method removeIncomingConnection.

public void removeIncomingConnection(String type, Connection connection) {
    super.removeIncomingConnection(type, connection);
    CompositeNode.NodeAndType nodeAndType = internalGetLinkedIncomingNode(type);
    if (nodeAndType != null) {
        for (Connection inConnection : nodeAndType.getNode().getIncomingConnections(nodeAndType.getType())) {
            if (((CompositeNodeStart) inConnection.getFrom()).getInNodeId() == connection.getFrom().getId()) {
                Node compositeNodeStart = inConnection.getFrom();
                ((ConnectionImpl) inConnection).terminate();
                internalRemoveNode(compositeNodeStart);
                return;
            }
        }
        throw new IllegalArgumentException("Could not find internal incoming 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 22 with Connection

use of org.kie.api.definition.process.Connection 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 23 with Connection

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

the class CompositeNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    super.writeNode(getNodeName(), node, xmlDump, includeMeta);
    CompositeNode compositeNode = (CompositeNode) node;
    writeAttributes(compositeNode, xmlDump, includeMeta);
    xmlDump.append(">" + EOL);
    if (includeMeta) {
        writeMetaData(compositeNode, xmlDump);
    }
    for (String eventType : compositeNode.getActionTypes()) {
        writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
    }
    writeTimers(compositeNode.getTimers(), xmlDump);
    if (compositeNode instanceof CompositeContextNode) {
        VariableScope variableScope = (VariableScope) ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        if (variableScope != null) {
            List<Variable> variables = variableScope.getVariables();
            XmlWorkflowProcessDumper.visitVariables(variables, xmlDump);
        }
        ExceptionScope exceptionScope = (ExceptionScope) ((CompositeContextNode) compositeNode).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
        if (exceptionScope != null) {
            XmlWorkflowProcessDumper.visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
        }
    }
    List<Node> subNodes = getSubNodes(compositeNode);
    xmlDump.append("      <nodes>" + EOL);
    for (Node subNode : subNodes) {
        XmlRuleFlowProcessDumper.INSTANCE.visitNode(subNode, xmlDump, includeMeta);
    }
    xmlDump.append("      </nodes>" + EOL);
    List<Connection> connections = getSubConnections(compositeNode);
    xmlDump.append("      <connections>" + EOL);
    for (Connection connection : connections) {
        XmlRuleFlowProcessDumper.INSTANCE.visitConnection(connection, xmlDump, includeMeta);
    }
    xmlDump.append("      </connections>" + EOL);
    Map<String, CompositeNode.NodeAndType> inPorts = getInPorts(compositeNode);
    xmlDump.append("      <in-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : inPorts.entrySet()) {
        xmlDump.append("        <in-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeInType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </in-ports>" + EOL);
    Map<String, CompositeNode.NodeAndType> outPorts = getOutPorts(compositeNode);
    xmlDump.append("      <out-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : outPorts.entrySet()) {
        xmlDump.append("        <out-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeOutType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </out-ports>" + EOL);
    endNode(getNodeName(), xmlDump);
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Node(org.jbpm.workflow.core.Node) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) Connection(org.kie.api.definition.process.Connection) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) Map(java.util.Map) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 24 with Connection

use of org.kie.api.definition.process.Connection 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)

Aggregations

Connection (org.kie.api.definition.process.Connection)24 ArrayList (java.util.ArrayList)10 Node (org.kie.api.definition.process.Node)10 Map (java.util.Map)6 Constraint (org.jbpm.workflow.core.Constraint)6 HashMap (java.util.HashMap)5 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)5 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)5 EventNode (org.jbpm.workflow.core.node.EventNode)5 Split (org.jbpm.workflow.core.node.Split)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 InternalKnowledgeRuntime (org.drools.core.common.InternalKnowledgeRuntime)4 ActionNode (org.jbpm.workflow.core.node.ActionNode)4 EndNode (org.jbpm.workflow.core.node.EndNode)4 List (java.util.List)3 FaultNode (org.jbpm.workflow.core.node.FaultNode)3 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)3 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)3 NodeInstanceContainer (org.jbpm.workflow.instance.NodeInstanceContainer)3 NodeInstance (org.kie.api.runtime.process.NodeInstance)3