@Test public void testGetScientificName() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); ScientificName sn = null; CrsMultiMediaTransformer crsMultiMediaTransformer = new CrsMultiMediaTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(multimediaFile, etlStatistics); outerloop: for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "objectID", "RMNH.INS.867435"); CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "input", extracted); Element oaiDcElem = getDescendant(extracted.getRecord(), "oai_dc:dc"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); String collectionType = DOMUtil.getDescendantValue(oaiDcElem, "abcd:CollectionType"); for (Element element : ncsrDeterminationElems) { String fullScientificNameStr = DOMUtil.getDescendantValue(element, "dwc:scientificName"); Object obj = ReflectionUtil.call(crsMultiMediaTransformer, "getScientificName", new Class[] {Element.class, String.class}, new Object[] {element, collectionType}); sn = (ScientificName) obj; if (sn != null && fullScientificNameStr.equals("Aedes kabaenensis")) break outerloop; } ScientificName expectedSn = new ScientificName(); expectedSn.setFullScientificName("Aedes kabaenensis"); expectedSn.setGenusOrMonomial("Aedes"); expectedSn.setScientificNameGroup("aedes kabaenensis"); assertNotNull(sn); assertEquals("01", expectedSn.getFullScientificName(), sn.getFullScientificName()); assertEquals("02", expectedSn.getGenusOrMonomial(), sn.getGenusOrMonomial()); assertEquals("03", expectedSn.getScientificNameGroup(), sn.getScientificNameGroup()); } }
private ScientificName getScientificName(Element ncrsDeterminationElem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(ncrsDeterminationElem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(ncrsDeterminationElem, "abcd:Subgenus")); sn.setSpecificEpithet(val(ncrsDeterminationElem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(ncrsDeterminationElem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(ncrsDeterminationElem, "dwc:nameAccordingTo")); String fullScientificNameStr = val(ncrsDeterminationElem, "dwc:scientificName"); 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(ncrsDeterminationElem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) { nextBest = val(elems.get(0), "ac: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 { sn.setScientificNameGroup("? ?"); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ScientificName getScientificName(Element ncrsDeterminationElem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(ncrsDeterminationElem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(ncrsDeterminationElem, "abcd:Subgenus")); sn.setSpecificEpithet(val(ncrsDeterminationElem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(ncrsDeterminationElem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(ncrsDeterminationElem, "dwc:nameAccordingTo")); String fullScientificNameStr = val(ncrsDeterminationElem, "dwc:scientificName"); 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(ncrsDeterminationElem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) { nextBest = val(elems.get(0), "ac: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 { sn.setScientificNameGroup("? ?"); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ScientificName getScientificName(Element ncrsDeterminationElem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(ncrsDeterminationElem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(ncrsDeterminationElem, "abcd:Subgenus")); sn.setSpecificEpithet(val(ncrsDeterminationElem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(ncrsDeterminationElem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(ncrsDeterminationElem, "dwc:nameAccordingTo")); String fullScientificNameStr = val(ncrsDeterminationElem, "dwc:scientificName"); 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(ncrsDeterminationElem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) { nextBest = val(elems.get(0), "ac: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 { sn.setScientificNameGroup("? ?"); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsMultiMediaTransformer(ETLStatistics stats); }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ScientificName getScientificName(Element ncrsDeterminationElem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(ncrsDeterminationElem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(ncrsDeterminationElem, "abcd:Subgenus")); sn.setSpecificEpithet(val(ncrsDeterminationElem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(ncrsDeterminationElem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(ncrsDeterminationElem, "dwc:nameAccordingTo")); String fullScientificNameStr = val(ncrsDeterminationElem, "dwc:scientificName"); 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(ncrsDeterminationElem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) { nextBest = val(elems.get(0), "ac: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 { sn.setScientificNameGroup("? ?"); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsMultiMediaTransformer(ETLStatistics stats);  }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ScientificName getScientificName(Element ncrsDeterminationElem, String collectionType) { ScientificName sn = new ScientificName(); sn.setGenusOrMonomial(val(ncrsDeterminationElem, "abcd:GenusOrMonomial")); sn.setSubgenus(val(ncrsDeterminationElem, "abcd:Subgenus")); sn.setSpecificEpithet(val(ncrsDeterminationElem, "abcd:SpeciesEpithet")); String subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:subspeciesepithet"); if (subSpeciesEpithetStr == null) { subSpeciesEpithetStr = val(ncrsDeterminationElem, "abcd:InfrasubspecificName"); } sn.setInfraspecificEpithet(subSpeciesEpithetStr); sn.setNameAddendum(val(ncrsDeterminationElem, "abcd:NameAddendum")); sn.setAuthorshipVerbatim(val(ncrsDeterminationElem, "dwc:nameAccordingTo")); String fullScientificNameStr = val(ncrsDeterminationElem, "dwc:scientificName"); 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(ncrsDeterminationElem, "ncrsHighername"); String nextBest = getBestTaxonCoverage(elems); if (nextBest == null && elems != null) { if (elems.size() > 0) { nextBest = val(elems.get(0), "ac: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 { sn.setScientificNameGroup("? ?"); } } else { TransformUtil.setScientificNameGroup(sn); } return sn; } CrsMultiMediaTransformer(ETLStatistics stats);   }