use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskAdminRuntimeImpl method tasks.
@Override
public Page<Task> tasks(Pageable pageable, GetTasksPayload getTasksPayload) {
TaskQuery taskQuery = taskService.createTaskQuery();
if (getTasksPayload.getProcessInstanceId() != null) {
taskQuery = taskQuery.processInstanceId(getTasksPayload.getProcessInstanceId());
}
if (getTasksPayload.getParentTaskId() != null) {
taskQuery = taskQuery.taskParentTaskId(getTasksPayload.getParentTaskId());
}
List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems()));
return new PageImpl<>(tasks, Math.toIntExact(taskQuery.count()));
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskRuntimeImpl method tasks.
@Override
public Page<Task> tasks(Pageable pageable, GetTasksPayload getTasksPayload) {
TaskQuery taskQuery = taskService.createTaskQuery();
if (getTasksPayload == null) {
getTasksPayload = TaskPayloadBuilder.tasks().build();
}
String authenticatedUserId = securityManager.getAuthenticatedUserId();
if (authenticatedUserId != null && !authenticatedUserId.isEmpty()) {
List<String> userGroups = securityManager.getAuthenticatedUserGroups();
getTasksPayload.setAssigneeId(authenticatedUserId);
getTasksPayload.setGroups(userGroups);
} else {
throw new IllegalStateException("You need an authenticated user to perform a task query");
}
taskQuery = taskQuery.or().taskCandidateOrAssigned(getTasksPayload.getAssigneeId(), getTasksPayload.getGroups()).taskOwner(authenticatedUserId).endOr();
if (getTasksPayload.getProcessInstanceId() != null) {
taskQuery = taskQuery.processInstanceId(getTasksPayload.getProcessInstanceId());
}
if (getTasksPayload.getParentTaskId() != null) {
taskQuery = taskQuery.taskParentTaskId(getTasksPayload.getParentTaskId());
}
List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems()));
return new PageImpl<>(tasks, Math.toIntExact(taskQuery.count()));
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubProcessTest method testTwoSubProcessInParallelWithinSubProcess.
@Deployment
public void testTwoSubProcessInParallelWithinSubProcess() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess");
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc();
List<Task> tasks = taskQuery.list();
// After process start, both tasks in the subprocesses should be active
Task taskA = tasks.get(0);
Task taskB = tasks.get(1);
assertThat(taskA.getName()).isEqualTo("Task in subprocess A");
assertThat(taskB.getName()).isEqualTo("Task in subprocess B");
// Completing both tasks should active the tasks outside the subprocesses
taskService.complete(taskA.getId());
taskService.complete(taskB.getId());
Task taskAfterSubProcess = taskQuery.singleResult();
assertThat(taskAfterSubProcess.getName()).isEqualTo("Task after subprocess");
// Completing this task should end the process
taskService.complete(taskAfterSubProcess.getId());
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubProcessTest method IGNORE_testSimpleSubProcessWithConcurrentTimer.
/**
* A test case that has a timer attached to the subprocess, where 2 concurrent paths are defined when the timer fires.
*/
@Deployment
public void IGNORE_testSimpleSubProcessWithConcurrentTimer() {
// After staring the process, the task in the subprocess should be active
ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcessWithConcurrentTimer");
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc();
Task subProcessTask = taskQuery.singleResult();
assertThat(subProcessTask.getName()).isEqualTo("Task in subprocess");
// When the timer is fired (after 2 hours), two concurrent paths should be created
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
List<Task> tasksAfterTimer = taskQuery.list();
assertThat(tasksAfterTimer).hasSize(2);
Task taskAfterTimer1 = tasksAfterTimer.get(0);
Task taskAfterTimer2 = tasksAfterTimer.get(1);
assertThat(taskAfterTimer1.getName()).isEqualTo("Task after timer 1");
assertThat(taskAfterTimer2.getName()).isEqualTo("Task after timer 2");
// Completing the two tasks should end the process instance
taskService.complete(taskAfterTimer1.getId());
taskService.complete(taskAfterTimer2.getId());
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskAssignmentExtensionsTest method testCandidateGroupsExtension.
@Deployment
public void testCandidateGroupsExtension() {
runtimeService.startProcessInstanceByKey("candidateGroupsExtension");
// Bugfix check: potentially the query could return 2 tasks since
// kermit is a member of the two candidate groups
List<Task> tasks = taskService.createTaskQuery().taskCandidateUser(KERMIT, KERMITSGROUPS).list();
assertThat(tasks).hasSize(1);
assertThat(tasks.get(0).getName()).isEqualTo("make profit");
tasks = taskService.createTaskQuery().taskCandidateUser(FOZZIE, FOZZIESGROUPS).list();
assertThat(tasks).hasSize(1);
assertThat(tasks.get(0).getName()).isEqualTo("make profit");
// Test the task query find-by-candidate-group operation
TaskQuery query = taskService.createTaskQuery();
assertThat(query.taskCandidateGroup("management").count()).isEqualTo(1);
assertThat(query.taskCandidateGroup("accountancy").count()).isEqualTo(1);
}
Aggregations