@Override protected void populate(Element xml, Sample sample) { xml.setAttribute("alias", sample.getAlias()); xml.setAttribute("center_name", centreName); Element sampleTitle = xml.getOwnerDocument().createElementNS(null, "TITLE"); sampleTitle.setTextContent(sample.getAlias()); xml.appendChild(sampleTitle); Element sampleName = xml.getOwnerDocument().createElementNS(null, "SAMPLE_NAME"); Element sampleScientificName = xml.getOwnerDocument().createElementNS(null, "SCIENTIFIC_NAME"); sampleScientificName.setTextContent(sample.getScientificName()); sampleName.appendChild(sampleScientificName); // 2/11/2011 Antony Colles moved IF !=null statement, to help produce valid submission XML. Element sampleTaxonIdentifier = xml.getOwnerDocument().createElementNS(null, "TAXON_ID"); if (!isStringEmptyOrNull(sample.getTaxonIdentifier())) { sampleTaxonIdentifier.setTextContent(sample.getTaxonIdentifier()); } else { sampleTaxonIdentifier.setTextContent("000001"); } sampleName.appendChild(sampleTaxonIdentifier); xml.appendChild(sampleName); Element sampleDescription = xml.getOwnerDocument().createElementNS(null, "DESCRIPTION"); sampleDescription.setTextContent(sample.getDescription()); xml.appendChild(sampleDescription); }
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.setScientificName(from.getScientificName()); dto.setTaxonIdentifier(from.getTaxonIdentifier()); if (from.getVolume() != null) {
target.setSampleType(source.getSampleType()); target.setReceivedDate(source.getReceivedDate()); target.setScientificName(source.getScientificName()); target.setTaxonIdentifier(source.getTaxonIdentifier());