use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class TaskCleanUpProcessEventListener method afterProcessCompleted.
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Error);
statuses.add(Status.Failed);
statuses.add(Status.Obsolete);
statuses.add(Status.Suspended);
statuses.add(Status.Completed);
statuses.add(Status.Exited);
List<TaskSummary> completedTasksByProcessId = ((InternalTaskService) taskService).execute(new GetTasksForProcessCommand(event.getProcessInstance().getId(), statuses, "en-UK"));
// archive and remove
taskService.archiveTasks(completedTasksByProcessId);
taskService.removeTasks(completedTasksByProcessId);
}
use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class AuditTaskDeleteTest method produceTaskInstances.
private void produceTaskInstances() {
InternalTaskService taskService = (InternalTaskService) HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).listener(new JPATaskLifeCycleEventListener(true)).listener(new BAMTaskEventListener(true)).getTaskService();
Calendar cal = randomCal();
String processId = "process";
taskTestData = new Task[10];
List<ProcessInstanceLog> pLogs = new ArrayList<>();
for (int i = 0; i < 10; i++) {
cal.add(Calendar.HOUR_OF_DAY, 1);
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").setProcessId(processId + i).setProcessInstanceId(i).setCreatedOn(cal.getTime()).getTask();
taskService.addTask(task, new HashMap<String, Object>());
taskTestData[i] = task;
ProcessInstanceLog plog = buildCompletedProcessInstance(i);
pLogs.add(plog);
}
StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
EntityManager em = jtaHelper.getEntityManager();
Object tx = jtaHelper.joinTransaction(em);
pLogs.forEach(pl -> {
em.persist(pl);
});
jtaHelper.leaveTransaction(em, tx);
}
use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class DefaultChecklistManager method updateTaskPriority.
public void updateTaskPriority(long taskId, int priority) {
RuntimeEngine runtime = getRuntime();
((InternalTaskService) runtime.getTaskService()).setPriority(taskId, priority);
manager.disposeRuntimeEngine(runtime);
}
use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class AdminAPIsWithListenerTest method automaticCleanUpForSubProcessWithSingletonStrategy.
@Test
public void automaticCleanUpForSubProcessWithSingletonStrategy() throws Exception {
TaskCleanUpProcessEventListener taskCleanUpProcessEventListener = new TaskCleanUpProcessEventListener(null);
this.addProcessEventListener(taskCleanUpProcessEventListener);
RuntimeManager manager = createRuntimeManager("org/jbpm/test/functional/task/ht-main.bpmn", "org/jbpm/test/functional/task/ht-sub.bpmn");
RuntimeEngine runtime = getRuntimeEngine(ProcessInstanceIdContext.get());
taskCleanUpProcessEventListener.setTaskService((InternalTaskService) runtime.getTaskService());
KieSession ksession = runtime.getKieSession();
// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance pi = ksession.startProcess("com.mycompany.sample", params);
// obtain the task service
TaskService taskService = runtime.getTaskService();
List<TaskSummary> tasks1 = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertFalse(tasks1.isEmpty());
TaskSummary task1 = tasks1.get(0);
System.out.println("Sales-rep executing task " + task1.getName() + "(" + task1.getId() + ": " + task1.getDescription() + ")");
taskService.start(task1.getId(), "john");
Map<String, Object> results = new HashMap<String, Object>();
results.put("comment", "Agreed, existing laptop needs replacing");
results.put("outcome", "Accept");
// complete the human task of the main process
taskService.complete(task1.getId(), "john", results);
// abort the process instance
ksession.abortProcessInstance(pi.getId());
// main process instance shall be aborted
assertProcessInstanceAborted(pi.getId());
AuditService logService = runtime.getAuditService();
List<? extends ProcessInstanceLog> logs = logService.findProcessInstances("com.mycompany.sample");
assertNotNull(logs);
assertEquals(1, logs.size());
assertEquals(ProcessInstance.STATE_ABORTED, logs.get(0).getStatus().intValue());
logs = logService.findProcessInstances("com.mycompany.sample.subprocess");
assertNotNull(logs);
assertEquals(1, logs.size());
assertEquals(ProcessInstance.STATE_ABORTED, logs.get(0).getStatus().intValue());
manager.close();
final EntityManager em = emfTasks.createEntityManager();
assertEquals(0, em.createQuery("select t from TaskImpl t").getResultList().size());
assertEquals(0, em.createQuery("select i from I18NTextImpl i").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_BAs").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_ExclOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_PotOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Recipients").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Stakeholders").getResultList().size());
assertEquals(0, em.createQuery("select c from ContentImpl c").getResultList().size());
em.close();
}
use of org.kie.internal.task.api.InternalTaskService in project jbpm by kiegroup.
the class SupportProcessTest method simpleSupportProcessTest.
@Test
public void simpleSupportProcessTest() {
createRuntimeManager("org/jbpm/test/functional/jpa/support.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", "salaboy");
ProcessInstance processInstance = ksession.startProcess("support.process", params);
assertProcessInstanceActive(processInstance.getId());
assertProcessVarExists(processInstance, "customer");
// Configure Release
List<TaskSummary> tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertNodeTriggered(processInstance.getId(), "Create Support");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Create Support", tasksAssignedToSalaboy.get(0).getName());
TaskSummary createSupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(createSupportTask.getId(), "salaboy");
Map<String, Object> taskContent = ((InternalTaskService) taskService).getTaskContent(createSupportTask.getId());
assertEquals("salaboy", taskContent.get("input_customer"));
Map<String, Object> output = new HashMap<String, Object>();
output.put("output_customer", "salaboy/redhat");
taskService.complete(createSupportTask.getId(), "salaboy", output);
assertNodeTriggered(processInstance.getId(), "Resolve Support");
tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Resolve Support", tasksAssignedToSalaboy.get(0).getName());
TaskSummary resolveSupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(resolveSupportTask.getId(), "salaboy");
taskService.complete(resolveSupportTask.getId(), "salaboy", null);
assertNodeTriggered(processInstance.getId(), "Notify Customer");
tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Notify Customer", tasksAssignedToSalaboy.get(0).getName());
TaskSummary notifySupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(notifySupportTask.getId(), "salaboy");
output = new HashMap<String, Object>();
output.put("output_solution", "solved today");
taskService.complete(notifySupportTask.getId(), "salaboy", output);
assertProcessInstanceCompleted(processInstance.getId());
}
Aggregations