private void loadChildEntities(ArrayRun arrayRun) throws IOException { if (arrayRun.getInstrument() != null) { arrayRun.setInstrument(instrumentService.get(arrayRun.getInstrument().getId())); } if (arrayRun.getArray() != null) { Array array = arrayService.get(arrayRun.getArray().getId()); if (array == null) { // providing a way to detect "array not found" in validation arrayRun.getArray().setAlias(null); } else { arrayRun.setArray(array); } } }
errors.add(new ValidationError("alias", "Alias cannot be blank")); if (arrayRun.getInstrument() == null) { errors.add(new ValidationError("instrument", "An instrument must be selected")); } else if (arrayRun.getInstrument().getInstrumentModel().getInstrumentType() != InstrumentType.ARRAY_SCANNER) { errors.add(new ValidationError("instrument", "Instrument must be an array scanner"));
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; }
public static final ArrayRun to(@Nonnull ArrayRunDto from) { ArrayRun run = new ArrayRun(); if (from.getId() != null) { run.setId(from.getId()); } run.setAlias(from.getAlias()); run.setDescription(nullifyStringIfBlank(from.getDescription())); run.setFilePath(nullifyStringIfBlank(from.getFilePath())); run.setInstrument(new InstrumentImpl()); if (from.getInstrumentId() != null) { run.getInstrument().setId(from.getInstrumentId()); } if (from.getInstrumentName() != null) { run.getInstrument().setName(from.getInstrumentName()); } if (from.getArray() != null) { run.setArray(to(from.getArray())); } run.setHealth(HealthType.get(from.getStatus())); if (from.getStartDate() != null) { run.setStartDate(parseDate(from.getStartDate())); } if (from.getCompletionDate() != null) { run.setCompletionDate(parseDate(from.getCompletionDate())); } if (from.getLastModified() != null) { run.setLastModified(parseDate(from.getLastModified())); } return run; }