use of org.kie.kogito.taskassigning.service.event.TaskDataEvent in project kogito-apps by kiegroup.
the class TaskAssigningServiceTest method mockTaskDataEvent.
private static TaskDataEvent mockTaskDataEvent(String taskId, String state, ZonedDateTime lastUpdate) {
TaskData taskData = mock(TaskData.class);
doReturn(taskId).when(taskData).getId();
doReturn(state).when(taskData).getState();
doReturn(lastUpdate).when(taskData).getLastUpdate();
return new TaskDataEvent(taskData);
}
use of org.kie.kogito.taskassigning.service.event.TaskDataEvent in project kogito-apps by kiegroup.
the class EventUtilTest method mockTaskDataEvent.
private static TaskDataEvent mockTaskDataEvent(String taskId, ZonedDateTime lastUpdate) {
TaskData taskData = mock(TaskData.class);
doReturn(taskId).when(taskData).getId();
doReturn(lastUpdate).when(taskData).getLastUpdate();
return new TaskDataEvent(taskData);
}
use of org.kie.kogito.taskassigning.service.event.TaskDataEvent 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