/** * @return true when action is forced, false otherwise */ default boolean isForced() { return ActionType.FORCED.equals(getActionType()); }
/** * @return {@code true} if either the {@link #getActionType()} is * {@link ActionType#FORCED} or {@link ActionType#TIMEFORCED} but * then if the {@link #getForcedTime()} has been exceeded otherwise * always {@code false} */ default boolean isForce() { switch (getActionType()) { case FORCED: return true; case TIMEFORCED: return isHitAutoForceTime(System.currentTimeMillis()); default: return false; } }
private static StatusFontIcon createForcedLabelMetadata(final Action action) { StatusFontIcon result = null; if (ActionType.FORCED.equals(action.getActionType()) || ActionType.TIMEFORCED.equals(action.getActionType())) { result = new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_FORCED, "Forced", UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCED_LABEL_ID); } return result; }
private static StatusFontIcon createForcedLabelMetadata(final Action action) { StatusFontIcon result = null; if (ActionType.FORCED.equals(action.getActionType()) || ActionType.TIMEFORCED.equals(action.getActionType())) { result = new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_FORCED, "Forced", UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCED_LABEL_ID); } return result; }
/** * checks if the {@link #getForcedTime()} is hit by the given * {@code hitTimeMillis}, by means if the given milliseconds are greater * than the forcedTime. * * @param hitTimeMillis * the milliseconds, mostly the * {@link System#currentTimeMillis()} * @return {@code true} if this {@link #getActionType()} is in * {@link ActionType#TIMEFORCED} and the given {@code hitTimeMillis} * is greater than the {@link #getForcedTime()} otherwise * {@code false} */ default boolean isHitAutoForceTime(final long hitTimeMillis) { if (ActionType.TIMEFORCED.equals(getActionType())) { return hitTimeMillis >= getForcedTime(); } return false; }
private StatusFontIcon createTimeForcedLabelMetadata(final Action action) { StatusFontIcon result = null; if (ActionType.TIMEFORCED.equals(action.getActionType())) { final long currentTimeMillis = System.currentTimeMillis(); String style; String title; if (action.isHitAutoForceTime(currentTimeMillis)) { style = STATUS_ICON_GREEN; title = "auto forced since " + SPDateTimeUtil.getDurationFormattedString(action.getForcedTime(), currentTimeMillis, i18n); } else { style = STATUS_ICON_PENDING; title = "auto forcing in " + SPDateTimeUtil.getDurationFormattedString(currentTimeMillis, action.getForcedTime(), i18n); } result = new StatusFontIcon(FontAwesome.HISTORY, style, title, UIComponentIdProvider.ACTION_HISTORY_TABLE_TIMEFORCED_LABEL_ID); } return result; }
private StatusFontIcon createTimeForcedLabelMetadata(final Action action) { StatusFontIcon result = null; if (ActionType.TIMEFORCED.equals(action.getActionType())) { final long currentTimeMillis = System.currentTimeMillis(); String style; String title; if (action.isHitAutoForceTime(currentTimeMillis)) { style = STATUS_ICON_GREEN; title = "auto forced since " + SPDateTimeUtil.getDurationFormattedString(action.getForcedTime(), currentTimeMillis, i18n); } else { style = STATUS_ICON_PENDING; title = "auto forcing in " + SPDateTimeUtil.getDurationFormattedString(currentTimeMillis, action.getForcedTime(), i18n); } result = new StatusFontIcon(FontAwesome.HISTORY, style, title, UIComponentIdProvider.ACTION_HISTORY_TABLE_TIMEFORCED_LABEL_ID); } return result; }
static MgmtAction toResponse(final String targetId, final Action action) { final MgmtAction result = new MgmtAction(); result.setActionId(action.getId()); result.setType(getType(action)); if (ActionType.TIMEFORCED.equals(action.getActionType())) { result.setForceTime(action.getForcedTime()); } result.setForceType(MgmtRestModelMapper.convertActionType(action.getActionType())); if (action.isActive()) { result.setStatus(MgmtAction.ACTION_PENDING); } else { result.setStatus(MgmtAction.ACTION_FINISHED); } if (action.hasMaintenanceSchedule()) { final MgmtMaintenanceWindow maintenanceWindow = new MgmtMaintenanceWindow(); maintenanceWindow.setSchedule(action.getMaintenanceWindowSchedule()); maintenanceWindow.setDuration(action.getMaintenanceWindowDuration()); maintenanceWindow.setTimezone(action.getMaintenanceWindowTimeZone()); action.getMaintenanceWindowStartTime() .ifPresent(nextStart -> maintenanceWindow.setNextStartAt(nextStart.toInstant().toEpochMilli())); result.setMaintenanceWindow(maintenanceWindow); } MgmtRestModelMapper.mapBaseToBase(result, action); result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withSelfRel()); return result; }
.assignDistributionSet(set.getId(), ActionType.SOFT, 0, Arrays.asList(target.getControllerId())) .getActions().get(0); assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT);
public void getActionFromTarget() throws Exception { final Action action = generateActionForTarget(targetId, true, true); assertThat(deploymentManagement.findAction(action.getId()).get().getActionType()) .isEqualTo(ActionType.TIMEFORCED);