use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoftTest method parseRowsAndEnrich.
public static void parseRowsAndEnrich(JsonNode biodivTable, InteractionListener listener, ResourceService resourceService) throws StudyImporterException {
DatasetImporterForPensoft datasetImporterForPensoft = new DatasetImporterForPensoft(null, null);
datasetImporterForPensoft.parseRowsAndEnrich(biodivTable, listener, new NullImportLogger(), new OpenBiodivClientImpl(resourceService));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importRecordsFromMCZ.
@Test
public void importRecordsFromMCZ() throws StudyImporterException, URISyntaxException {
StringBuilder actualMessage = new StringBuilder();
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/mcz/meta.xml");
URI archiveRoot = new File(resource.toURI()).getParentFile().toURI();
AtomicInteger recordCounter = new AtomicInteger(0);
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setLogger(new NullImportLogger() {
@Override
public void severe(LogContext ctx, String message) {
actualMessage.append(message);
}
});
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", archiveRoot, inStream -> inStream));
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
for (String expectedProperty : new String[] {}) {
assertThat("no [" + expectedProperty + "] found in " + interaction, interaction.containsKey(expectedProperty), is(true));
assertThat("no value of [" + expectedProperty + "] found in " + interaction, interaction.get(expectedProperty), is(notNullValue()));
}
assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/ResourceRelationship | http://rs.tdwg.org/dwc/terms/Occurrence"));
recordCounter.incrementAndGet();
}
});
studyImporterForDwCA.importStudy();
assertThat(recordCounter.get(), is(0));
assertThat(actualMessage.toString(), startsWith("[failed to handle dwc record]"));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class InteractionListenerWithInteractionTypeMappingTest method withTaxonHierarchy.
@Test
public void withTaxonHierarchy() throws StudyImporterException {
final List<Map<String, String>> links = new ArrayList<Map<String, String>>();
InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() {
@Override
public boolean shouldIgnoreInteractionType(String nameOrId) {
return false;
}
@Override
public InteractType getInteractType(String nameOrId) {
return null;
}
}, new NullImportLogger());
listener.on(new HashMap<String, String>() {
{
put(INTERACTION_TYPE_NAME, "eats");
put(TaxonUtil.TARGET_TAXON_GENUS, "Donald");
put(TaxonUtil.TARGET_TAXON_SPECIFIC_EPITHET, "duck");
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_NAME), is("Donald duck"));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_PATH_NAMES), is("genus | species"));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_PATH), is("Donald | Donald duck"));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class TaxonNameEnricherTest method importWithMissingSourceTaxonButAvailableInstitutionCollectionCatalogTriple.
@Test
public void importWithMissingSourceTaxonButAvailableInstitutionCollectionCatalogTriple() throws StudyImporterException {
List<String> msgs = new ArrayList<>();
List<Map<String, String>> received = new ArrayList<>();
final InteractionListener listener = new TaxonNameEnricher(interaction -> received.add(interaction), new NullImportLogger() {
@Override
public void info(LogContext ctx, String message) {
msgs.add(message);
}
@Override
public void warn(LogContext ctx, String message) {
msgs.add(message);
}
@Override
public void severe(LogContext ctx, String message) {
msgs.add(message);
}
});
final TreeMap<String, String> link = new TreeMap<>();
link.put(TARGET_TAXON_NAME, "Donald duck");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, InteractType.ATE.getIRI());
link.put(SOURCE_OCCURRENCE_ID, "occurrenceId123");
link.put(SOURCE_INSTITUTION_CODE, "institutionCode123");
link.put(SOURCE_COLLECTION_CODE, "collectionCode123");
link.put(SOURCE_COLLECTION_ID, "collectionId123");
link.put(SOURCE_CATALOG_NUMBER, "catalogNumber123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_ID, "123");
link.put(REFERENCE_CITATION, "");
listener.on(link);
assertThat(msgs, hasItem("source taxon name missing: using institutionCode/collectionCode/collectionId/catalogNumber/occurrenceId as placeholder"));
assertThat(received.size(), is(1));
String expectedPlaceholder = "institutionCode123 | collectionCode123 | collectionId123 | catalogNumber123 | occurrenceId123";
assertThat(received.get(0).get(SOURCE_TAXON_NAME), is(expectedPlaceholder));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method malformedDOI.
@Test
public void malformedDOI() {
final List<String> msgs = new ArrayList<>();
InteractionListener interactionListener = new InteractionImporter(nodeFactory, new GeoNamesService() {
@Override
public boolean hasTermForLocale(String locality) {
return true;
}
@Override
public LatLng findLatLng(String locality) throws IOException {
throw new IOException("kaboom!");
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
msgs.add(message);
}
});
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
link.put(TARGET_TAXON_NAME, "mini");
link.put(REFERENCE_ID, "123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_CITATION, "");
link.put(REFERENCE_DOI, "bla:XXX");
try {
interactionListener.on(link);
assertThat(msgs.size(), is(1));
assertThat(msgs.get(0), startsWith("found malformed doi [bla:XXX]"));
} catch (StudyImporterException ex) {
fail("should not throw on failing geoname lookup");
}
}
Aggregations