@Override public String getDeleteDescription() { return getName() + (getLibrary() == null || getLibrary().getAlias() == null ? "" : " (" + getLibrary().getAlias() + ")"); }
private static String listIndices(LibraryDilution dilution) { return dilution.getLibrary().getIndices().stream().map(Index::getSequence).collect(Collectors.joining(", ")); }
private static <S extends DetailedSample, T> Function<LibraryDilution, T> detailedSample(Class<S> clazz, Function<S, T> function, T defaultValue) { return d -> { if (clazz.isInstance(d.getLibrary().getSample())) { return function.apply(clazz.cast(d.getLibrary().getSample())); } if (LimsUtils.isDetailedSample(d.getLibrary().getSample())) { S parent = LimsUtils.getParent(clazz, (DetailedSample) d.getLibrary().getSample()); if (parent != null) { return function.apply(parent); } } return defaultValue; }; }
@Override @CoverageIgnore public String getLabelText() { return getLibrary().getAlias(); }
private void validateTargetedSequencing(LibraryDilution dilution) { TargetedSequencing ts = dilution.getTargetedSequencing(); Library library = dilution.getLibrary(); if (ts == null) { if (isTargetedSequencingRequired(library)) { throw new IllegalArgumentException("Targeted sequencing value is required"); } } else { if (!isTargetedSequencingCompatible(ts, library)) { throwTargetedSequencingIncompatible(ts, library.getKitDescriptor()); } } }
/** * Generates a unique barcode for a Nameable entity, and sets the identificationBarcode property for Boxables and LibraryDilutions. * * @param nameable Nameable object * @throws IOException */ public static void generateAndSetIdBarcode(Nameable nameable) throws IOException { String barcode = null; if (nameable instanceof LibraryDilution && nameable.getName() != null) { barcode = nameable.getName(); if (((LibraryDilution) nameable).getLibrary() != null && ((LibraryDilution) nameable).getLibrary().getAlias() != null) { barcode += "::" + ((LibraryDilution) nameable).getLibrary().getAlias(); } ((LibraryDilution) nameable).setIdentificationBarcode(barcode); } else if (nameable instanceof Boxable && nameable.getName() != null) { barcode = nameable.getName(); if (((Boxable) nameable).getAlias() != null) { barcode += "::" + ((Boxable) nameable).getAlias(); } ((Boxable) nameable).setIdentificationBarcode(barcode); } else { throw new IOException("Error generating barcode"); } }
@Override public void afterDelete(LibraryDilution object) throws IOException { LibraryChangeLog changeLog = new LibraryChangeLog(); changeLog.setLibrary(object.getLibrary()); changeLog.setColumnsChanged(object.getName()); changeLog.setSummary("Deleted dilution " + object.getName() + "."); changeLog.setTime(new Date()); changeLog.setUser(authorizationManager.getCurrentUser()); changeLogService.create(changeLog); }
public static DilutionDto asDto(@Nonnull LibraryDilution from, boolean includeFullLibrary, boolean includeBoxPositions) { LibraryDto libDto = null; if (includeFullLibrary) { libDto = asDto(from.getLibrary(), false); } else { Library lib = from.getLibrary(); libDto = new LibraryDto(); libDto.setId(lib.getId()); libDto.setName(lib.getName()); libDto.setAlias(lib.getAlias()); libDto.setIdentificationBarcode(lib.getIdentificationBarcode()); if (lib.getPlatformType() != null) { libDto.setPlatformType(lib.getPlatformType().getKey()); } } return asDto(from, libDto, includeBoxPositions); }
if (them.getLibrary() != null) return false; } else if (!library.equals(them.getLibrary())) { return false;
/** * Loads persisted objects into LibraryDilution fields. Should be called before saving LibraryDilutions. Loads all member objects * <b>except</b> * <ul> * <li>creator/lastModifier User objects</li> * </ul> * * @param libraryDilution the LibraryDilution to load entities into. Must contain at least the IDs of objects to load (e.g. to load the * persisted Library * into dilution.library, dilution.library.id must be set) * @throws IOException */ private void loadChildEntities(LibraryDilution dilution) throws IOException { if (dilution.getLibrary() != null) { dilution.setLibrary(libraryService.get(dilution.getLibrary().getId())); } if (dilution.getTargetedSequencing() != null) { dilution.setTargetedSequencing(targetedSequencingService.get(dilution.getTargetedSequencing().getId())); } if (dilution.getSecurityProfile() != null && dilution.getSecurityProfile().getProfileId() != SecurityProfile.UNSAVED_ID) { dilution.setSecurityProfile(securityProfileStore.get(dilution.getSecurityProfile().getProfileId())); } }
@Override public Long create(LibraryDilution dilution) throws IOException { loadChildEntities(dilution); dilution.setCreator(authorizationManager.getCurrentUser()); if (dilution.getSecurityProfile() == null) { dilution.inheritPermissions(libraryService.get(dilution.getLibrary().getId())); } authorizationManager.throwIfNotWritable(dilution); boxService.throwIfBoxPositionIsFilled(dilution); if (dilution.getConcentration() == null) { dilution.setConcentrationUnits(null); } if (dilution.getVolume() == null) { dilution.setVolumeUnits(null); } Library library = dilution.getLibrary(); if (dilution.getVolumeUsed() != null && library.getVolume() != null) { library.setVolume(library.getVolume() - dilution.getVolumeUsed()); } dilution.setChangeDetails(authorizationManager.getCurrentUser()); // pre-save field generation dilution.setName(generateTemporaryName()); validateChange(dilution, null); long savedId = save(dilution).getId(); libraryService.update(library); boxService.updateBoxableLocation(dilution); return savedId; }
@Override public void update(LibraryDilution dilution) throws IOException { LibraryDilution managed = get(dilution.getId()); authorizationManager.throwIfNotWritable(managed); boxService.throwIfBoxPositionIsFilled(dilution); Library library = dilution.getLibrary(); if (library.getVolume() != null) { if (dilution.getVolumeUsed() != null && managed.getVolumeUsed() != null) { library.setVolume(library.getVolume() + managed.getVolumeUsed() - dilution.getVolumeUsed()); } else if (managed.getVolumeUsed() != null) { library.setVolume(library.getVolume() + managed.getVolumeUsed()); } else if (dilution.getVolumeUsed() != null) { library.setVolume(library.getVolume() - dilution.getVolumeUsed()); } } validateChange(dilution, managed); applyChanges(managed, dilution); managed.setChangeDetails(authorizationManager.getCurrentUser()); loadChildEntities(managed); save(managed); libraryService.update(library); boxService.updateBoxableLocation(dilution); }
Library lib = dilution.getLibrary(); if (lib != null) { v.setIndices(lib.getIndices());