@Test public void testDoTransform() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); NsrTaxonTransformer nsrTaxonTransformer = new NsrTaxonTransformer(etlStatistics); List<Taxon> transformed = null; LineNumberReader lnr; FileReader fr = new FileReader(nsrFile); lnr = new LineNumberReader(fr, 4096); String json; while ((json = lnr.readLine()) != null) { NsrTaxonTransformer taxonTransformer = new NsrTaxonTransformer(etlStatistics); transformed = taxonTransformer.transform(json); } Taxon actual = transformed.get(0); String expectedId = "D3KF0JNQ0UA@NSR"; String expectedSourceSystemId = "D3KF0JNQ0UA"; String expectedAuthorName = "Pontoppidan"; String expectedFullScintificName = "Larus argentatus argentatus Pontoppidan, 1763"; String expectedGenusOrMonomial = "Larus"; String expectedScientificNameGroup = "larus argentatus argentatus"; String recordUri = "http: String sourceSystemName = "Naturalis - Dutch Species Register"; assertEquals(expectedId, actual.getId()); assertEquals(expectedSourceSystemId, actual.getSourceSystemId()); assertEquals(expectedAuthorName, actual.getAcceptedName().getAuthor().toString()); assertEquals(recordUri, actual.getRecordURI().toString()); assertEquals(expectedFullScintificName, actual.getAcceptedName().getFullScientificName()); assertEquals(expectedGenusOrMonomial, actual.getAcceptedName().getGenusOrMonomial()); assertEquals(expectedScientificNameGroup, actual.getAcceptedName().getScientificNameGroup()); assertEquals(sourceSystemName, actual.getSourceSystem().getName()); }
@Override protected List<Taxon> doTransform() { try { String rank = val(nsrTaxon.getRank()); if (invalidRank(rank)) { return null; } Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(NSR, objectID)); if (!addScientificNames(taxon)) { return null; } if (testGenera != null && !hasTestGenus(taxon)) { stats.recordsSkipped++; return null; } addSystemClassification(taxon); addDefaultClassification(taxon); taxon.setSourceSystem(NSR); taxon.setSourceSystemId(objectID); taxon.setTaxonRank(rank); String s = getOccurrenceStatusVerbatim(nsrTaxon.getStatus()); taxon.setOccurrenceStatusVerbatim(s); taxon.setSourceSystemParentId(val(nsrTaxon.getNsr_id_parent())); setRecordURI(taxon); addVernacularNames(taxon); addDescriptions(taxon); stats.recordsAccepted++; stats.objectsProcessed++; stats.objectsAccepted++; return Collections.singletonList(taxon); } catch (Throwable t) { stats.recordsRejected++; if (!suppressErrors) error("Record rejected! {}", t.getMessage()); return null; } }
NsrTaxonTransformer extends AbstractJSONTransformer<Taxon> { @Override protected List<Taxon> doTransform() { try { String rank = val(nsrTaxon.getRank()); if (invalidRank(rank)) { return null; } Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(NSR, objectID)); if (!addScientificNames(taxon)) { return null; } if (testGenera != null && !hasTestGenus(taxon)) { stats.recordsSkipped++; return null; } addSystemClassification(taxon); addDefaultClassification(taxon); taxon.setSourceSystem(NSR); taxon.setSourceSystemId(objectID); taxon.setTaxonRank(rank); String s = getOccurrenceStatusVerbatim(nsrTaxon.getStatus()); taxon.setOccurrenceStatusVerbatim(s); taxon.setSourceSystemParentId(val(nsrTaxon.getNsr_id_parent())); setRecordURI(taxon); addVernacularNames(taxon); addDescriptions(taxon); stats.recordsAccepted++; stats.objectsProcessed++; stats.objectsAccepted++; return Collections.singletonList(taxon); } catch (Throwable t) { stats.recordsRejected++; if (!suppressErrors) error("Record rejected! {}", t.getMessage()); return null; } } }
NsrTaxonTransformer extends AbstractJSONTransformer<Taxon> { @Override protected List<Taxon> doTransform() { try { String rank = val(nsrTaxon.getRank()); if (invalidRank(rank)) { return null; } Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(NSR, objectID)); if (!addScientificNames(taxon)) { return null; } if (testGenera != null && !hasTestGenus(taxon)) { stats.recordsSkipped++; return null; } addSystemClassification(taxon); addDefaultClassification(taxon); taxon.setSourceSystem(NSR); taxon.setSourceSystemId(objectID); taxon.setTaxonRank(rank); String s = getOccurrenceStatusVerbatim(nsrTaxon.getStatus()); taxon.setOccurrenceStatusVerbatim(s); taxon.setSourceSystemParentId(val(nsrTaxon.getNsr_id_parent())); setRecordURI(taxon); addVernacularNames(taxon); addDescriptions(taxon); stats.recordsAccepted++; stats.objectsProcessed++; stats.objectsAccepted++; return Collections.singletonList(taxon); } catch (Throwable t) { stats.recordsRejected++; if (!suppressErrors) error("Record rejected! {}", t.getMessage()); return null; } } NsrTaxonTransformer(ETLStatistics stats); }
NsrTaxonTransformer extends AbstractJSONTransformer<Taxon> { @Override protected List<Taxon> doTransform() { try { String rank = val(nsrTaxon.getRank()); if (invalidRank(rank)) { return null; } Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(NSR, objectID)); if (!addScientificNames(taxon)) { return null; } if (testGenera != null && !hasTestGenus(taxon)) { stats.recordsSkipped++; return null; } addSystemClassification(taxon); addDefaultClassification(taxon); taxon.setSourceSystem(NSR); taxon.setSourceSystemId(objectID); taxon.setTaxonRank(rank); String s = getOccurrenceStatusVerbatim(nsrTaxon.getStatus()); taxon.setOccurrenceStatusVerbatim(s); taxon.setSourceSystemParentId(val(nsrTaxon.getNsr_id_parent())); setRecordURI(taxon); addVernacularNames(taxon); addDescriptions(taxon); stats.recordsAccepted++; stats.objectsProcessed++; stats.objectsAccepted++; return Collections.singletonList(taxon); } catch (Throwable t) { stats.recordsRejected++; if (!suppressErrors) error("Record rejected! {}", t.getMessage()); return null; } } NsrTaxonTransformer(ETLStatistics stats);  }
NsrTaxonTransformer extends AbstractJSONTransformer<Taxon> { @Override protected List<Taxon> doTransform() { try { String rank = val(nsrTaxon.getRank()); if (invalidRank(rank)) { return null; } Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(NSR, objectID)); if (!addScientificNames(taxon)) { return null; } if (testGenera != null && !hasTestGenus(taxon)) { stats.recordsSkipped++; return null; } addSystemClassification(taxon); addDefaultClassification(taxon); taxon.setSourceSystem(NSR); taxon.setSourceSystemId(objectID); taxon.setTaxonRank(rank); String s = getOccurrenceStatusVerbatim(nsrTaxon.getStatus()); taxon.setOccurrenceStatusVerbatim(s); taxon.setSourceSystemParentId(val(nsrTaxon.getNsr_id_parent())); setRecordURI(taxon); addVernacularNames(taxon); addDescriptions(taxon); stats.recordsAccepted++; stats.objectsProcessed++; stats.objectsAccepted++; return Collections.singletonList(taxon); } catch (Throwable t) { stats.recordsRejected++; if (!suppressErrors) error("Record rejected! {}", t.getMessage()); return null; } } NsrTaxonTransformer(ETLStatistics stats);   }