@Test public void executePlanningWithTaskNoLongerInActiveStatus() { List<TaskData> taskDataList = Collections.emptyList(); PlanningItem planningItem = mockPlanningItem(TASK_ID, CONTAINER_ID, ASSIGNED_USER_ID); PlanningItemList planningItemList = new PlanningItemList(Collections.singletonList(planningItem)); prepareExecution(taskDataList, CONTAINER_ID); PlanningExecutionResult result = serviceBase.executePlanning(planningItemList, USER_ID); String errorMessage = String.format(TASK_MODIFIED_ERROR_MSG_3, planningItem.getPlanningTask().getTaskId(), Arrays.toString(new Status[]{Ready, Reserved, InProgress, Suspended})); assertHasError(result, PlanningExecutionResult.ErrorCode.TASK_MODIFIED_SINCE_PLAN_CALCULATION_ERROR, errorMessage, CONTAINER_ID); }
public PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); checkServerStatus(); Map<String, List<PlanningCommand>> commandsByContainer; try { commandsByContainer = calculatePlanningCommands(planningItemList, userId); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan calculation, containerId: {}, error code: {}, message: {}", e.getContainerId(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .build(); } stopWatch.stop(); LOGGER.debug("Time to calculate the planning commands: {}", stopWatch); stopWatch.reset(); stopWatch.start(); for (Map.Entry<String, List<PlanningCommand>> entry : commandsByContainer.entrySet()) { try { executeContainerCommands(entry.getKey(), entry.getValue()); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan execution on containerId: {}, error code: {}, message: {}", entry.getKey(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, entry.getKey(), e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .containerId(entry.getKey()) .build(); } } stopWatch.stop(); LOGGER.debug("Time for executing the planning with planning items: {} -> {}", planningItemList.getItems().size(), stopWatch); return PlanningExecutionResult.builder().build(); }
TaskAssigningRuntimeServiceBase { public PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); checkServerStatus(); Map<String, List<PlanningCommand>> commandsByContainer; try { commandsByContainer = calculatePlanningCommands(planningItemList, userId); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan calculation, containerId: {}, error code: {}, message: {}", e.getContainerId(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .build(); } stopWatch.stop(); LOGGER.debug("Time to calculate the planning commands: {}", stopWatch); stopWatch.reset(); stopWatch.start(); for (Map.Entry<String, List<PlanningCommand>> entry : commandsByContainer.entrySet()) { try { executeContainerCommands(entry.getKey(), entry.getValue()); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan execution on containerId: {}, error code: {}, message: {}", entry.getKey(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, entry.getKey(), e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .containerId(entry.getKey()) .build(); } } stopWatch.stop(); LOGGER.debug("Time for executing the planning with planning items: {} -> {}", planningItemList.getItems().size(), stopWatch); return PlanningExecutionResult.builder().build(); } }
TaskAssigningRuntimeServiceBase { public PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); checkServerStatus(); Map<String, List<PlanningCommand>> commandsByContainer; try { commandsByContainer = calculatePlanningCommands(planningItemList, userId); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan calculation, containerId: {}, error code: {}, message: {}", e.getContainerId(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .build(); } stopWatch.stop(); LOGGER.debug("Time to calculate the planning commands: {}", stopWatch); stopWatch.reset(); stopWatch.start(); for (Map.Entry<String, List<PlanningCommand>> entry : commandsByContainer.entrySet()) { try { executeContainerCommands(entry.getKey(), entry.getValue()); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan execution on containerId: {}, error code: {}, message: {}", entry.getKey(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, entry.getKey(), e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .containerId(entry.getKey()) .build(); } } stopWatch.stop(); LOGGER.debug("Time for executing the planning with planning items: {} -> {}", planningItemList.getItems().size(), stopWatch); return PlanningExecutionResult.builder().build(); } TaskAssigningRuntimeServiceBase(KieServerImpl kieServer, KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); }
TaskAssigningRuntimeServiceBase { public PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); checkServerStatus(); Map<String, List<PlanningCommand>> commandsByContainer; try { commandsByContainer = calculatePlanningCommands(planningItemList, userId); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan calculation, containerId: {}, error code: {}, message: {}", e.getContainerId(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .build(); } stopWatch.stop(); LOGGER.debug("Time to calculate the planning commands: {}", stopWatch); stopWatch.reset(); stopWatch.start(); for (Map.Entry<String, List<PlanningCommand>> entry : commandsByContainer.entrySet()) { try { executeContainerCommands(entry.getKey(), entry.getValue()); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan execution on containerId: {}, error code: {}, message: {}", entry.getKey(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, entry.getKey(), e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .containerId(entry.getKey()) .build(); } } stopWatch.stop(); LOGGER.debug("Time for executing the planning with planning items: {} -> {}", planningItemList.getItems().size(), stopWatch); return PlanningExecutionResult.builder().build(); } TaskAssigningRuntimeServiceBase(KieServerImpl kieServer, KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); List<TaskData> executeFindTasksQuery(Map<String, Object> params); PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId); }
TaskAssigningRuntimeServiceBase { public PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); checkServerStatus(); Map<String, List<PlanningCommand>> commandsByContainer; try { commandsByContainer = calculatePlanningCommands(planningItemList, userId); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan calculation, containerId: {}, error code: {}, message: {}", e.getContainerId(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_CALCULATION, e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .build(); } stopWatch.stop(); LOGGER.debug("Time to calculate the planning commands: {}", stopWatch); stopWatch.reset(); stopWatch.start(); for (Map.Entry<String, List<PlanningCommand>> entry : commandsByContainer.entrySet()) { try { executeContainerCommands(entry.getKey(), entry.getValue()); } catch (PlanningException e) { LOGGER.debug("An error was produced during plan execution on containerId: {}, error code: {}, message: {}", entry.getKey(), e.getCode(), e.getMessage()); return PlanningExecutionResult.builder() .error(e.getCode()) .errorMessage(e.getMessage()) .containerId(e.getContainerId()) .build(); } catch (Exception e) { final String msg = String.format(UNEXPECTED_ERROR_DURING_PLAN_EXECUTION, entry.getKey(), e.getMessage()); LOGGER.error(msg, e); return PlanningExecutionResult.builder() .error(PlanningExecutionResult.ErrorCode.UNEXPECTED_ERROR) .errorMessage(msg) .containerId(entry.getKey()) .build(); } } stopWatch.stop(); LOGGER.debug("Time for executing the planning with planning items: {} -> {}", planningItemList.getItems().size(), stopWatch); return PlanningExecutionResult.builder().build(); } TaskAssigningRuntimeServiceBase(KieServerImpl kieServer, KieServerRegistry registry, UserTaskService userTaskService, QueryService queryService); List<TaskData> executeFindTasksQuery(Map<String, Object> params); PlanningExecutionResult executePlanning(PlanningItemList planningItemList, String userId);  }