@Test public void testGetScientificName() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); ScientificName scientificName = null; CrsSpecimenTransformer crsSpecimenTransformer = new CrsSpecimenTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(specimenFile, etlStatistics); outerloop: for (XMLRecordInfo extracted : extractor) { Element rootElement = extracted.getRecord(); List<Element> elems = DOMUtil.getDescendants(rootElement, "ncrsDetermination"); for (Element element : elems) { String fullScientificNameStr = DOMUtil.getDescendantValue(element, "abcd:FullScientificNameString"); Object scientificNameObj = ReflectionUtil.call(crsSpecimenTransformer, "getScientificName", new Class[] {Element.class, String.class}, new Object[] {element, "Arts"}); scientificName = (ScientificName) scientificNameObj; if (scientificName != null && fullScientificNameStr.equals("Cleyera japonica")) break outerloop; } } ScientificName expectedSn = new ScientificName(); expectedSn.setFullScientificName("Cleyera japonica"); expectedSn.setGenusOrMonomial("Cleyera"); expectedSn.setSpecificEpithet("japonica"); expectedSn.setScientificNameGroup("cleyera japonica"); assertEquals("01",expectedSn.getFullScientificName(), scientificName.getFullScientificName()); assertEquals("02",expectedSn.getGenusOrMonomial(), scientificName.getGenusOrMonomial()); assertEquals("03",expectedSn.getSpecificEpithet(), scientificName.getSpecificEpithet()); assertEquals("04",expectedSn.getScientificNameGroup(), scientificName.getScientificNameGroup()); }
private ScientificName getScientificName(Element elem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(elem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(elem, "abcd:Subgenus")); sn.setSpecificEpithet(val(elem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(elem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(elem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(elem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(elem, "abcd:AuthorTeamOriginalAndYear")); String fullScientificNameStr = val(elem, "abcd:FullScientificNameString"); if (sn.getGenusOrMonomial() != null) { StringBuilder sb = new StringBuilder(); sb.append(sn.getGenusOrMonomial()).append(' '); if (sn.getSubgenus() != null) { sb.append("(").append(sn.getSubgenus()).append(") "); } if (sn.getSpecificEpithet() != null) { sb.append(sn.getSpecificEpithet()).append(' '); } if (sn.getInfraspecificEpithet() != null) { sb.append(sn.getInfraspecificEpithet()).append(' '); } if (sn.getAuthorshipVerbatim() != null) { sb.append(sn.getAuthorshipVerbatim()); } if (sb.length() != 0) { sn.setFullScientificName(sb.toString().trim()); } } else if (fullScientificNameStr != null) { sn.setFullScientificName(fullScientificNameStr); } else { List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) nextBest = val(elems.get(0), "abcd:taxonCoverage"); } sn.setFullScientificName(nextBest); } if (collectionType.equals("Mineralogy and Petrology") || collectionType.equals("Mineralogy") || collectionType.equals("Petrology")) { if (sn.getFullScientificName() != null) { sn.setScientificNameGroup(sn.getFullScientificName().toLowerCase()); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private ScientificName getScientificName(Element elem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(elem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(elem, "abcd:Subgenus")); sn.setSpecificEpithet(val(elem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(elem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(elem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(elem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(elem, "abcd:AuthorTeamOriginalAndYear")); String fullScientificNameStr = val(elem, "abcd:FullScientificNameString"); if (sn.getGenusOrMonomial() != null) { StringBuilder sb = new StringBuilder(); sb.append(sn.getGenusOrMonomial()).append(' '); if (sn.getSubgenus() != null) { sb.append("(").append(sn.getSubgenus()).append(") "); } if (sn.getSpecificEpithet() != null) { sb.append(sn.getSpecificEpithet()).append(' '); } if (sn.getInfraspecificEpithet() != null) { sb.append(sn.getInfraspecificEpithet()).append(' '); } if (sn.getAuthorshipVerbatim() != null) { sb.append(sn.getAuthorshipVerbatim()); } if (sb.length() != 0) { sn.setFullScientificName(sb.toString().trim()); } } else if (fullScientificNameStr != null) { sn.setFullScientificName(fullScientificNameStr); } else { List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) nextBest = val(elems.get(0), "abcd:taxonCoverage"); } sn.setFullScientificName(nextBest); } if (collectionType.equals("Mineralogy and Petrology") || collectionType.equals("Mineralogy") || collectionType.equals("Petrology")) { if (sn.getFullScientificName() != null) { sn.setScientificNameGroup(sn.getFullScientificName().toLowerCase()); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private ScientificName getScientificName(Element elem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(elem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(elem, "abcd:Subgenus")); sn.setSpecificEpithet(val(elem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(elem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(elem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(elem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(elem, "abcd:AuthorTeamOriginalAndYear")); String fullScientificNameStr = val(elem, "abcd:FullScientificNameString"); if (sn.getGenusOrMonomial() != null) { StringBuilder sb = new StringBuilder(); sb.append(sn.getGenusOrMonomial()).append(' '); if (sn.getSubgenus() != null) { sb.append("(").append(sn.getSubgenus()).append(") "); } if (sn.getSpecificEpithet() != null) { sb.append(sn.getSpecificEpithet()).append(' '); } if (sn.getInfraspecificEpithet() != null) { sb.append(sn.getInfraspecificEpithet()).append(' '); } if (sn.getAuthorshipVerbatim() != null) { sb.append(sn.getAuthorshipVerbatim()); } if (sb.length() != 0) { sn.setFullScientificName(sb.toString().trim()); } } else if (fullScientificNameStr != null) { sn.setFullScientificName(fullScientificNameStr); } else { List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) nextBest = val(elems.get(0), "abcd:taxonCoverage"); } sn.setFullScientificName(nextBest); } if (collectionType.equals("Mineralogy and Petrology") || collectionType.equals("Mineralogy") || collectionType.equals("Petrology")) { if (sn.getFullScientificName() != null) { sn.setScientificNameGroup(sn.getFullScientificName().toLowerCase()); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsSpecimenTransformer(ETLStatistics stats); }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private ScientificName getScientificName(Element elem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(elem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(elem, "abcd:Subgenus")); sn.setSpecificEpithet(val(elem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(elem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(elem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(elem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(elem, "abcd:AuthorTeamOriginalAndYear")); String fullScientificNameStr = val(elem, "abcd:FullScientificNameString"); if (sn.getGenusOrMonomial() != null) { StringBuilder sb = new StringBuilder(); sb.append(sn.getGenusOrMonomial()).append(' '); if (sn.getSubgenus() != null) { sb.append("(").append(sn.getSubgenus()).append(") "); } if (sn.getSpecificEpithet() != null) { sb.append(sn.getSpecificEpithet()).append(' '); } if (sn.getInfraspecificEpithet() != null) { sb.append(sn.getInfraspecificEpithet()).append(' '); } if (sn.getAuthorshipVerbatim() != null) { sb.append(sn.getAuthorshipVerbatim()); } if (sb.length() != 0) { sn.setFullScientificName(sb.toString().trim()); } } else if (fullScientificNameStr != null) { sn.setFullScientificName(fullScientificNameStr); } else { List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) nextBest = val(elems.get(0), "abcd:taxonCoverage"); } sn.setFullScientificName(nextBest); } if (collectionType.equals("Mineralogy and Petrology") || collectionType.equals("Mineralogy") || collectionType.equals("Petrology")) { if (sn.getFullScientificName() != null) { sn.setScientificNameGroup(sn.getFullScientificName().toLowerCase()); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsSpecimenTransformer(ETLStatistics stats);  }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private ScientificName getScientificName(Element elem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(elem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(elem, "abcd:Subgenus")); sn.setSpecificEpithet(val(elem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(elem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(elem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(elem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(elem, "abcd:AuthorTeamOriginalAndYear")); String fullScientificNameStr = val(elem, "abcd:FullScientificNameString"); if (sn.getGenusOrMonomial() != null) { StringBuilder sb = new StringBuilder(); sb.append(sn.getGenusOrMonomial()).append(' '); if (sn.getSubgenus() != null) { sb.append("(").append(sn.getSubgenus()).append(") "); } if (sn.getSpecificEpithet() != null) { sb.append(sn.getSpecificEpithet()).append(' '); } if (sn.getInfraspecificEpithet() != null) { sb.append(sn.getInfraspecificEpithet()).append(' '); } if (sn.getAuthorshipVerbatim() != null) { sb.append(sn.getAuthorshipVerbatim()); } if (sb.length() != 0) { sn.setFullScientificName(sb.toString().trim()); } } else if (fullScientificNameStr != null) { sn.setFullScientificName(fullScientificNameStr); } else { List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) nextBest = val(elems.get(0), "abcd:taxonCoverage"); } sn.setFullScientificName(nextBest); } if (collectionType.equals("Mineralogy and Petrology") || collectionType.equals("Mineralogy") || collectionType.equals("Petrology")) { if (sn.getFullScientificName() != null) { sn.setScientificNameGroup(sn.getFullScientificName().toLowerCase()); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsSpecimenTransformer(ETLStatistics stats);   }