private SampleClass singleResult(Collection<SampleClass> classes, SampleClass child, String parentCategory) { switch (classes.size()) { case 0: return null; case 1: return classes.iterator().next(); default: throw new IllegalStateException( String.format("SampleClass %s has multiple %s parents.", child.getAlias(), parentCategory)); } }
public static boolean isSampleSlide(DetailedSample sample) { return sample instanceof SampleSlide || sample.getSampleClass().getAlias().equals(SampleSlide.SAMPLE_CLASS_NAME); }
private void validateHierarchy(DetailedSample sample) throws IOException { Set<SampleValidRelationship> sampleValidRelationships = sampleValidRelationshipService.getAll(); if (!isValidRelationship(sampleValidRelationships, sample.getParent(), sample)) { throw new IllegalArgumentException("Parent " + sample.getParent().getSampleClass().getAlias() + " not permitted to have a child of type " + sample.getSampleClass().getAlias()); } }
private SampleAliquot buildAliquot() { SampleAliquot aliquot = null; if (sampleClass.getAlias().equals(SampleAliquotSingleCell.SAMPLE_CLASS_NAME)) { SampleAliquotSingleCell sc = new SampleAliquotSingleCellImpl(); sc.setInputIntoLibrary(inputIntoLibrary); aliquot = sc; } else { aliquot = new SampleAliquotImpl(); } aliquot.setSamplePurpose(samplePurpose); return aliquot; }
private SampleTissueProcessing buildTissueProcessing() { if (sampleClass.getAlias().equals(SampleSlide.SAMPLE_CLASS_NAME)) { SampleSlide slide = new SampleSlideImpl(); slide.setSlides(slides); slide.setDiscards(discards); slide.setThickness(thickness); slide.setStain(stain); return slide; } else if (sampleClass.getAlias().equals(SampleLCMTube.SAMPLE_CLASS_NAME)) { SampleLCMTube lcmTube = new SampleLCMTubeImpl(); lcmTube.setSlidesConsumed(slidesConsumed); return lcmTube; } else if (sampleClass.getAlias().equals(SampleSingleCell.SAMPLE_CLASS_NAME)) { SampleSingleCell sc = new SampleSingleCellImpl(); sc.setInitialCellConcentration(initialCellConcentration); sc.setDigestion(digestion); return sc; } else { return new SampleTissueProcessingImpl(); } }
private void validateParentOrThrow(Library library) { if (!isDetailedLibrary(library)) return; if (!isAliquotSample(library.getSample())) { String sc = null; if (isDetailedSample(library.getSample())) { DetailedSample sample = (DetailedSample) library.getSample(); sc = sample.getSampleClass() == null ? "not set" : sample.getSampleClass().getAlias(); } else { sc = "Plain Sample"; } throw new IllegalArgumentException(String.format("Sample Class '%s' is not a valid parent for Libraries. Must be an aliquot", sc)); } }
private SampleStock buildStock() { SampleStock stock = null; if (sampleClass.getAlias().equals(SampleStockSingleCell.SAMPLE_CLASS_NAME)) { SampleStockSingleCell sc = new SampleStockSingleCellImpl(); sc.setTargetCellRecovery(targetCellRecovery); sc.setCellViability(cellViability); sc.setLoadingCellConcentration(loadingCellConcentration); stock = sc; } else { stock = new SampleStockImpl(); } stock.setStrStatus(strStatus); stock.setDNAseTreated(dnaseTreated); return stock; }
@Override public void update(SampleClass sampleClass) throws IOException { authorizationManager.throwIfNonAdmin(); SampleClass updatedSampleClass = get(sampleClass.getId()); updatedSampleClass.setAlias(sampleClass.getAlias()); updatedSampleClass.setSampleCategory(sampleClass.getSampleCategory()); updatedSampleClass.setSuffix(sampleClass.getSuffix()); updatedSampleClass.setDNAseTreatable(sampleClass.getDNAseTreatable()); User user = authorizationManager.getCurrentUser(); updatedSampleClass.setUpdatedBy(user); sampleClassDao.update(updatedSampleClass); }
public static SampleClassDto asDto(@Nonnull SampleClass from) { SampleClassDto dto = new SampleClassDto(); dto.setId(from.getId()); dto.setAlias(from.getAlias()); dto.setSampleCategory(from.getSampleCategory()); dto.setSuffix(from.getSuffix()); dto.setArchived(from.isArchived()); dto.setDirectCreationAllowed(from.isDirectCreationAllowed()); dto.setCreatedById(from.getCreatedBy().getUserId()); dto.setCreationDate(formatDateTime(from.getCreationDate())); dto.setUpdatedById(from.getUpdatedBy().getUserId()); dto.setLastUpdated(formatDateTime(from.getLastUpdated())); dto.setDNAseTreatable(from.getDNAseTreatable()); return dto; }
if (!sampleClass.getId().equals(design.getSampleClass().getId())) { throw new IllegalArgumentException( "Cannot use design " + design.getName() + " for a library from a sample of type " + sampleClass.getAlias());