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; }
@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); }
@Override public Long create(SamplePurpose samplePurpose) throws IOException { authorizationManager.throwIfNotInternal(); User user = authorizationManager.getCurrentUser(); samplePurpose.setCreatedBy(user); samplePurpose.setUpdatedBy(user); return samplePurposeDao.addSamplePurpose(samplePurpose); }
@Override public Long addSamplePurpose(SamplePurpose samplePurpose) { Date now = new Date(); samplePurpose.setCreationDate(now); samplePurpose.setLastUpdated(now); return (Long) currentSession().save(samplePurpose); }
@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; }
private static SampleAliquotDto asAliquotSampleDto(@Nonnull SampleAliquot from) { SampleAliquotDto dto = null; if (isAliquotSingleCellSample(from)) { SampleAliquotSingleCell scFrom = (SampleAliquotSingleCell) from; SampleAliquotSingleCellDto sc = new SampleAliquotSingleCellDto(); setString(sc::setInputIntoLibrary, scFrom.getInputIntoLibrary()); dto = sc; } else { dto = new SampleAliquotDto(); } if (from.getSamplePurpose() != null) { dto.setSamplePurposeId(from.getSamplePurpose().getId()); } return dto; }
public static SamplePurpose to(@Nonnull SamplePurposeDto from) { SamplePurpose to = new SamplePurposeImpl(); to.setAlias(from.getAlias()); return to; }
aliquot.setSamplePurpose(samplePurposeService.getAll().stream().filter(samplePurpose -> samplePurpose.getAlias().equals("Library")) .findFirst().orElse(null)); aliquot.setProject(sample.getProject());