Search in sources :

Example 16 with Dataset

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

the class StudyImporterForSzoboszlaiTest method importShapes.

@Test
public void importShapes() throws StudyImporterException, IOException {
    Dataset testDataset = getTestDataset();
    ParserFactory parserFactory = new ParserFactoryForDataset(testDataset);
    StudyImporterForSzoboszlai studyImporterForSzoboszlai = new StudyImporterForSzoboszlai(parserFactory, nodeFactory);
    studyImporterForSzoboszlai.setDataset(testDataset);
    Map<Integer, LatLng> localityMap = studyImporterForSzoboszlai.importShapes();
    LatLng centroid = localityMap.get(2361);
    assertThat(centroid, is(notNullValue()));
    assertThat(centroid.getLat(), is(34.00824202376044));
    assertThat(centroid.getLng(), is(-120.72716166720323));
}
Also used : Dataset(org.eol.globi.service.Dataset) LatLng(org.eol.globi.geo.LatLng) Test(org.junit.Test)

Example 17 with Dataset

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

the class DatasetFinderWithCacheIT method gitHubTest.

@Test
public void gitHubTest() throws DatasetFinderException {
    DatasetFinder finder = new DatasetFinderWithCache(new DatasetFinderGitHubArchive(), cachePath);
    Dataset dataset = DatasetFactory.datasetFor("globalbioticinteractions/Catalogue-of-Afrotropical-Bees", finder);
    assertThat(dataset.getArchiveURI().toString(), containsString("github.com"));
    assertThat(dataset.getResourceURI("globi.json").toString(), startsWith("jar:file:/"));
    assertThat(dataset.getCitation(), startsWith("Shan Kothari, Pers. Comm. 2014."));
}
Also used : DatasetFinder(org.eol.globi.service.DatasetFinder) Dataset(org.eol.globi.service.Dataset) DatasetFinderGitHubArchive(org.eol.globi.service.DatasetFinderGitHubArchive) Test(org.junit.Test)

Example 18 with Dataset

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

the class DatasetFinderWithCacheIT method assertTemplateDataset.

private void assertTemplateDataset(String expectedURIFragment, DatasetFinder datasetFinder, String expectedCitation) throws DatasetFinderException, IOException {
    DatasetFinder finder = new DatasetFinderWithCache(datasetFinder, cachePath);
    Dataset dataset = DatasetFactory.datasetFor("globalbioticinteractions/template-dataset", finder);
    assertThat(dataset.getArchiveURI().toString(), containsString(expectedURIFragment));
    assertThat(dataset.getResourceURI("globi.json").toString(), startsWith("jar:file:/"));
    assertThat(dataset.getCitation(), startsWith(expectedCitation));
}
Also used : DatasetFinder(org.eol.globi.service.DatasetFinder) Dataset(org.eol.globi.service.Dataset)

Example 19 with Dataset

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

the class StudyImporterForSzoboszlaiTest method getTestDataset.

private Dataset getTestDataset() throws IOException {
    JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Szoboszlai AI, Thayer JA, Wood SA, Sydeman WJ, Koehn LE (2015) Data from: Forage species in predator diets: synthesis of data from the California Current. Dryad Digital Repository. http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + "  \"doi\": \"http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + "  \"format\": \"szoboszlai\",\n" + "  \"resources\": {\n" + "    \"links\": \"szoboszlai/CCPDDlinkdata_v2.csv\",\n" + "    \"shapes\": \"szoboszlai/CCPDDlocationdata_test.zip\"\n" + "  }\n" + "}");
    Dataset dataset = new DatasetLocal();
    dataset.setConfig(config);
    return dataset;
}
Also used : Dataset(org.eol.globi.service.Dataset) JsonNode(org.codehaus.jackson.JsonNode) DatasetLocal(org.eol.globi.service.DatasetLocal) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 20 with Dataset

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

the class StudyImporterForGitHubData method importData.

public void importData(String repository) throws StudyImporterException {
    try {
        LOG.info("importing github repo [" + repository + "]...");
        Dataset dataset = DatasetFactory.datasetFor(repository, getDatasetFinder());
        nodeFactory.getOrCreateDataset(dataset);
        importData(dataset);
        LOG.info("importing github repo [" + repository + "] done.");
    } catch (StudyImporterException | DatasetFinderException ex) {
        String msg = "failed to import data from repo [" + repository + "]";
        LOG.error(msg, ex);
        throw new StudyImporterException(msg, ex);
    }
}
Also used : Dataset(org.eol.globi.service.Dataset) DatasetFinderException(org.eol.globi.service.DatasetFinderException)

Aggregations

Dataset (org.eol.globi.service.Dataset)31 Test (org.junit.Test)16 JsonNode (org.codehaus.jackson.JsonNode)11 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)9 DatasetImpl (org.eol.globi.service.DatasetImpl)9 IOException (java.io.IOException)6 InputStream (java.io.InputStream)5 URI (java.net.URI)5 URL (java.net.URL)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 DatasetFinder (org.eol.globi.service.DatasetFinder)4 Is.is (org.hamcrest.core.Is.is)4 Assert.assertNotNull (org.junit.Assert.assertNotNull)4 Assert.assertThat (org.junit.Assert.assertThat)4 CSVParser (com.Ostermiller.util.CSVParser)3 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)3 Map (java.util.Map)3 Assert (junit.framework.Assert)3 IOUtils (org.apache.commons.io.IOUtils)3