private void validateChange(Library library, Library beforeChange) throws IOException { List<ValidationError> errors = new ArrayList<>(); validateConcentrationUnits(library.getConcentration(), library.getConcentrationUnits(), errors); validateVolumeUnits(library.getVolume(), library.getVolumeUnits(), errors); validateBarcodeUniqueness(library, beforeChange, libraryDao::getByBarcode, errors, "library"); validateDistributionFields(library.isDistributed(), library.getDistributionDate(), library.getDistributionRecipient(), library.getBox(), errors); validateUnboxableFields(library.isDiscarded(), library.isDistributed(), library.getBox(), errors); if (library.getSpikeIn() != null) { if (library.getSpikeInDilutionFactor() == null) { errors.add(new ValidationError("spikeInDilutionFactor", "Spike-in dilution factor must be specified")); } if (library.getSpikeInVolume() == null) { errors.add(new ValidationError("spikeInVolume", "Spike-in volume must be specified")); } } if (!errors.isEmpty()) { throw new ValidationException(errors); } }
@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.setDescription(from.getDescription()); dto.setId(from.getId()); if (from.getConcentration() != null) { dto.setConcentration(from.getConcentration().toString());
target.setDescription(source.getDescription()); target.setIdentificationBarcode(LimsUtils.nullifyStringIfBlank(source.getIdentificationBarcode())); target.setConcentration(source.getConcentration()); target.setConcentrationUnits(target.getConcentration() == null ? null : source.getConcentrationUnits()); target.setPlatformType(source.getPlatformType()); target.setAlias(source.getAlias());