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;
}
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());
}
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);
}
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());
}
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());
}
Aggregations