@Override @CoverageIgnore public String getLabelText() { return getLibrary().getAlias(); }
/** * Checks whether library's alias conforms to the naming scheme. Validation is skipped for DetailedLibraries * {@code if (library.hasNonStandardAlias())} * * @param library * @throws IOException * @throws IllegalArgumentException */ private void validateAliasOrThrow(Library library) throws IOException { validateAliasUniqueness(library); if (!isDetailedLibrary(library) || !((DetailedLibrary) library).hasNonStandardAlias()) { uk.ac.bbsrc.tgac.miso.core.service.naming.validation.ValidationResult aliasValidation = namingScheme.validateLibraryAlias(library .getAlias()); if (!aliasValidation.isValid()) { throw new IllegalArgumentException("Invalid library alias: '" + library.getAlias() + "' - " + aliasValidation.getMessage()); } } }
@CoverageIgnore @Override public int compareTo(Library l) { if (getId() != 0L && l.getId() != 0L) { if (getId() < l.getId()) return -1; if (getId() > l.getId()) return 1; } else if (getName() != null && l.getName() != null) { return getName().compareTo(l.getName()); } else if (getAlias() != null && l.getAlias() != null) { return getAlias().compareTo(l.getAlias()); } return 0; }
private void validateAliasUniqueness(Library library) throws IOException { // duplicate aliases may be allowed via naming scheme, or with nonStandardAlias=true in the case of a DetailedLibrary if (namingScheme.duplicateLibraryAliasAllowed() || (LimsUtils.isDetailedLibrary(library) && ((DetailedLibrary) library).hasNonStandardAlias())) { return; } List<Library> potentialDupes = listByAlias(library.getAlias()); for (Library potentialDupe : potentialDupes) { if (library.getId() == AbstractLibrary.UNSAVED_ID || library.getId() != potentialDupe.getId()) { // an existing DIFFERENT library already has this alias throw new IllegalArgumentException("NEW: A library with this alias already exists in the database"); } } }
@Override public void update(Library library) throws IOException { Library managed = get(library.getId()); managed.setChangeDetails(authorizationManager.getCurrentUser()); List<Index> originalIndices = new ArrayList<>(managed.getIndices()); authorizationManager.throwIfNotWritable(managed); maybeRemoveFromBox(library); boxService.throwIfBoxPositionIsFilled(library); boolean validateAliasUniqueness = !managed.getAlias().equals(library.getAlias()); validateChange(library, managed); applyChanges(managed, library); loadChildEntities(managed); makeChangeLogForIndices(originalIndices, managed.getIndices(), managed); save(managed, validateAliasUniqueness); boxService.updateBoxableLocation(library); }
/** * 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"); } }
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); }
@Override public Long create(Library library) throws IOException { if (library.getSample() != null && library.getSample().getId() == Sample.UNSAVED_ID) { Long sampleId = sampleService.create(library.getSample()); library.getSample().setId(sampleId); } loadChildEntities(library); boxService.throwIfBoxPositionIsFilled(library); library.setChangeDetails(authorizationManager.getCurrentUser()); if (library.getSecurityProfile() == null) { library.inheritPermissions(sampleService.get(library.getSample().getId())); } authorizationManager.throwIfNotWritable(library); validateParentOrThrow(library); // pre-save field generation library.setName(generateTemporaryName()); if (isStringEmptyOrNull(library.getAlias()) && namingScheme.hasLibraryAliasGenerator()) { library.setAlias(generateTemporaryName()); } if (library.getConcentration() == null) { library.setConcentrationUnits(null); } if (library.getVolume() == null) { library.setVolumeUnits(null); } validateChange(library, null); long savedId = save(library, true).getId(); boxService.updateBoxableLocation(library); return savedId; }
dto = new LibraryDto(); dto.setAlias(from.getAlias()); dto.setName(from.getName()); dto.setParentSampleId(from.getSample().getId());
if (lib != null) { v.setIndices(lib.getIndices()); v.setLibraryAlias(lib.getAlias()); v.setLibraryBarcode(lib.getIdentificationBarcode()); v.setLibraryDescription(lib.getDescription());
target.setConcentrationUnits(target.getConcentration() == null ? null : source.getConcentrationUnits()); target.setPlatformType(source.getPlatformType()); target.setAlias(source.getAlias()); target.setPaired(source.getPaired()); target.setLowQuality(source.isLowQuality());