Search in sources :

Example 1 with TaskInfoChangeProblemFactChange

use of org.kie.kogito.taskassigning.core.model.solver.realtime.TaskInfoChangeProblemFactChange in project kogito-apps by kiegroup.

the class SolutionChangesBuilder method addTaskChanges.

private void addTaskChanges(TaskAssignment taskAssignment, TaskData taskData) {
    String taskState = taskData.getState();
    if (READY.value().equals(taskState)) {
        context.setTaskPublished(taskData.getId(), false);
        releasedTasksChanges.add(new ReleaseTaskProblemFactChange(taskAssignment));
    } else if (RESERVED.value().equals(taskState)) {
        context.setTaskPublished(taskData.getId(), true);
        if (!taskData.getActualOwner().equals(taskAssignment.getUser().getId()) || !taskAssignment.isPinned()) {
            final User user = getUser(usersById.get(taskData.getActualOwner()), taskData.getActualOwner());
            AssignTaskProblemFactChange change = new AssignTaskProblemFactChange(taskAssignment, user, true);
            addChangeToUser(assignToUserChangesByUserId, change, user, -1, true);
        }
    } else if (TaskState.isTerminal(taskState)) {
        removedTasksSet.add(taskAssignment);
    }
    if (!removedTasksSet.contains(taskAssignment)) {
        Task updatedTask = fromTaskData(taskData);
        if (!equalsByTaskInfoProperties(taskAssignment.getTask(), updatedTask)) {
            processorRegistry.applyAttributesProcessor(updatedTask, updatedTask.getAttributes());
        } else {
            updatedTask.setAttributes(taskAssignment.getTask().getAttributes());
        }
        taskPropertyChanges.add(new TaskInfoChangeProblemFactChange(taskAssignment, updatedTask));
    }
}
Also used : Task(org.kie.kogito.taskassigning.core.model.Task) ReleaseTaskProblemFactChange(org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange) UserUtil.fromExternalUser(org.kie.kogito.taskassigning.service.util.UserUtil.fromExternalUser) User(org.kie.kogito.taskassigning.core.model.User) AssignTaskProblemFactChange(org.kie.kogito.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) TaskInfoChangeProblemFactChange(org.kie.kogito.taskassigning.core.model.solver.realtime.TaskInfoChangeProblemFactChange)

Aggregations

Task (org.kie.kogito.taskassigning.core.model.Task)1 User (org.kie.kogito.taskassigning.core.model.User)1 AssignTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)1 ReleaseTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)1 TaskInfoChangeProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.TaskInfoChangeProblemFactChange)1 UserUtil.fromExternalUser (org.kie.kogito.taskassigning.service.util.UserUtil.fromExternalUser)1