use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class TaskUtil method fromTaskData.
public static Task fromTaskData(TaskData taskData) {
final Task task = new Task(taskData.getTaskId(), taskData.getProcessInstanceId(), taskData.getProcessId(), taskData.getContainerId(), taskData.getName(), taskData.getPriority(), taskData.getStatus(), taskData.getInputData());
if (taskData.getPotentialOwners() != null) {
taskData.getPotentialOwners().forEach(potentialOwner -> {
if (isUser(potentialOwner.getType())) {
task.getPotentialOwners().add(new User(potentialOwner.getName().hashCode(), potentialOwner.getName()));
} else {
task.getPotentialOwners().add(new Group(potentialOwner.getName().hashCode(), potentialOwner.getName()));
}
});
}
LabelValueExtractorRegistry.getInstance().applyLabelValueExtractors(TaskData.class, taskData, task::setLabelValues);
return task;
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class PlanningBuilderTest method mockTask.
private Task mockTask(long taskId, boolean pinned, String containerId, long processInstanceId) {
Task result = new Task(taskId, "Task_" + taskId, 0);
result.setContainerId(containerId);
result.setProcessInstanceId(processInstanceId);
result.setPinned(pinned);
return result;
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class PlanningBuilderTest method assertTasksArePlanned.
private void assertTasksArePlanned(List<Task> tasks, List<PlanningItem> planningItems) {
for (Task task : tasks) {
PlanningItem peerItem = planningItems.stream().filter(item -> item.getTaskId().equals(task.getId())).findFirst().orElse(null);
if (peerItem == null) {
fail("Task: " + task.getId() + " for user: " + task.getUser().getId() + " must be part of the generated planning");
}
assertEquals("PlanningItem containerId for task: " + task.getId() + " and user: " + task.getUser().getId() + " don't have the expected value.", task.getContainerId(), peerItem.getContainerId());
assertEquals("PlanningItem processInstanceId for task: " + task.getId() + " and user: " + task.getUser().getId() + " don't have the expected value.", task.getProcessInstanceId(), task.getProcessInstanceId());
assertEquals("PlanningItem assignedUser for task: " + task.getId() + " and user: " + task.getUser().getId() + " don't have the expected value.", task.getUser().getEntityId(), peerItem.getPlanningTask().getAssignedUser());
}
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class PlanningBuilderTest method build.
@Test
public void build() {
List<Task> user1Tasks = mockTasks(USER1_TOTAL_TASKS, USER1_PINNED_TASKS, "container1", 1L);
User user1 = mockUser(1, user1Tasks);
List<Task> user2Tasks = mockTasks(USER2_TOTAL_TASKS, USER2_PINNED_TASKS, "container2", 2L);
User user2 = mockUser(2, user2Tasks);
List<Task> user3Tasks = mockTasks(USER3_TOTAL_TASKS, USER3_PINNED_TASKS, "container3", 3L);
User user3 = mockUser(3, user3Tasks);
List<Task> user4Tasks = mockTasks(USER4_TOTAL_TASKS, USER4_PINNED_TASKS, "container4", 4L);
User user4 = mockUser(4, user4Tasks);
List<Task> user5Tasks = mockTasks(USER5_TOTAL_TASKS, USER5_PINNED_TASKS, "container5", 5L);
User user5 = mockUser(5, user5Tasks);
List<Task> user6Tasks = mockTasks(USER6_TOTAL_TASKS, USER6_PINNED_TASKS, "container6", 6L);
User user6 = mockUser(6, user6Tasks);
List<Task> planningUserTasks = mockTasks(PLANNING_USER_TASKS, 0, "container7", 7L);
User planningUser = initializeUser(new User(-1, PLANNING_USER_ID), planningUserTasks);
List<Task> totalTasks = new ArrayList<>();
totalTasks.addAll(user1Tasks);
totalTasks.addAll(user2Tasks);
totalTasks.addAll(user3Tasks);
totalTasks.addAll(user4Tasks);
totalTasks.addAll(user5Tasks);
totalTasks.addAll(user6Tasks);
totalTasks.addAll(planningUserTasks);
List<User> totalUsers = Arrays.asList(user1, user2, user3, user4, user5, user6, planningUser);
TaskAssigningSolution solution = new TaskAssigningSolution(1, totalUsers, totalTasks);
List<PlanningItem> planningItems = PlanningBuilder.create().withPublishWindowSize(publishWindowSize).withSolution(solution).build();
assertPlanningItems(user1, publishWindowSize, planningItems);
assertPlanningItems(user2, publishWindowSize, planningItems);
assertPlanningItems(user3, publishWindowSize, planningItems);
assertPlanningItems(user4, publishWindowSize, planningItems);
assertPlanningItems(user5, publishWindowSize, planningItems);
assertPlanningItems(user6, publishWindowSize, planningItems);
assertPlanningUserPlanningItems(planningUser, publishWindowSize, planningItems);
}
use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.
the class SolutionBuilderTest method assertContainsAssignedTask.
private void assertContainsAssignedTask(TaskData taskData, String userId, boolean pinned, TaskAssigningSolution solution) {
Task task = solution.getTaskList().stream().filter(t -> taskData.getTaskId().equals(t.getId())).findFirst().orElse(null);
User user = solution.getUserList().stream().filter(u -> userId.equals(u.getEntityId())).findFirst().orElse(null);
assertNotNull("Task: " + taskData.getTaskId() + " must be present in the solution.", task);
assertNotNull("Task: " + taskData.getTaskId() + " must assigned to user: " + userId + " but user is not be present in the solution.", user);
assertNotNull("Task: " + taskData.getTaskId() + " must be assigned to user: " + userId + " but has no assigned user.", task.getUser());
assertEquals("Task: " + taskData.getTaskId() + " must be assigned to user: " + userId, userId, task.getUser().getEntityId());
assertEquals("Task: " + taskData.getTaskId() + " must have pinned = " + pinned, pinned, task.isPinned());
}
Aggregations