Search in sources :

Example 1 with AssignTaskProblemFactChange

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

the class SolutionChangesBuilderTest method addReassignReservedOrInProgressOrSuspendedTaskWhenItWasManuallyReassigned.

private void addReassignReservedOrInProgressOrSuspendedTaskWhenItWasManuallyReassigned(Status status, boolean addActualOwnerToSolution) {
    TaskData taskData = mockTaskData(TASK_ID, NAME, status, ACTUAL_OWNER_ENTITY_ID);
    Task task = fromTaskData(taskData);
    User user = mockUser(USER_ENTITY_ID);
    task.setUser(user);
    List<User> userList = new ArrayList<>();
    userList.add(user);
    if (addActualOwnerToSolution) {
        User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
        userList.add(actualOwner);
    }
    TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), userList);
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, new AssignTaskProblemFactChange(task, mockUser(ACTUAL_OWNER_ENTITY_ID), true));
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) UserUtil.fromExternalUser(org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser) User(org.kie.server.services.taskassigning.core.model.User) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) ArrayList(java.util.ArrayList) 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)

Example 2 with AssignTaskProblemFactChange

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

the class SolutionChangesBuilderTest method addPinReservedOrInProgressOrSuspendedTaskWhenPublishedAndNotYetPinned.

private void addPinReservedOrInProgressOrSuspendedTaskWhenPublishedAndNotYetPinned(Status status, boolean addActualOwnerToSolution) {
    TaskData taskData = mockTaskData(TASK_ID, NAME, status, ACTUAL_OWNER_ENTITY_ID);
    PlanningTask planningTask = mockPlanningTask(taskData.getTaskId(), true);
    planningTask.setIndex(0);
    taskData.setPlanningTask(planningTask);
    Task task = fromTaskData(taskData);
    task.setPinned(false);
    User actualOwner = mockUser(ACTUAL_OWNER_ENTITY_ID);
    task.setUser(actualOwner);
    List<User> userList = new ArrayList<>();
    if (addActualOwnerToSolution) {
        userList.add(actualOwner);
    }
    TaskAssigningSolution solution = mockSolution(Collections.singletonList(task), userList);
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(mockTaskDataList(taskData)).withUserSystem(userSystemService).withContext(context).build();
    assertChangeIsTheChangeSetId(result, 0);
    assertChange(result, 1, new AssignTaskProblemFactChange(task, mockUser(ACTUAL_OWNER_ENTITY_ID), true));
    assertTaskChangeRegistered(taskData.getTaskId(), taskData.getLastModificationDate());
}
Also used : PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) UserUtil.fromExternalUser(org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser) User(org.kie.server.services.taskassigning.core.model.User) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) ArrayList(java.util.ArrayList) 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)

Example 3 with AssignTaskProblemFactChange

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

the class SolutionChangesBuilderTest method assertChange.

private void assertChange(List<ProblemFactChange<TaskAssigningSolution>> result, int index, AssignTaskProblemFactChange expected) {
    AssignTaskProblemFactChange change = (AssignTaskProblemFactChange) result.get(index);
    assertTaskEquals(expected.getTask(), change.getTask());
    assertUserEquals(expected.getUser(), change.getUser());
}
Also used : AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)

Example 4 with AssignTaskProblemFactChange

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

the class SolutionChangesBuilderTest method assertChangeIsTheDummyTaskAssigned.

private void assertChangeIsTheDummyTaskAssigned(List<ProblemFactChange<TaskAssigningSolution>> result, Task dummyTask, int index) {
    assertTrue(result.get(index) instanceof AssignTaskProblemFactChange);
    AssignTaskProblemFactChange change = (AssignTaskProblemFactChange) result.get(index);
    assertEquals(dummyTask, change.getTask());
}
Also used : AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)

Example 5 with AssignTaskProblemFactChange

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

the class SolutionChangesBuilder method addNewTaskChanges.

private void addNewTaskChanges(final TaskData taskData, final Map<String, User> usersById, final List<AddTaskProblemFactChange> newTaskChanges, final Map<String, List<IndexedElement<AssignTaskProblemFactChange>>> changesByUserId) {
    Task newTask;
    final Status taskDataStatus = convertFromString(taskData.getStatus());
    switch(taskDataStatus) {
        case Ready:
            newTask = fromTaskData(taskData);
            newTaskChanges.add(new AddTaskProblemFactChange(newTask));
            break;
        case Reserved:
        case InProgress:
        case Suspended:
            if (taskData.getActualOwner() != null) {
                newTask = fromTaskData(taskData);
                final User user = getUser(usersById, taskData.getActualOwner());
                // assign and ensure the task is published since the task was already seen by the public audience.
                AssignTaskProblemFactChange change = new AssignTaskProblemFactChange(newTask, user, true);
                addChangeToUser(changesByUserId, change, user, -1, true);
            }
            break;
        default:
            // out of the refresh interval, so there's nothing to do with them.
            break;
    }
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.server.services.taskassigning.core.model.Task) User(org.kie.server.services.taskassigning.core.model.User) UserUtil.fromExternalUser(org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) AddTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)

Aggregations

AssignTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)8 User (org.kie.server.services.taskassigning.core.model.User)5 AddTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)5 ReleaseTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)5 TaskPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange)5 UserUtil.fromExternalUser (org.kie.server.services.taskassigning.planning.util.UserUtil.fromExternalUser)5 TaskData (org.kie.server.api.model.taskassigning.TaskData)4 Task (org.kie.server.services.taskassigning.core.model.Task)4 AddUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)4 DisableUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)4 RemoveTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)4 RemoveUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange)4 UserPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)4 TaskUtil.fromTaskData (org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)4 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)4 ArrayList (java.util.ArrayList)3 Status (org.kie.api.task.model.Status)3 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)3 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)2 HashMap (java.util.HashMap)1