/** * 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 LibraryDilution to(@Nonnull DilutionDto from) { LibraryDilution to = new LibraryDilution(); if (from.getId() != null) to.setId(from.getId()); if (!isStringEmptyOrNull(from.getName())) { to.setName(from.getName()); } to.setIdentificationBarcode(from.getIdentificationBarcode()); to.setConcentration(from.getConcentration() == null ? null : Double.valueOf(from.getConcentration())); to.setConcentrationUnits(from.getConcentrationUnits()); to.setNgUsed(from.getNgUsed() == null ? null : Double.valueOf(from.getNgUsed())); to.setVolume(from.getVolume() == null ? null : Double.valueOf(from.getVolume())); to.setVolumeUnits(from.getVolumeUnits()); to.setVolumeUsed(from.getVolumeUsed() == null ? null : Double.valueOf(from.getVolumeUsed())); to.setLibrary(to(from.getLibrary())); to.setCreationDate(parseDate(from.getCreationDate())); if (from.getTargetedSequencingId() != null) { to.setTargetedSequencing(new TargetedSequencing()); to.getTargetedSequencing().setId(from.getTargetedSequencingId()); } to.setBoxPosition((DilutionBoxPosition) makeBoxablePosition(from, to)); to.setDiscarded(from.isDiscarded()); return to; }
/** * Copies modifiable fields from the source LibraryDilution into the target LibraryDilution to be persisted * * @param target the persisted LibraryDilution to modify * @param source the modified LibraryDilution to copy modifiable fields from * @throws IOException */ private void applyChanges(LibraryDilution target, LibraryDilution source) { target.setTargetedSequencing(source.getTargetedSequencing()); target.setIdentificationBarcode(LimsUtils.nullifyStringIfBlank(source.getIdentificationBarcode())); target.setVolume(source.getVolume()); target.setVolumeUnits(target.getVolume() == null ? null : source.getVolumeUnits()); target.setConcentration(source.getConcentration()); target.setConcentrationUnits(target.getConcentration() == null ? null : source.getConcentrationUnits()); target.setNgUsed(source.getNgUsed()); target.setVolumeUsed(source.getVolumeUsed()); }