use of org.jbpm.task.service.local.LocalTaskService in project jBPM5-Developer-Guide by Salaboy.
the class HumanTasksLifecycleAPITest method claimNextAvailable.
@Test
public void claimNextAvailable() {
// Create a local instance of the TaskService
LocalTaskService localTaskService = new LocalTaskService(taskService);
List<User> potentialOwners = new ArrayList<User>();
potentialOwners.add(users.get("salaboy"));
potentialOwners.add(users.get("watman"));
// Create a Task Definition
Task task = createSimpleTask(potentialOwners, users.get("administrator"));
// Deploy the Task Definition to the Task Component
localTaskService.addTask(task, new ContentData());
// we don't need to query for our task to see what we will claim, just claim the next one available for us
localTaskService.claimNextAvailable("watman", "en-UK");
List<Status> status = new ArrayList<Status>();
status.add(Status.Ready);
List<TaskSummary> salaboyTasks = localTaskService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", status, "en-UK");
assertEquals(0, salaboyTasks.size());
}
use of org.jbpm.task.service.local.LocalTaskService in project jBPM5-Developer-Guide by Salaboy.
the class HumanTasksLifecycleAPITest method regularFlowTest.
@Test
public void regularFlowTest() {
// Create a local instance of the TaskService
LocalTaskService localTaskService = new LocalTaskService(taskService);
List<User> potentialOwners = new ArrayList<User>();
potentialOwners.add(users.get("salaboy"));
// Create a Task Definition
Task task = createSimpleTask(potentialOwners, users.get("administrator"));
// Deploy the Task Definition to the Task Component
localTaskService.addTask(task, new ContentData());
// Because the Task contains a direct assignment we can query it for its Potential Owner
// Notice that we obtain a list of TaskSummary (a lightweight representation of a task)
List<TaskSummary> tasksAssignedAsPotentialOwner = localTaskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
// We know that there is just one task available so we get the first one
Long taskId = tasksAssignedAsPotentialOwner.get(0).getId();
// In order to check the task status we need to get the real task
// The task is in a Reserved status because it already have a well-defined Potential Owner
Task simpleTask = localTaskService.getTask(taskId);
assertEquals(Status.Reserved, simpleTask.getTaskData().getStatus());
// In order start working with this task we call the start() method
localTaskService.start(simpleTask.getId(), "salaboy");
// The task is now In Progress
simpleTask = localTaskService.getTask(taskId);
assertEquals(Status.InProgress, simpleTask.getTaskData().getStatus());
// PERFORM THE TASK ACTIVITY HERE, the user need to perform the required activities here
// Once the Task activity is performed the user can complete the task,
// Notice that we are completing this task without results
localTaskService.complete(simpleTask.getId(), "salaboy", null);
// We can check the task status after completion
simpleTask = localTaskService.getTask(taskId);
assertEquals(Status.Completed, simpleTask.getTaskData().getStatus());
}
use of org.jbpm.task.service.local.LocalTaskService in project jBPM5-Developer-Guide by Salaboy.
the class TaskServiceMinaSyncTest method claimNextAvailable.
@Test
public void claimNextAvailable() {
// Create a local instance of the TaskService
LocalTaskService localTaskService = new LocalTaskService(taskService);
List<User> potentialOwners = new ArrayList<User>();
potentialOwners.add(users.get("salaboy"));
potentialOwners.add(users.get("watman"));
// Create a Task Definition
Task task = createSimpleTask(potentialOwners, users.get("administrator"));
// Deploy the Task Definition to the Task Component
localTaskService.addTask(task, new ContentData());
// we don't need to query for our task to see what we will claim, just claim the next one available for us
localTaskService.claimNextAvailable("watman", "en-UK");
List<Status> status = new ArrayList<Status>();
status.add(Status.Ready);
List<TaskSummary> salaboyTasks = localTaskService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", status, "en-UK");
assertEquals(0, salaboyTasks.size());
}
use of org.jbpm.task.service.local.LocalTaskService in project jBPM5-Developer-Guide by Salaboy.
the class TaskServiceMinaSyncTest method claimConflictAndRetry.
@Test
public void claimConflictAndRetry() {
// Create a local instance of the TaskService
LocalTaskService localTaskService = new LocalTaskService(taskService);
List<User> potentialOwners = new ArrayList<User>();
potentialOwners.add(users.get("salaboy"));
potentialOwners.add(users.get("watman"));
// Create a Task Definition
Task task = createSimpleTask(potentialOwners, users.get("administrator"));
// Deploy the Task Definition to the Task Component
localTaskService.addTask(task, new ContentData());
// Because the Task contains a direct assignment we can query it for its Potential Owner
// Notice that we obtain a list of TaskSummary (a lightweight representation of a task)
List<TaskSummary> salaboyTasks = localTaskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
// We know that there is just one task available so we get the first one
Long salaboyTaskId = salaboyTasks.get(0).getId();
// In order to check the task status we need to get the real task
// The task is in a Reserved status because it already have a well-defined Potential Owner
Task salaboyTask = localTaskService.getTask(salaboyTaskId);
assertEquals(Status.Ready, salaboyTask.getTaskData().getStatus());
// Because the Task contains a direct assignment we can query it for its Potential Owner
// Notice that we obtain a list of TaskSummary (a lightweight representation of a task)
List<TaskSummary> watmanTasks = localTaskService.getTasksAssignedAsPotentialOwner("watman", "en-UK");
// We know that there is just one task available so we get the first one
Long watmanTaskId = watmanTasks.get(0).getId();
assertEquals(watmanTaskId, salaboyTaskId);
// In order to check the task status we need to get the real task
// The task is in a Reserved status because it already have a well-defined Potential Owner
Task watmanTask = localTaskService.getTask(watmanTaskId);
assertEquals(Status.Ready, watmanTask.getTaskData().getStatus());
localTaskService.claim(watmanTask.getId(), "watman");
try {
localTaskService.claim(salaboyTask.getId(), "salaboy");
} catch (PermissionDeniedException ex) {
// The Task is gone.. salaboy needs to retry
assertNotNull(ex);
}
}
Aggregations