@Test public void testGetIdentifications() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CrsMultiMediaTransformer crsMultiMediaTransformer = new CrsMultiMediaTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(multimediaFile, etlStatistics); ArrayList<MultiMediaContentIdentification> ids = null; 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"); String collectionType = DOMUtil.getDescendantValue(oaiDcElem, "abcd:CollectionType"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); Object obj = ReflectionUtil.call(crsMultiMediaTransformer, "getIdentifications", new Class[] {List.class, String.class}, new Object[] {ncsrDeterminationElems, collectionType}); ids = (ArrayList<MultiMediaContentIdentification>) obj; } assertNotNull(ids); assertEquals("Aedes kabaenensis", ids.stream().map(i -> i.getScientificName().getFullScientificName()).findFirst().get()); assertEquals("Aedes", ids.stream().map(i -> i.getScientificName().getGenusOrMonomial()).findFirst().get()); assertEquals("kabaenensis", ids.stream().map(i -> i.getScientificName().getSpecificEpithet()).findFirst().get()); assertEquals("01", "Aedes", ids.stream().map(i -> i.getDefaultClassification().getGenus()).findFirst().get()); assertEquals("02", "kabaenensis", ids.stream().map(i -> i.getDefaultClassification().getSpecificEpithet()).findFirst().get()); }
private ArrayList<MultiMediaContentIdentification> getIdentifications(List<Element> ncsrDeterminationElems, String collectionType) { ArrayList<MultiMediaContentIdentification> identifications = null; for (Element ncrsDeterminationElem : ncsrDeterminationElems) { ScientificName sn = getScientificName(ncrsDeterminationElem, collectionType); if (sn.getFullScientificName() == null) { if (logger.isDebugEnabled()) { debug("Identification is missing full scientific name"); } continue; } MultiMediaContentIdentification mmci = new MultiMediaContentIdentification(); mmci.setTypeStatus(getTypeStatus(ncrsDeterminationElem)); mmci.setScientificName(sn); List<Monomial> sc = getSystemClassification(ncrsDeterminationElem, mmci.getScientificName()); DefaultClassification dc = DefaultClassification.fromSystemClassification(sc); mmci.setDefaultClassification(dc); mmci.setIdentificationQualifiers(getQualifiers(ncrsDeterminationElem)); mmci.setVernacularNames(getVernacularNames(ncrsDeterminationElem)); if (identifications == null) { identifications = new ArrayList<>(ncsrDeterminationElems.size()); } identifications.add(mmci); } return identifications; }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ArrayList<MultiMediaContentIdentification> getIdentifications(List<Element> ncsrDeterminationElems, String collectionType) { ArrayList<MultiMediaContentIdentification> identifications = null; for (Element ncrsDeterminationElem : ncsrDeterminationElems) { ScientificName sn = getScientificName(ncrsDeterminationElem, collectionType); if (sn.getFullScientificName() == null) { if (logger.isDebugEnabled()) { debug("Identification is missing full scientific name"); } continue; } MultiMediaContentIdentification mmci = new MultiMediaContentIdentification(); mmci.setTypeStatus(getTypeStatus(ncrsDeterminationElem)); mmci.setScientificName(sn); List<Monomial> sc = getSystemClassification(ncrsDeterminationElem, mmci.getScientificName()); DefaultClassification dc = DefaultClassification.fromSystemClassification(sc); mmci.setDefaultClassification(dc); mmci.setIdentificationQualifiers(getQualifiers(ncrsDeterminationElem)); mmci.setVernacularNames(getVernacularNames(ncrsDeterminationElem)); if (identifications == null) { identifications = new ArrayList<>(ncsrDeterminationElems.size()); } identifications.add(mmci); } return identifications; } }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ArrayList<MultiMediaContentIdentification> getIdentifications(List<Element> ncsrDeterminationElems, String collectionType) { ArrayList<MultiMediaContentIdentification> identifications = null; for (Element ncrsDeterminationElem : ncsrDeterminationElems) { ScientificName sn = getScientificName(ncrsDeterminationElem, collectionType); if (sn.getFullScientificName() == null) { if (logger.isDebugEnabled()) { debug("Identification is missing full scientific name"); } continue; } MultiMediaContentIdentification mmci = new MultiMediaContentIdentification(); mmci.setTypeStatus(getTypeStatus(ncrsDeterminationElem)); mmci.setScientificName(sn); List<Monomial> sc = getSystemClassification(ncrsDeterminationElem, mmci.getScientificName()); DefaultClassification dc = DefaultClassification.fromSystemClassification(sc); mmci.setDefaultClassification(dc); mmci.setIdentificationQualifiers(getQualifiers(ncrsDeterminationElem)); mmci.setVernacularNames(getVernacularNames(ncrsDeterminationElem)); if (identifications == null) { identifications = new ArrayList<>(ncsrDeterminationElems.size()); } identifications.add(mmci); } return identifications; } CrsMultiMediaTransformer(ETLStatistics stats); }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ArrayList<MultiMediaContentIdentification> getIdentifications(List<Element> ncsrDeterminationElems, String collectionType) { ArrayList<MultiMediaContentIdentification> identifications = null; for (Element ncrsDeterminationElem : ncsrDeterminationElems) { ScientificName sn = getScientificName(ncrsDeterminationElem, collectionType); if (sn.getFullScientificName() == null) { if (logger.isDebugEnabled()) { debug("Identification is missing full scientific name"); } continue; } MultiMediaContentIdentification mmci = new MultiMediaContentIdentification(); mmci.setTypeStatus(getTypeStatus(ncrsDeterminationElem)); mmci.setScientificName(sn); List<Monomial> sc = getSystemClassification(ncrsDeterminationElem, mmci.getScientificName()); DefaultClassification dc = DefaultClassification.fromSystemClassification(sc); mmci.setDefaultClassification(dc); mmci.setIdentificationQualifiers(getQualifiers(ncrsDeterminationElem)); mmci.setVernacularNames(getVernacularNames(ncrsDeterminationElem)); if (identifications == null) { identifications = new ArrayList<>(ncsrDeterminationElems.size()); } identifications.add(mmci); } return identifications; } CrsMultiMediaTransformer(ETLStatistics stats);  }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private ArrayList<MultiMediaContentIdentification> getIdentifications(List<Element> ncsrDeterminationElems, String collectionType) { ArrayList<MultiMediaContentIdentification> identifications = null; for (Element ncrsDeterminationElem : ncsrDeterminationElems) { ScientificName sn = getScientificName(ncrsDeterminationElem, collectionType); if (sn.getFullScientificName() == null) { if (logger.isDebugEnabled()) { debug("Identification is missing full scientific name"); } continue; } MultiMediaContentIdentification mmci = new MultiMediaContentIdentification(); mmci.setTypeStatus(getTypeStatus(ncrsDeterminationElem)); mmci.setScientificName(sn); List<Monomial> sc = getSystemClassification(ncrsDeterminationElem, mmci.getScientificName()); DefaultClassification dc = DefaultClassification.fromSystemClassification(sc); mmci.setDefaultClassification(dc); mmci.setIdentificationQualifiers(getQualifiers(ncrsDeterminationElem)); mmci.setVernacularNames(getVernacularNames(ncrsDeterminationElem)); if (identifications == null) { identifications = new ArrayList<>(ncsrDeterminationElems.size()); } identifications.add(mmci); } return identifications; } CrsMultiMediaTransformer(ETLStatistics stats);   }