@Override public String getDescription(final CellReference cell) { final String propertyId = (String) cell.getPropertyId(); switch (propertyId) { case ProxyAction.PXY_ACTION_LAST_MODIFIED_AT: case ProxyActionStatus.PXY_AS_CREATED_AT: final Long timestamp = (Long) cell.getItem().getItemProperty(propertyId).getValue(); return SPDateTimeUtil.getFormattedDate(timestamp); case ProxyAction.PXY_ACTION_MAINTENANCE_WINDOW: final Action action = (Action) cell.getItem().getItemProperty(ProxyAction.PXY_ACTION).getValue(); return action.getMaintenanceWindowStartTime().map(this::getFormattedNextMaintenanceWindow).orElse(null); default: return null; } }
@Override public String getDescription(final CellReference cell) { final String propertyId = (String) cell.getPropertyId(); switch (propertyId) { case ProxyAction.PXY_ACTION_LAST_MODIFIED_AT: case ProxyActionStatus.PXY_AS_CREATED_AT: final Long timestamp = (Long) cell.getItem().getItemProperty(propertyId).getValue(); return SPDateTimeUtil.getFormattedDate(timestamp); case ProxyAction.PXY_ACTION_MAINTENANCE_WINDOW: final Action action = (Action) cell.getItem().getItemProperty(ProxyAction.PXY_ACTION).getValue(); return action.getMaintenanceWindowStartTime().map(this::getFormattedNextMaintenanceWindow).orElse(null); default: return null; } }
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; }