/** * @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; } }
/** * Calculates an etag for the given {@link Action} based on the entities * hashcode and the {@link Action#isHitAutoForceTime(long)} to reflect a * force switch. * * @param action * to calculate the etag for * @return the etag */ private static int calculateEtag(final Action action) { final int prime = 31; int result = action.hashCode(); int offsetPrime = action.isHitAutoForceTime(System.currentTimeMillis()) ? 1231 : 1237; offsetPrime = action.hasMaintenanceSchedule() && action.isMaintenanceWindowAvailable() ? 1249 : offsetPrime; result = prime * result + offsetPrime; return result; }
/** * Calculates an etag for the given {@link Action} based on the entities * hashcode and the {@link Action#isHitAutoForceTime(long)} to reflect a * force switch. * * @param action * to calculate the etag for * @return the etag */ private static int calculateEtag(final Action action) { final int prime = 31; int result = action.hashCode(); int offsetPrime = action.isHitAutoForceTime(System.currentTimeMillis()) ? 1231 : 1237; offsetPrime = (action.hasMaintenanceSchedule() && action.isMaintenanceWindowAvailable()) ? 1249 : offsetPrime; result = prime * result + offsetPrime; 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; }
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; }