/** * 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; }