Search in sources :

Example 86 with TaskService

use of org.kie.api.task.TaskService in project jbpm by kiegroup.

the class JBPMHelper method startTaskService.

@Deprecated
public static TaskService startTaskService() {
    Properties properties = getProperties();
    String dialect = properties.getProperty("persistence.persistenceunit.dialect", "org.hibernate.dialect.H2Dialect");
    Map<String, String> map = new HashMap<String, String>();
    map.put("hibernate.dialect", dialect);
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties.getProperty("taskservice.datasource.name", "org.jbpm.services.task"), map);
    System.setProperty("jbpm.user.group.mapping", properties.getProperty("taskservice.usergroupmapping", "classpath:/usergroups.properties"));
    TaskService taskService = new HumanTaskConfigurator().entityManagerFactory(emf).userGroupCallback(getUserGroupCallback()).getTaskService();
    return taskService;
}
Also used : HumanTaskConfigurator(org.jbpm.services.task.HumanTaskConfigurator) HashMap(java.util.HashMap) TaskService(org.kie.api.task.TaskService) EntityManagerFactory(javax.persistence.EntityManagerFactory) Properties(java.util.Properties)

Example 87 with TaskService

use of org.kie.api.task.TaskService in project jbpm by kiegroup.

the class HumanTaskCleanUpEarlyFlushTest method testSubprocess.

@Test
@BZ({ "1128377", "1177736" })
public void testSubprocess() {
    createRuntimeManager(SUBPROCESS_PARENT, SUBPROCESS_CHILD1, SUBPROCESS_CHILD2);
    RuntimeEngine engine = getRuntimeEngine();
    KieSession ksession = engine.getKieSession();
    TaskService taskService = engine.getTaskService();
    ksession.addEventListener(new TaskCleanUpProcessEventListener(taskService));
    ProcessInstance processInstance = ksession.startProcess(SUBPROCESS_PARENT_ID);
    for (int i = 0; i < 2; ++i) {
        List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
        assertEquals(1, tasks.size());
        long taskId = tasks.get(0).getId();
        taskService.start(taskId, "john");
        taskService.complete(taskId, "john", null);
    }
    assertProcessInstanceCompleted(processInstance.getId());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskService(org.kie.api.task.TaskService) TaskSummary(org.kie.api.task.model.TaskSummary) TaskCleanUpProcessEventListener(org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 88 with TaskService

use of org.kie.api.task.TaskService in project jbpm by kiegroup.

the class HumanTaskCleanUpEarlyFlushTest method testSignal.

private void testSignal(JbpmJUnitBaseTestCase.Strategy strategy) {
    createRuntimeManager(strategy, null, SIGNAL_SENDER, SIGNAL_RECEIVER);
    RuntimeEngine engine = getRuntimeEngine();
    KieSession ksession = engine.getKieSession();
    TaskService taskService = engine.getTaskService();
    ksession.addEventListener(new TaskCleanUpProcessEventListener(taskService));
    ksession.startProcess(SIGNAL_SENDER_ID);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskService(org.kie.api.task.TaskService) TaskCleanUpProcessEventListener(org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener) KieSession(org.kie.api.runtime.KieSession)

Example 89 with TaskService

use of org.kie.api.task.TaskService in project jbpm by kiegroup.

the class HumanTaskSwimlaneTest method testSwimlaneWithMultipleActorsAssigned.

@Test
public void testSwimlaneWithMultipleActorsAssigned() {
    createRuntimeManager(SWIMLANE_MULTIPLE_ACTORS);
    String user = "john";
    RuntimeEngine runtime = getRuntimeEngine();
    KieSession kSession = runtime.getKieSession();
    TaskService taskservice = runtime.getTaskService();
    kSession.addEventListener(new DefaultProcessEventListener() {

        @Override
        public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
            if (event.getNodeInstance().getNodeName().equals("TASK")) {
                Object swimlaneActorId = ((HumanTaskNodeInstance) event.getNodeInstance()).getWorkItem().getParameter("SwimlaneActorId");
                assertNull(swimlaneActorId);
            }
        }
    });
    Map<String, Object> map = new HashMap<String, Object>();
    ProcessInstance instance = kSession.startProcess(SWIMLANE_MULTIPLE_ACTORS_ID, map);
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    statuses.add(Status.InProgress);
    List<TaskSummary> tasks = taskservice.getTasksByStatusByProcessInstanceId(instance.getId(), statuses, "en_US");
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    TaskSummary task = tasks.get(0);
    assertEquals(Status.Ready, task.getStatus());
    taskservice.claim(task.getId(), user);
    taskservice.start(task.getId(), user);
    tasks = taskservice.getTasksByStatusByProcessInstanceId(instance.getId(), statuses, "en_US");
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    task = tasks.get(0);
    assertEquals(Status.InProgress, task.getStatus());
    taskservice.complete(task.getId(), user, map);
    assertProcessInstanceCompleted(instance.getId());
}
Also used : Status(org.kie.api.task.model.Status) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) TaskService(org.kie.api.task.TaskService) ArrayList(java.util.ArrayList) HumanTaskNodeInstance(org.jbpm.workflow.instance.node.HumanTaskNodeInstance) TaskSummary(org.kie.api.task.model.TaskSummary) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 90 with TaskService

use of org.kie.api.task.TaskService in project jbpm by kiegroup.

the class HumanTaskTest method testBoundaryTimer.

@Test
@BZ("958397")
public void testBoundaryTimer() throws Exception {
    createRuntimeManager(BOUNDARY_TIMER);
    KieSession ksession = getRuntimeEngine().getKieSession();
    TaskService taskService = getRuntimeEngine().getTaskService();
    TrackingProcessEventListener tpel = new TrackingProcessEventListener();
    ksession.addEventListener(tpel);
    ProcessInstance pi = ksession.startProcess(BOUNDARY_TIMER_ID);
    // wait for timer
    String endNodeName = "End1";
    assertTrue("Node '" + endNodeName + "' was not triggered on time!", tpel.waitForNodeTobeTriggered(endNodeName, 2000));
    assertTriggeredAndLeft(tpel, "Script1");
    assertTriggered(tpel, endNodeName);
    long taskId = taskService.getTasksByProcessInstanceId(pi.getId()).get(0);
    taskService.start(taskId, "john");
    taskService.complete(taskId, "john", null);
    assertTriggeredAndLeft(tpel, "Script2");
    assertTriggered(tpel, "End2");
    assertProcessInstanceCompleted(pi.getId());
}
Also used : TaskService(org.kie.api.task.TaskService) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Aggregations

TaskService (org.kie.api.task.TaskService)129 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)111 KieSession (org.kie.api.runtime.KieSession)79 Test (org.junit.Test)73 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)70 TaskSummary (org.kie.api.task.model.TaskSummary)66 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)53 InternalTaskService (org.kie.internal.task.api.InternalTaskService)52 HashMap (java.util.HashMap)41 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)39 UserTaskService (org.jbpm.services.api.UserTaskService)38 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)34 ArrayList (java.util.ArrayList)17 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)17 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)15 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)15 Task (org.kie.api.task.model.Task)14 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)12 BZ (qa.tools.ikeeper.annotation.BZ)10 TaskCleanUpProcessEventListener (org.jbpm.services.task.admin.listener.TaskCleanUpProcessEventListener)9