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);
}
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);
}
}
Aggregations