Search in sources :

Example 21 with ConnectionImpl

use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.

the class ProcessEventSupportTest method testProcessEventListener.

@Test
public void testProcessEventListener() throws Exception {
    InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    // create a simple package with one process to test the events
    final InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.drools.test");
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.core.process.event");
    process.setName("Event Process");
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    process.addNode(startNode);
    ActionNode actionNode = new ActionNode();
    actionNode.setName("Print");
    DroolsAction action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Executed action");
        }
    });
    actionNode.setAction(action);
    actionNode.setId(2);
    process.addNode(actionNode);
    new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);
    process.addNode(endNode);
    new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    pkg.addProcess(process);
    List<KiePackage> pkgs = new ArrayList<KiePackage>();
    pkgs.add(pkg);
    kbase.addPackages(pkgs);
    KieSession session = kbase.newKieSession();
    final List<ProcessEvent> processEventList = new ArrayList<ProcessEvent>();
    final ProcessEventListener processEventListener = new ProcessEventListener() {

        public void afterNodeLeft(ProcessNodeLeftEvent event) {
            processEventList.add(event);
        }

        public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
            processEventList.add(event);
        }

        public void afterProcessCompleted(ProcessCompletedEvent event) {
            processEventList.add(event);
        }

        public void afterProcessStarted(ProcessStartedEvent event) {
            processEventList.add(event);
        }

        public void beforeNodeLeft(ProcessNodeLeftEvent event) {
            processEventList.add(event);
        }

        public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
            processEventList.add(event);
        }

        public void beforeProcessCompleted(ProcessCompletedEvent event) {
            processEventList.add(event);
        }

        public void beforeProcessStarted(ProcessStartedEvent event) {
            processEventList.add(event);
        }

        public void beforeVariableChanged(ProcessVariableChangedEvent event) {
            processEventList.add(event);
        }

        public void afterVariableChanged(ProcessVariableChangedEvent event) {
            processEventList.add(event);
        }
    };
    session.addEventListener(processEventListener);
    // execute the process
    session.startProcess("org.drools.core.process.event");
    assertEquals(16, processEventList.size());
    assertEquals("org.drools.core.process.event", ((ProcessStartedEvent) processEventList.get(0)).getProcessInstance().getProcessId());
    assertEquals("Start", ((ProcessNodeTriggeredEvent) processEventList.get(1)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeLeftEvent) processEventList.get(2)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeTriggeredEvent) processEventList.get(3)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeLeftEvent) processEventList.get(4)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeTriggeredEvent) processEventList.get(5)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeLeftEvent) processEventList.get(6)).getNodeInstance().getNodeName());
    assertEquals("org.drools.core.process.event", ((ProcessCompletedEvent) processEventList.get(7)).getProcessInstance().getProcessId());
    assertEquals("org.drools.core.process.event", ((ProcessCompletedEvent) processEventList.get(8)).getProcessInstance().getProcessId());
    assertEquals("End", ((ProcessNodeLeftEvent) processEventList.get(9)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeTriggeredEvent) processEventList.get(10)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeLeftEvent) processEventList.get(11)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeTriggeredEvent) processEventList.get(12)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeLeftEvent) processEventList.get(13)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeTriggeredEvent) processEventList.get(14)).getNodeInstance().getNodeName());
    assertEquals("org.drools.core.process.event", ((ProcessStartedEvent) processEventList.get(15)).getProcessInstance().getProcessId());
}
Also used : ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ActionNode(org.jbpm.workflow.core.node.ActionNode) ArrayList(java.util.ArrayList) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) ProcessContext(org.kie.api.runtime.process.ProcessContext) KiePackage(org.kie.api.definition.KiePackage) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) KieSession(org.kie.api.runtime.KieSession) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) DroolsAction(org.jbpm.workflow.core.DroolsAction) StartNode(org.jbpm.workflow.core.node.StartNode) ProcessEvent(org.kie.api.event.process.ProcessEvent) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) ProcessCompletedEvent(org.kie.api.event.process.ProcessCompletedEvent) EndNode(org.jbpm.workflow.core.node.EndNode) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 22 with ConnectionImpl

use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.

the class ProcessEventSupportTest method testProcessEventListenerWithEndEvent.

@Test
public void testProcessEventListenerWithEndEvent() throws Exception {
    InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    // create a simple package with one process to test the events
    final InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.drools.test");
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.core.process.event");
    process.setName("Event Process");
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    process.addNode(startNode);
    ActionNode actionNode = new ActionNode();
    actionNode.setName("Print");
    DroolsAction action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Executed action");
        }
    });
    actionNode.setAction(action);
    actionNode.setId(2);
    process.addNode(actionNode);
    new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);
    endNode.setTerminate(false);
    process.addNode(endNode);
    new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    pkg.addProcess(process);
    List<KiePackage> pkgs = new ArrayList<KiePackage>();
    pkgs.add(pkg);
    kbase.addPackages(pkgs);
    KieSession session = kbase.newKieSession();
    final List<ProcessEvent> processEventList = new ArrayList<ProcessEvent>();
    final ProcessEventListener processEventListener = new ProcessEventListener() {

        public void afterNodeLeft(ProcessNodeLeftEvent event) {
            processEventList.add(event);
        }

        public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
            processEventList.add(event);
        }

        public void afterProcessCompleted(ProcessCompletedEvent event) {
            processEventList.add(event);
        }

        public void afterProcessStarted(ProcessStartedEvent event) {
            processEventList.add(event);
        }

        public void beforeNodeLeft(ProcessNodeLeftEvent event) {
            processEventList.add(event);
        }

        public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
            processEventList.add(event);
        }

        public void beforeProcessCompleted(ProcessCompletedEvent event) {
            processEventList.add(event);
        }

        public void beforeProcessStarted(ProcessStartedEvent event) {
            processEventList.add(event);
        }

        public void beforeVariableChanged(ProcessVariableChangedEvent event) {
            processEventList.add(event);
        }

        public void afterVariableChanged(ProcessVariableChangedEvent event) {
            processEventList.add(event);
        }
    };
    session.addEventListener(processEventListener);
    // execute the process
    session.startProcess("org.drools.core.process.event");
    assertEquals(14, processEventList.size());
    assertEquals("org.drools.core.process.event", ((ProcessStartedEvent) processEventList.get(0)).getProcessInstance().getProcessId());
    assertEquals("Start", ((ProcessNodeTriggeredEvent) processEventList.get(1)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeLeftEvent) processEventList.get(2)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeTriggeredEvent) processEventList.get(3)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeLeftEvent) processEventList.get(4)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeTriggeredEvent) processEventList.get(5)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeLeftEvent) processEventList.get(6)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeLeftEvent) processEventList.get(7)).getNodeInstance().getNodeName());
    assertEquals("End", ((ProcessNodeTriggeredEvent) processEventList.get(8)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeLeftEvent) processEventList.get(9)).getNodeInstance().getNodeName());
    assertEquals("Print", ((ProcessNodeTriggeredEvent) processEventList.get(10)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeLeftEvent) processEventList.get(11)).getNodeInstance().getNodeName());
    assertEquals("Start", ((ProcessNodeTriggeredEvent) processEventList.get(12)).getNodeInstance().getNodeName());
    assertEquals("org.drools.core.process.event", ((ProcessStartedEvent) processEventList.get(13)).getProcessInstance().getProcessId());
}
Also used : ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ActionNode(org.jbpm.workflow.core.node.ActionNode) ArrayList(java.util.ArrayList) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) ProcessContext(org.kie.api.runtime.process.ProcessContext) KiePackage(org.kie.api.definition.KiePackage) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) KieSession(org.kie.api.runtime.KieSession) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) DroolsAction(org.jbpm.workflow.core.DroolsAction) StartNode(org.jbpm.workflow.core.node.StartNode) ProcessEvent(org.kie.api.event.process.ProcessEvent) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) ProcessCompletedEvent(org.kie.api.event.process.ProcessCompletedEvent) EndNode(org.jbpm.workflow.core.node.EndNode) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 23 with ConnectionImpl

use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.

the class EventTest method testEvent3.

@Test
public void testEvent3() {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.core.process.event");
    process.setName("Event Process");
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName("event");
    ObjectDataType personDataType = new ObjectDataType();
    personDataType.setClassName("org.drools.Person");
    variable.setType(personDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    process.addNode(startNode);
    EventNode eventNode = new EventNode();
    EventTypeFilter eventFilter = new EventTypeFilter();
    eventFilter.setType("myEvent");
    eventNode.addEventFilter(eventFilter);
    eventNode.setVariableName("event");
    eventNode.setId(3);
    process.addNode(eventNode);
    final List<String> myList = new ArrayList<String>();
    ActionNode actionNode = new ActionNode();
    actionNode.setName("Print");
    DroolsAction action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Detected event for person {}", ((Person) context.getVariable("event")).getName());
            myList.add("Executed action");
        }
    });
    actionNode.setAction(action);
    actionNode.setId(4);
    process.addNode(actionNode);
    new ConnectionImpl(eventNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
    EventNode eventNode2 = new EventNode();
    eventFilter = new EventTypeFilter();
    eventFilter.setType("myOtherEvent");
    eventNode2.addEventFilter(eventFilter);
    eventNode2.setVariableName("event");
    eventNode2.setId(5);
    process.addNode(eventNode2);
    ActionNode actionNode2 = new ActionNode();
    actionNode2.setName("Print");
    action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Detected other event for person {}", ((Person) context.getVariable("event")).getName());
            myList.add("Executed action");
        }
    });
    actionNode2.setAction(action);
    actionNode2.setId(6);
    process.addNode(actionNode2);
    new ConnectionImpl(eventNode2, Node.CONNECTION_DEFAULT_TYPE, actionNode2, Node.CONNECTION_DEFAULT_TYPE);
    Join join = new Join();
    join.setName("AND Join");
    join.setType(Join.TYPE_AND);
    join.setId(7);
    process.addNode(join);
    new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    new ConnectionImpl(actionNode2, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(8);
    process.addNode(endNode);
    new ConnectionImpl(join, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    KieSession ksession = createKieSession(process);
    TestProcessEventListener procEventListener = new TestProcessEventListener();
    ksession.addEventListener(procEventListener);
    ProcessInstance processInstance = ksession.startProcess("org.drools.core.process.event");
    assertEquals(0, myList.size());
    Person jack = new Person();
    jack.setName("Jack");
    processInstance.signalEvent("myEvent", jack);
    assertEquals(1, myList.size());
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    Person john = new Person();
    john.setName("John");
    processInstance.signalEvent("myOtherEvent", john);
    assertEquals(2, myList.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    verifyEventHistory(test3EventOrder, procEventListener.getEventHistory());
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) Variable(org.jbpm.process.core.context.variable.Variable) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ArrayList(java.util.ArrayList) ActionNode(org.jbpm.workflow.core.node.ActionNode) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) Join(org.jbpm.workflow.core.node.Join) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) ProcessContext(org.kie.api.runtime.process.ProcessContext) EventNode(org.jbpm.workflow.core.node.EventNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) EndNode(org.jbpm.workflow.core.node.EndNode) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.process.test.Person) TestProcessEventListener(org.jbpm.process.test.TestProcessEventListener) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 24 with ConnectionImpl

use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.

the class EventTest method testEvent3a.

@Test
public void testEvent3a() {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.core.process.event");
    process.setName("Event Process");
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName("event");
    ObjectDataType personDataType = new ObjectDataType();
    personDataType.setClassName("org.drools.Person");
    variable.setType(personDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    process.addNode(startNode);
    EventNode eventNode = new EventNode();
    EventTypeFilter eventFilter = new EventTypeFilter();
    eventFilter.setType("myEvent");
    eventNode.addEventFilter(eventFilter);
    eventNode.setVariableName("event");
    eventNode.setId(3);
    process.addNode(eventNode);
    final List<String> myList = new ArrayList<String>();
    ActionNode actionNode = new ActionNode();
    actionNode.setName("Print");
    DroolsAction action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Detected event for person {}", ((Person) context.getVariable("event")).getName());
            myList.add("Executed action");
        }
    });
    actionNode.setAction(action);
    actionNode.setId(4);
    process.addNode(actionNode);
    new ConnectionImpl(eventNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
    EventNode eventNode2 = new EventNode();
    eventFilter = new EventTypeFilter();
    eventFilter.setType("myOtherEvent");
    eventNode2.addEventFilter(eventFilter);
    eventNode2.setVariableName("event");
    eventNode2.setId(5);
    process.addNode(eventNode2);
    ActionNode actionNode2 = new ActionNode();
    actionNode2.setName("Print");
    action = new DroolsConsequenceAction("java", null);
    action.setMetaData("Action", new Action() {

        public void execute(ProcessContext context) throws Exception {
            logger.info("Detected other event for person {}", ((Person) context.getVariable("event")).getName());
            myList.add("Executed action");
        }
    });
    actionNode2.setAction(action);
    actionNode2.setId(6);
    process.addNode(actionNode2);
    new ConnectionImpl(eventNode2, Node.CONNECTION_DEFAULT_TYPE, actionNode2, Node.CONNECTION_DEFAULT_TYPE);
    Join join = new Join();
    join.setName("AND Join");
    join.setType(Join.TYPE_AND);
    join.setId(7);
    process.addNode(join);
    new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    new ConnectionImpl(actionNode2, Node.CONNECTION_DEFAULT_TYPE, join, Node.CONNECTION_DEFAULT_TYPE);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(8);
    process.addNode(endNode);
    new ConnectionImpl(join, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    KieSession ksession = createKieSession(process);
    TestProcessEventListener procEventListener = new TestProcessEventListener();
    ksession.addEventListener(procEventListener);
    System.setProperty("jbpm.loop.level.disabled", "true");
    ProcessInstance processInstance = ksession.startProcess("org.drools.core.process.event");
    assertEquals(0, myList.size());
    Person jack = new Person();
    jack.setName("Jack");
    processInstance.signalEvent("myEvent", jack);
    assertEquals(1, myList.size());
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    processInstance.signalEvent("myEvent", jack);
    assertEquals(2, myList.size());
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    Person john = new Person();
    john.setName("John");
    processInstance.signalEvent("myOtherEvent", john);
    assertEquals(3, myList.size());
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    System.clearProperty("jbpm.loop.level.disabled");
    verifyEventHistory(test3aEventOrder, procEventListener.getEventHistory());
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) Variable(org.jbpm.process.core.context.variable.Variable) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ArrayList(java.util.ArrayList) ActionNode(org.jbpm.workflow.core.node.ActionNode) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) Join(org.jbpm.workflow.core.node.Join) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) ProcessContext(org.kie.api.runtime.process.ProcessContext) EventNode(org.jbpm.workflow.core.node.EventNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) EndNode(org.jbpm.workflow.core.node.EndNode) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.process.test.Person) TestProcessEventListener(org.jbpm.process.test.TestProcessEventListener) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 25 with ConnectionImpl

use of org.jbpm.workflow.core.impl.ConnectionImpl 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)

Aggregations

ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)34 EndNode (org.jbpm.workflow.core.node.EndNode)23 StartNode (org.jbpm.workflow.core.node.StartNode)23 ActionNode (org.jbpm.workflow.core.node.ActionNode)21 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)19 ArrayList (java.util.ArrayList)17 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)17 Test (org.junit.Test)16 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)15 KieSession (org.kie.api.runtime.KieSession)15 DroolsAction (org.jbpm.workflow.core.DroolsAction)13 Action (org.jbpm.process.instance.impl.Action)12 EventNode (org.jbpm.workflow.core.node.EventNode)12 ProcessContext (org.kie.api.runtime.process.ProcessContext)12 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)11 TestProcessEventListener (org.jbpm.process.test.TestProcessEventListener)9 Variable (org.jbpm.process.core.context.variable.Variable)8 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)8 SubProcessNode (org.jbpm.workflow.core.node.SubProcessNode)8 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)8