@Test public void testGetSystemClassification() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); int listSize = 0; List<Monomial> classification = null; ScientificName scientificName = new ScientificName(); scientificName.setFullScientificName("Cleyera japonica"); scientificName.setGenusOrMonomial("Cleyera"); scientificName.setSpecificEpithet("japonica"); scientificName.setAuthor("Plabon"); scientificName.setScientificNameGroup("cleyera japonica"); CrsSpecimenTransformer crsSpecimenTransformer = new CrsSpecimenTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(specimenFile, etlStatistics); outerloop: for (XMLRecordInfo extracted : extractor) { Element elemet = extracted.getRecord(); List<Element> elems = DOMUtil.getDescendants(elemet, "ncrsDetermination"); for (Element element : elems) { Object scientificNameObj = ReflectionUtil.callStatic(crsSpecimenTransformer.getClass(), "getSystemClassification", new Class[] {Element.class, ScientificName.class}, new Object[] {element, scientificName}); classification = (List<Monomial>) scientificNameObj; listSize = classification.size(); if (listSize > 0) break outerloop; } } Monomial expectedMono = new Monomial(); expectedMono.setName("Cleyera"); expectedMono.setRank("genus"); assertEquals("01",2, listSize); assertEquals("02",expectedMono.getName(), classification.get(0).getName()); assertEquals("03",expectedMono.getRank(), classification.get(0).getRank()); }
private static List<Monomial> getSystemClassification(Element elem, ScientificName sn) { List<Monomial> lowerClassification = TransformUtil.getMonomialsInName(sn); List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); if (elems == null) { return lowerClassification; } List<Monomial> classification = new ArrayList<>(); for (Element e : elems) { String rank = DOMUtil.getValue(e, "abcd:HigherTaxonRank"); String name = DOMUtil.getValue(e, "abcd:taxonCoverage"); classification.add(new Monomial(rank, name)); } if (lowerClassification != null) { classification.addAll(lowerClassification); } if (classification.size() == 0) { return null; } return classification; }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private static List<Monomial> getSystemClassification(Element elem, ScientificName sn) { List<Monomial> lowerClassification = TransformUtil.getMonomialsInName(sn); List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); if (elems == null) { return lowerClassification; } List<Monomial> classification = new ArrayList<>(); for (Element e : elems) { String rank = DOMUtil.getValue(e, "abcd:HigherTaxonRank"); String name = DOMUtil.getValue(e, "abcd:taxonCoverage"); classification.add(new Monomial(rank, name)); } if (lowerClassification != null) { classification.addAll(lowerClassification); } if (classification.size() == 0) { return null; } return classification; } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private static List<Monomial> getSystemClassification(Element elem, ScientificName sn) { List<Monomial> lowerClassification = TransformUtil.getMonomialsInName(sn); List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); if (elems == null) { return lowerClassification; } List<Monomial> classification = new ArrayList<>(); for (Element e : elems) { String rank = DOMUtil.getValue(e, "abcd:HigherTaxonRank"); String name = DOMUtil.getValue(e, "abcd:taxonCoverage"); classification.add(new Monomial(rank, name)); } if (lowerClassification != null) { classification.addAll(lowerClassification); } if (classification.size() == 0) { return null; } return classification; } CrsSpecimenTransformer(ETLStatistics stats); }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private static List<Monomial> getSystemClassification(Element elem, ScientificName sn) { List<Monomial> lowerClassification = TransformUtil.getMonomialsInName(sn); List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); if (elems == null) { return lowerClassification; } List<Monomial> classification = new ArrayList<>(); for (Element e : elems) { String rank = DOMUtil.getValue(e, "abcd:HigherTaxonRank"); String name = DOMUtil.getValue(e, "abcd:taxonCoverage"); classification.add(new Monomial(rank, name)); } if (lowerClassification != null) { classification.addAll(lowerClassification); } if (classification.size() == 0) { return null; } return classification; } CrsSpecimenTransformer(ETLStatistics stats);  }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private static List<Monomial> getSystemClassification(Element elem, ScientificName sn) { List<Monomial> lowerClassification = TransformUtil.getMonomialsInName(sn); List<Element> elems = DOMUtil.getChildren(elem, "ncrsHighername"); if (elems == null) { return lowerClassification; } List<Monomial> classification = new ArrayList<>(); for (Element e : elems) { String rank = DOMUtil.getValue(e, "abcd:HigherTaxonRank"); String name = DOMUtil.getValue(e, "abcd:taxonCoverage"); classification.add(new Monomial(rank, name)); } if (lowerClassification != null) { classification.addAll(lowerClassification); } if (classification.size() == 0) { return null; } return classification; } CrsSpecimenTransformer(ETLStatistics stats);   }