Search in sources :

Example 6 with UserDataEvent

use of org.kie.kogito.taskassigning.service.event.UserDataEvent in project kogito-apps by kiegroup.

the class EventUtilTest method filterNewestUserEvent.

@Test
void filterNewestUserEvent() {
    List<DataEvent<?>> eventList = buildDataEvents();
    UserDataEvent result = EventUtil.filterNewestUserEvent(eventList);
    assertThat(result).isSameAs(USER_DATA_EVENT_3);
}
Also used : TaskDataEvent(org.kie.kogito.taskassigning.service.event.TaskDataEvent) DataEvent(org.kie.kogito.taskassigning.service.event.DataEvent) UserDataEvent(org.kie.kogito.taskassigning.service.event.UserDataEvent) SolutionUpdatedOnBackgroundDataEvent(org.kie.kogito.taskassigning.service.event.SolutionUpdatedOnBackgroundDataEvent) UserDataEvent(org.kie.kogito.taskassigning.service.event.UserDataEvent) Test(org.junit.jupiter.api.Test)

Example 7 with UserDataEvent

use of org.kie.kogito.taskassigning.service.event.UserDataEvent in project kogito-apps by kiegroup.

the class TaskAssigningService method executeSolutionChange.

synchronized void executeSolutionChange(TaskAssigningSolution solution) {
    if (isNotOperative()) {
        LOGGER.warn(SERVICE_INOPERATIVE_MESSAGE, context.getStatus());
        return;
    }
    try {
        LOGGER.debug("process the next generated solution, applyingPlanningExecutionResult: {}", applyingPlanningExecutionResult.get());
        if (LOGGER.isTraceEnabled()) {
            traceSolution(LOGGER, solution);
        }
        clearWaitForImprovedSolutionTimer();
        currentSolution.set(solution);
        List<ProblemFactChange<TaskAssigningSolution>> pendingEventsChanges = null;
        if (applyingPlanningExecutionResult.get()) {
            // solution is the result of applying the pinning changes corresponding to the last executed plan,
            // prioritize events that could have arrived in the middle if any.
            applyingPlanningExecutionResult.set(false);
            List<DataEvent<?>> pendingEvents = pollEvents();
            List<TaskDataEvent> pendingTaskDataEvents = filterNewestTaskEventsInContext(context, pendingEvents);
            UserDataEvent pendingUserDataEvent = filterNewestUserEvent(pendingEvents);
            if (!pendingTaskDataEvents.isEmpty() || pendingUserDataEvent != null) {
                pendingEventsChanges = SolutionChangesBuilder.create().forSolution(solution).withContext(context).withUserServiceConnector(userServiceConnectorDelegate).withProcessors(processorRegistry).fromTasksData(fromTaskDataEvents(pendingTaskDataEvents)).fromUserDataEvent(pendingUserDataEvent).build();
            }
        }
        if (pendingEventsChanges != null && !pendingEventsChanges.isEmpty()) {
            LOGGER.debug("executeSolutionChange - we have pendingEventsChanges: {} to apply", pendingEventsChanges.size());
            cancelScheduledImproveSolutionOnBackgroundTimer();
            solverExecutor.addProblemFactChanges(pendingEventsChanges);
        } else {
            executePlanOrResumeEvents(solution);
        }
    } catch (Exception e) {
        failFast(e);
    }
}
Also used : TaskDataEvent(org.kie.kogito.taskassigning.service.event.TaskDataEvent) TaskDataEvent(org.kie.kogito.taskassigning.service.event.TaskDataEvent) UserDataEvent(org.kie.kogito.taskassigning.service.event.UserDataEvent) SolutionUpdatedOnBackgroundDataEvent(org.kie.kogito.taskassigning.service.event.SolutionUpdatedOnBackgroundDataEvent) DataEvent(org.kie.kogito.taskassigning.service.event.DataEvent) AssignTaskProblemFactChange(org.kie.kogito.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) ProblemFactChange(org.optaplanner.core.api.solver.ProblemFactChange) UserDataEvent(org.kie.kogito.taskassigning.service.event.UserDataEvent)

Aggregations

UserDataEvent (org.kie.kogito.taskassigning.service.event.UserDataEvent)7 AssignTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)5 ProblemFactChange (org.optaplanner.core.api.solver.ProblemFactChange)5 Test (org.junit.jupiter.api.Test)4 TaskAssigningSolution (org.kie.kogito.taskassigning.core.model.TaskAssigningSolution)4 User (org.kie.kogito.taskassigning.core.model.User)3 AddTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)3 AddUserProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)3 DisableUserProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)3 ReleaseTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)3 RemoveTaskProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)3 RemoveUserProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange)3 UserPropertyChangeProblemFactChange (org.kie.kogito.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)3 SolutionUpdatedOnBackgroundDataEvent (org.kie.kogito.taskassigning.service.event.SolutionUpdatedOnBackgroundDataEvent)3 TaskDataEvent (org.kie.kogito.taskassigning.service.event.TaskDataEvent)3 DataEvent (org.kie.kogito.taskassigning.service.event.DataEvent)2 ZonedDateTime (java.time.ZonedDateTime)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1