Search in sources :

Example 26 with Dataset

use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.

the class DatasetImporterForRSS method datasetFor.

private static Dataset datasetFor(Dataset datasetOrig, SyndEntry entry, Map<String, String> foreignEntries) {
    Dataset dataset;
    String title = entry.getTitle();
    String citation = StringUtils.trim(title);
    dataset = embeddedDatasetFor(datasetOrig, citation, URI.create(foreignEntries.get("dwca")), parseForeignEntriesAndCategories(entry));
    return dataset;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset)

Example 27 with Dataset

use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.

the class DatasetImporterForMetaTable method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    try {
        for (JsonNode tableConfig : collectTables(dataset)) {
            Dataset datasetProxy = new DatasetProxy(dataset);
            datasetProxy.setConfig(tableConfig);
            InteractionListener interactionListener = getInteractionListener();
            final InteractionListener listener = new TableInteractionListenerProxy(datasetProxy, interactionListener);
            importTable(listener, new TableParserFactoryImpl(), tableConfig, datasetProxy, getLogger());
        }
    } catch (IOException | NodeFactoryException e) {
        String msg = "problem importing from [" + getBaseUrl() + "]";
        LogUtil.logError(getLogger(), msg, e);
        throw new StudyImporterException(msg, e);
    }
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) Dataset(org.globalbioticinteractions.dataset.Dataset) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) DatasetProxy(org.globalbioticinteractions.dataset.DatasetProxy)

Example 28 with Dataset

use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest method assertTermValues.

public void assertTermValues(String firstFewLines, Map<String, String> expected) throws StudyImporterException {
    AtomicInteger atomicInteger = new AtomicInteger(0);
    Dataset dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), firstFewLines);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importer.setInteractionListener(link -> {
        int i = atomicInteger.incrementAndGet();
        expected.values().forEach(termName -> {
            assertThat(link.get(termName), is(expected.get(termName)));
        });
    });
    importStudy(importer);
    assertThat(atomicInteger.get(), greaterThan(0));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dataset(org.globalbioticinteractions.dataset.Dataset) URI(java.net.URI)

Example 29 with Dataset

use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest method associatedTaxaNotSupported.

@Test
public void associatedTaxaNotSupported() throws StudyImporterException {
    AtomicInteger atomicInteger = new AtomicInteger(0);
    String firstFewLines = "sourceTaxonName\tassociatedTaxa\n" + "Homo sapiens\teats: Canis lupus | eats: Felis catus";
    Dataset dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.tsv"), firstFewLines);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importer.setInteractionListener(link -> {
        int i = atomicInteger.incrementAndGet();
        assertThat(link.get(INTERACTION_TYPE_ID), is(nullValue()));
        assertThat(link.get(INTERACTION_TYPE_NAME), is(nullValue()));
        assertThat(link.get(TARGET_TAXON_NAME), is(nullValue()));
        assertThat(link.get(ASSOCIATED_TAXA), is(notNullValue()));
    });
    importStudy(importer);
    assertThat(atomicInteger.get(), greaterThan(0));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dataset(org.globalbioticinteractions.dataset.Dataset) URI(java.net.URI) Test(org.junit.Test)

Example 30 with Dataset

use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.

the class DatasetImporterForTSVTest method importFewLinesCSV.

@Test
public void importFewLinesCSV() throws StudyImporterException {
    Dataset dataset = getDataset(new TreeMap<URI, String>() {

        {
            put(URI.create("/interactions.csv"), firstFewLinesCSV);
        }
    });
    DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
    importer.setDataset(dataset);
    importStudy(importer);
    assertExists("TESTLeptoconchus incycloseris");
    assertExists("Sandalolitha dentata");
    assertStudyTitles("someRepodoi:10.1007/s13127-011-0039-1");
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Dataset (org.globalbioticinteractions.dataset.Dataset)68 Test (org.junit.Test)46 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)25 URI (java.net.URI)20 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 Matchers.containsString (org.hamcrest.Matchers.containsString)14 IOException (java.io.IOException)11 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)10 InputStream (java.io.InputStream)9 Is.is (org.hamcrest.core.Is.is)9 StudyNode (org.eol.globi.domain.StudyNode)8 Node (org.neo4j.graphdb.Node)8 URL (java.net.URL)7 ArrayList (java.util.ArrayList)7 StringStartsWith.startsWith (org.hamcrest.core.StringStartsWith.startsWith)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 BaseDatasetImporter (org.eol.globi.data.BaseDatasetImporter)6 DatasetImporter (org.eol.globi.data.DatasetImporter)6 DatasetNode (org.eol.globi.domain.DatasetNode)6