private void validateChange(Sample sample, Sample beforeChange) throws IOException { List<ValidationError> errors = new ArrayList<>(); validateConcentrationUnits(sample.getConcentration(), sample.getConcentrationUnits(), errors); validateVolumeUnits(sample.getVolume(), sample.getVolumeUnits(), errors); validateBarcodeUniqueness(sample, beforeChange, sampleStore::getByBarcode, errors, "sample"); validateDistributionFields(sample.isDistributed(), sample.getDistributionDate(), sample.getDistributionRecipient(), sample.getBox(), errors); validateUnboxableFields(sample.isDiscarded(), sample.isDistributed(), sample.getBox(), errors); if (taxonLookupEnabled && (beforeChange == null || !sample.getScientificName().equals(beforeChange.getScientificName())) && (sample.getScientificName() == null || TaxonomyUtils.checkScientificNameAtNCBI(sample.getScientificName()) == null)) { errors.add(new ValidationError("scientificName", "This scientific name is not of a known taxonomy")); } if (!errors.isEmpty()) { throw new ValidationException(errors); } }
dto.setVolume(from.getVolume().toString()); dto.setVolumeUnits(from.getVolumeUnits()); if (from.getConcentration() != null) { dto.setConcentration(from.getConcentration().toString());
target.setVolume(source.getVolume()); target.setVolumeUnits(target.getVolume() == null ? null : source.getVolumeUnits()); target.setConcentration(source.getConcentration()); target.setConcentrationUnits(target.getConcentration() == null ? null : source.getConcentrationUnits());