Search in sources :

Example 66 with Dataset

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

the class DatasetImporterForRSS method extractDatasets.

private static List<Dataset> extractDatasets(Dataset datasetOrig, SyndFeed feed) {
    List<Dataset> datasets = new ArrayList<>();
    final List entries = feed.getEntries();
    for (Object entry : entries) {
        if (entry instanceof SyndEntry) {
            String title = StringUtils.trim(((SyndEntry) entry).getTitle());
            if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) {
                Dataset e = datasetFor(datasetOrig, (SyndEntry) entry);
                LOG.info("including [" + title + "].");
                if (e != null) {
                    datasets.add(e);
                }
            } else {
                LOG.info("skipping [" + title + "] : was not included or excluded.");
            }
        }
    }
    return datasets;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 67 with Dataset

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

the class DatasetImporterForRSS method datasetForIPT.

private static Dataset datasetForIPT(Dataset datasetOrig, SyndEntry entry) {
    Dataset dataset = null;
    Map<String, String> foreignEntries = parseForeignEntriesAndCategories(entry);
    if (foreignEntries.containsKey("dwca")) {
        dataset = datasetFor(datasetOrig, entry, foreignEntries);
    }
    return dataset;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset)

Example 68 with Dataset

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

the class DatasetImporterForRegistry method importData.

private void importData(String namespace) throws StudyImporterException {
    try {
        LOG.info("[" + namespace + "] checking status...");
        Dataset dataset = new DatasetFactory(getRegistry()).datasetFor(namespace);
        if (datasetFilter.test(dataset)) {
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            LOG.info("[" + namespace + "] is active, importing...");
            getNodeFactory().getOrCreateDataset(dataset);
            importData(dataset);
            stopWatch.stop();
            LOG.info("[" + namespace + "] imported in " + stopWatch.getTime(TimeUnit.SECONDS) + "s");
        } else {
            LOG.info("[" + namespace + "] is deprecated, not importing.");
        }
    } catch (StudyImporterException | DatasetRegistryException ex) {
        String msg = "failed to import data from repo [" + namespace + "]";
        LOG.error(msg, ex);
        throw new StudyImporterException(msg, ex);
    }
}
Also used : DatasetRegistryException(org.globalbioticinteractions.dataset.DatasetRegistryException) Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory) StopWatch(org.apache.commons.lang3.time.StopWatch)

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