Search in sources :

Example 61 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class TraceHelper method traceSolution.

static void traceSolution(Logger logger, TaskAssigningSolution solution) {
    logger.trace("{}*** Start of solution trace, with users = {} and tasks = {} ***", NEW_LINE, solution.getUserList().size(), solution.getTaskList().size());
    for (User user : solution.getUserList()) {
        Task nextTask = user.getNextTask();
        while (nextTask != null) {
            logger.trace("{} -> {}, pinned: {}, priority: {}, status: {}", user.getEntityId(), nextTask.getId(), nextTask.isPinned(), nextTask.getPriority(), nextTask.getStatus());
            nextTask = nextTask.getNextTask();
        }
    }
    logger.trace("*** End of solution trace ***");
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) User(org.kie.server.services.taskassigning.core.model.User)

Example 62 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class SolutionChangesBuilderTest method discardDuplicatedChanges.

@Test
public void discardDuplicatedChanges() {
    TaskData taskData1 = mockTaskData(1, NAME, Ready, null);
    TaskData taskData2 = mockTaskData(2, NAME, InProgress, null);
    TaskData taskData3 = mockTaskData(3, NAME, Completed, null);
    TaskData taskData4 = mockTaskData(4, NAME, Suspended, null);
    Task task1 = mockTask(taskData1.getTaskId());
    Task task2 = mockTask(taskData2.getTaskId());
    Task task3 = mockTask(taskData3.getTaskId());
    Task task4 = mockTask(taskData4.getTaskId());
    List<TaskData> taskDataList = mockTaskDataList(taskData1, taskData2, taskData3, taskData4);
    TaskAssigningSolution solution = mockSolution(Arrays.asList(task1, task2, task3, task4), Collections.emptyList());
    taskDataList.forEach(taskData -> context.setTaskChangeTime(taskData.getTaskId(), taskData.getLastModificationDate()));
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(taskDataList).withUserSystem(userSystemService).withContext(context).build();
    assertEquals(2, result.size());
    assertChangeIsTheChangeSetId(result, 0);
    assertChangeIsTheDummyTaskAssigned(result, ModelConstants.DUMMY_TASK_PLANNER_241, 1);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) DisableUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange) ReleaseTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange) UserPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) AddTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange) AddUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange) RemoveTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange) ProblemFactChange(org.optaplanner.core.impl.solver.ProblemFactChange) RemoveUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange) TaskData(org.kie.server.api.model.taskassigning.TaskData) TaskUtil.fromTaskData(org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData) Test(org.junit.Test)

Example 63 with Task

use of org.kie.server.services.taskassigning.core.model.Task in project droolsjbpm-integration by kiegroup.

the class SolverHandlerTest method onSolutionSynchronizedWithChanges.

@Test
public void onSolutionSynchronizedWithChanges() {
    prepareStart();
    List<ProblemFactChange<TaskAssigningSolution>> changes = new ArrayList<>();
    changes.add(new TaskPropertyChangeProblemFactChange(new Task()));
    SolutionSynchronizer.Result result = SolutionSynchronizer.Result.forChanges(changes);
    doReturn(true).when(solverExecutor).isStarted();
    synchronizerConsumerCaptor.getValue().accept(result);
    verify(solverExecutor).addProblemFactChanges(changes);
    verify(solutionProcessor, never()).process(any(TaskAssigningSolution.class));
    verify(solutionSynchronizer, never()).synchronizeSolution(any(TaskAssigningSolution.class), any(LocalDateTime.class));
}
Also used : LocalDateTime(java.time.LocalDateTime) Task(org.kie.server.services.taskassigning.core.model.Task) ArrayList(java.util.ArrayList) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) ProblemFactChange(org.optaplanner.core.impl.solver.ProblemFactChange) Test(org.junit.Test)

Aggregations

Task (org.kie.server.services.taskassigning.core.model.Task)63 User (org.kie.server.services.taskassigning.core.model.User)32 Test (org.junit.Test)26 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)23 TaskOrUser (org.kie.server.services.taskassigning.core.model.TaskOrUser)21 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)15 ArrayList (java.util.ArrayList)14 TaskPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange)12 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)12 AddTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)11 AssignTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)11 TaskData (org.kie.server.api.model.taskassigning.TaskData)10 AddUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)10 DisableUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)10 ReleaseTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)10 RemoveTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)10 RemoveUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange)10 UserPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)10 TaskUtil.fromTaskData (org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)8 UserUtil.fromExternalUser (org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser)8