Search in sources :

Example 96 with WorkItem

use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.

the class UIWorkItemHandler method select.

private void select() {
    WorkItem workItem = getSelectedWorkItem();
    if (workItem != null) {
        UIWorkItemHandlerDialog dialog = new UIWorkItemHandlerDialog(UIWorkItemHandler.this, workItem);
        dialog.setVisible(true);
    }
}
Also used : WorkItem(org.kie.api.runtime.process.WorkItem)

Example 97 with WorkItem

use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.

the class UIWorkItemHandler method reloadWorkItemsList.

private void reloadWorkItemsList() {
    List<WorkItemWrapper> result = new ArrayList<WorkItemWrapper>();
    for (Iterator<WorkItem> iterator = workItems.keySet().iterator(); iterator.hasNext(); ) {
        WorkItem workItem = iterator.next();
        result.add(new WorkItemWrapper(workItem));
    }
    workItemsList.setListData(result.toArray());
}
Also used : ArrayList(java.util.ArrayList) WorkItem(org.kie.api.runtime.process.WorkItem)

Example 98 with WorkItem

use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.

the class HumanTaskHandler method reloadWorkItemsList.

private void reloadWorkItemsList(String actor) {
    List<WorkItemWrapper> result = new ArrayList<WorkItemWrapper>();
    for (Iterator<WorkItem> iterator = workItems.keySet().iterator(); iterator.hasNext(); ) {
        WorkItem workItem = iterator.next();
        if (actor == null || workItem.getParameter("ActorId") == null || actor.equals(workItem.getParameter("ActorId"))) {
            result.add(new WorkItemWrapper(workItem));
        }
    }
    workItemsList.setListData(result.toArray());
}
Also used : ArrayList(java.util.ArrayList) WorkItem(org.kie.api.runtime.process.WorkItem)

Example 99 with WorkItem

use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.

the class IntermediateEventTest method testEventSubprocessSignalWithStateNode.

@Test
public void testEventSubprocessSignalWithStateNode() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessSignalWithStateNode.bpmn2");
    final List<Long> executednodes = new ArrayList<Long>();
    ProcessEventListener listener = new DefaultProcessEventListener() {

        @Override
        public void afterNodeLeft(ProcessNodeLeftEvent event) {
            if (event.getNodeInstance().getNodeName().equals("User Task 2")) {
                executednodes.add(event.getNodeInstance().getId());
            }
        }
    };
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(listener);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("BPMN2-EventSubprocessSignal");
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(listener);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    WorkItem workItemTopProcess = workItemHandler.getWorkItem();
    ksession.signalEvent("MySignal", null, processInstance.getId());
    assertProcessInstanceActive(processInstance);
    WorkItem workItem = workItemHandler.getWorkItem();
    assertThat(workItem).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    ksession.signalEvent("MySignal", null);
    assertProcessInstanceActive(processInstance);
    workItem = workItemHandler.getWorkItem();
    assertThat(workItem).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    ksession.signalEvent("MySignal", null);
    assertProcessInstanceActive(processInstance);
    workItem = workItemHandler.getWorkItem();
    assertThat(workItem).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    ksession.signalEvent("MySignal", null);
    assertProcessInstanceActive(processInstance);
    workItem = workItemHandler.getWorkItem();
    assertThat(workItem).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    assertThat(workItemTopProcess).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItemTopProcess.getId(), null);
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "User Task 2", "end-sub");
    assertThat(executednodes.size()).isEqualTo(4);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ArrayList(java.util.ArrayList) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test)

Example 100 with WorkItem

use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.

the class IntermediateEventTest method testErrorBoundaryEventOnMultiInstanceSubprocess.

@Test
public void testErrorBoundaryEventOnMultiInstanceSubprocess() throws Exception {
    KieBase kbase = createKnowledgeBase("subprocess/BPMN2-MultiInstanceSubprocessWithBoundaryError.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    Map<String, Object> params = new HashMap<String, Object>();
    List<String> approvers = new ArrayList<String>();
    approvers.add("john");
    approvers.add("john");
    params.put("approvers", approvers);
    ProcessInstance processInstance = ksession.startProcess("boundary-catch-error-event", params);
    assertProcessInstanceActive(processInstance);
    List<WorkItem> workItems = handler.getWorkItems();
    assertThat(workItems).isNotNull();
    assertThat(workItems.size()).isEqualTo(2);
    ksession.signalEvent("Inside", null, processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    ksession.dispose();
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ArrayList(java.util.ArrayList) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test)

Aggregations

WorkItem (org.kie.api.runtime.process.WorkItem)174 Test (org.junit.Test)139 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)127 KieBase (org.kie.api.KieBase)110 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)91 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)87 HashMap (java.util.HashMap)72 KieSession (org.kie.api.runtime.KieSession)48 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)33 ArrayList (java.util.ArrayList)29 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)27 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)26 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)22 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)20 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)14 TestWorkItemHandler (org.jbpm.persistence.session.objects.TestWorkItemHandler)13 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)13 Map (java.util.Map)11 StringReader (java.io.StringReader)10 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)10