@Override public ValidationResult validateDeletion(SamplePurpose object) { ValidationResult result = new ValidationResult(); long usage = samplePurposeDao.getUsage(object); if (usage > 0L) { result.addError(new ValidationError("Sample Purpose '" + object.getAlias() + "' is used by " + usage + " samples")); } return result; }
@Override public void update(SamplePurpose samplePurpose) throws IOException { authorizationManager.throwIfNonAdmin(); SamplePurpose updatedSamplePurpose = get(samplePurpose.getId()); updatedSamplePurpose.setAlias(samplePurpose.getAlias()); User user = authorizationManager.getCurrentUser(); updatedSamplePurpose.setUpdatedBy(user); samplePurposeDao.update(updatedSamplePurpose); }
aliquot.setSamplePurpose(samplePurposeService.getAll().stream().filter(samplePurpose -> samplePurpose.getAlias().equals("Library")) .findFirst().orElse(null)); aliquot.setProject(sample.getProject());
public static SamplePurposeDto asDto(@Nonnull SamplePurpose from) { SamplePurposeDto dto = new SamplePurposeDto(); dto.setId(from.getId()); dto.setAlias(from.getAlias()); dto.setCreatedById(from.getCreatedBy().getUserId()); dto.setCreationDate(formatDateTime(from.getCreationDate())); dto.setUpdatedById(from.getUpdatedBy().getUserId()); dto.setLastUpdated(formatDateTime(from.getLastUpdated())); dto.setArchived(from.isArchived()); return dto; }