private void validateStatusAndCompletion(ArrayRun arrayRun, ArrayRun beforeChange, List<ValidationError> errors) throws IOException { if (arrayRun.getHealth() == null) { errors.add(new ValidationError("status", "A status must be selected")); } else if (arrayRun.getHealth().isDone()) { if (arrayRun.getCompletionDate() == null) { errors.add(new ValidationError(FIELD_COMPLETIONDATE, "Completion date must be entered for a completed run")); } else if (!authorizationManager.isAdminUser() && beforeChange != null && beforeChange.getCompletionDate() != null && !arrayRun.getCompletionDate().equals(beforeChange.getCompletionDate())) { errors.add(new ValidationError(FIELD_COMPLETIONDATE, "Only admin may change completion date of a completed run")); } } else if (arrayRun.getCompletionDate() != null) { errors.add(new ValidationError(FIELD_COMPLETIONDATE, "Cannot set completion date for incomplete run")); } }
private void applyChanges(ArrayRun from, ArrayRun to) { to.setAlias(from.getAlias()); to.setDescription(from.getDescription()); to.setFilePath(from.getFilePath()); to.setArray(from.getArray()); to.setHealth(from.getHealth()); to.setStartDate(from.getStartDate()); to.setCompletionDate(from.getCompletionDate()); }
public static ArrayRunDto asDto(@Nonnull ArrayRun from) { ArrayRunDto dto = new ArrayRunDto(); dto.setId(from.getId()); dto.setAlias(from.getAlias()); dto.setDescription(from.getDescription()); dto.setFilePath(from.getFilePath()); if (from.getInstrument() != null) { dto.setInstrumentId(from.getInstrument().getId()); dto.setInstrumentName(from.getInstrument().getName()); } if (from.getArray() != null) { dto.setArray(asDto(from.getArray())); } dto.setStatus(from.getHealth().getKey()); if (from.getStartDate() != null) { dto.setStartDate(formatDate(from.getStartDate())); } if (from.getCompletionDate() != null) { dto.setCompletionDate(formatDate(from.getCompletionDate())); } if (from.getLastModified() != null) { dto.setLastModified(formatDate(from.getLastModified())); } return dto; }