Search in sources :

Example 6 with PlanningItem

use of org.kie.server.api.model.taskassigning.PlanningItem 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);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) TestUtil.mockUser(org.kie.server.services.taskassigning.planning.TestUtil.mockUser) User(org.kie.server.services.taskassigning.core.model.User) TestUtil.initializeUser(org.kie.server.services.taskassigning.planning.TestUtil.initializeUser) ArrayList(java.util.ArrayList) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) Test(org.junit.Test)

Example 7 with PlanningItem

use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.

the class SolutionProcessor method doProcess.

protected void doProcess(final TaskAssigningSolution solution) {
    LOGGER.debug("Starting processing of solution: {}", solution);
    final List<PlanningItem> publishedTasks = buildPlanning(solution, publishWindowSize);
    if (LOGGER.isTraceEnabled()) {
        traceSolution(LOGGER, solution);
        tracePublishedTasks(LOGGER, publishedTasks);
    }
    Result result;
    try {
        PlanningExecutionResult executeResult = delegate.executePlanning(publishedTasks, targetUserId);
        result = new Result(executeResult);
    } catch (Exception e) {
        LOGGER.error("An error was produced during solution processing, planning execution failed.", e);
        result = new Result(e);
    }
    LOGGER.debug("Solution processing finished: {}", solution);
    if (isAlive()) {
        resultConsumer.accept(result);
        status.compareAndSet(STARTED, STOPPED);
    }
}
Also used : PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult)

Example 8 with PlanningItem

use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerChanged.

private void executePlanningWithTaskInInProgressOrSuspendedStatusWithActualOwnerChanged(Status status) {
    TaskData taskData = mockTaskData(TASK_ID, status, PREVIOUS_ASSIGNED_USER_ID_CHANGED, null);
    List<TaskData> taskDataList = Collections.singletonList(taskData);
    PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
    PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
    prepareExecution(taskDataList, CONTAINER_ID);
    PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
    verify(userTaskService, never()).execute(eq(CONTAINER_ID), any());
    String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_2, planningItem.getPlanningTask().getTaskId(), PREVIOUS_ASSIGNED_USER_ID_CHANGED, ASSIGNED_USER_ID);
    assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID);
}
Also used : PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) StatusConverter.convertToString(org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) TaskData(org.kie.server.api.model.taskassigning.TaskData)

Example 9 with PlanningItem

use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReservedStatusWithPlanningTaskButReassigned.

@Test
public void executePlanningWithTaskInReservedStatusWithPlanningTaskButReassigned() {
    PlanningTask planningTask = mockPlanningTask(TASK_ID, PREVIOUS_ASSIGNED_USER_ID);
    TaskData taskData = mockTaskData(TASK_ID, Reserved, PREVIOUS_ASSIGNED_USER_ID_CHANGED, planningTask);
    List<TaskData> taskDataList = Collections.singletonList(taskData);
    PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
    PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
    prepareExecution(taskDataList, CONTAINER_ID);
    PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
    verify(userTaskService, never()).execute(eq(CONTAINER_ID), any());
    String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_1, taskData.getTaskId(), PREVIOUS_ASSIGNED_USER_ID_CHANGED, PREVIOUS_ASSIGNED_USER_ID);
    assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) StatusConverter.convertToString(org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 10 with PlanningItem

use of org.kie.server.api.model.taskassigning.PlanningItem in project droolsjbpm-integration by kiegroup.

the class TaskAssigningRuntimeServiceBaseTest method executePlanningWithTaskInReservedStatusWithPlanningTaskDontReassigned.

@Test
public void executePlanningWithTaskInReservedStatusWithPlanningTaskDontReassigned() {
    PlanningTask planningTask = mockPlanningTask(TASK_ID, PREVIOUS_ASSIGNED_USER_ID);
    TaskData taskData = mockTaskData(TASK_ID, Reserved, PREVIOUS_ASSIGNED_USER_ID, planningTask);
    List<TaskData> taskDataList = Collections.singletonList(taskData);
    PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID);
    PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem));
    prepareExecution(taskDataList, CONTAINER_ID);
    PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID);
    verify(userTaskService).execute(eq(CONTAINER_ID), planningCommandCaptor.capture());
    assertDelegateAndSaveCommand(planningCommandCaptor.getAllValues(), 0, USER_ID, planningItem);
    assertNoError(result);
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) PlanningItemList(org.kie.server.api.model.taskassigning.PlanningItemList) PlanningExecutionResult(org.kie.server.api.model.taskassigning.PlanningExecutionResult) PlanningItem(org.kie.server.api.model.taskassigning.PlanningItem) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Aggregations

PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)14 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)10 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)9 TaskData (org.kie.server.api.model.taskassigning.TaskData)9 Test (org.junit.Test)8 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)4 StatusConverter.convertToString (org.kie.server.api.model.taskassigning.util.StatusConverter.convertToString)4 ArrayList (java.util.ArrayList)3 Task (org.kie.server.services.taskassigning.core.model.Task)3 CompositeCommand (org.jbpm.services.task.commands.CompositeCommand)2 Status (org.kie.api.task.model.Status)2 KieContainerStatus (org.kie.server.api.model.KieContainerStatus)2 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1