Search in sources :

Example 56 with Dataset

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

the class DatasetImplTest method useCitationFromMultipleTableDefinitionsWithDifferentCitations.

@Test
public void useCitationFromMultipleTableDefinitionsWithDifferentCitations() throws IOException {
    Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
    dataset.setConfig(new ObjectMapper().readTree(getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi-default-external-schemas-different-citations.json")));
    assertThat(dataset.getCitation(), is("a citation; other citation"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 57 with Dataset

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

the class DatasetImplTest method doiScrubbing.

@Test
public void doiScrubbing() throws IOException {
    Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
    dataset.setConfig(new ObjectMapper().readTree("{\"doi\": \"doi:http://dx.doi.org/10.2980/1195-6860(2006)13[23:TDOFUB]2.0.CO;2\" }"));
    assertThat(dataset.getDOI(), is(new DOI("2980", "1195-6860(2006)13[23:TDOFUB]2.0.CO;2")));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 58 with Dataset

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

the class DatasetImplTest method useCitationFromMultipleTableDefinitions.

@Test
public void useCitationFromMultipleTableDefinitions() throws IOException {
    Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
    dataset.setConfig(new ObjectMapper().readTree(getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi-default-external-schemas.json")));
    assertThat(dataset.getCitation(), is("Seltzer, Carrie; Wysocki, William; Palacios, Melissa; Eickhoff, Anna; Pilla, Hannah; Aungst, Jordan; Mercer, Aaron; Quicho, Jamie; Voss, Neil; Xu, Man; J. Ndangalasi, Henry; C. Lovett, Jon; J. Cordeiro, Norbert (2015): Plant-animal interactions from Africa. figshare. https://dx.doi.org/10.6084/m9.figshare.1526128"));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 59 with Dataset

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

the class DatasetImportUtilTest method listDependencies.

@Test
public void listDependencies() throws StudyImporterException, IOException {
    String jsonConfig = "{" + "  \"format\": \"dwca\", " + "  \"citation\": \"The MSB Division of Parasitology Collection\"," + "  \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_para\"," + "  \"references\": [" + "    {" + "      \"format\": \"dwca\"," + "      \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_host\"," + "      \"citation\": \"The MSB Division of Host Collection\"" + "    }, {" + "      \"format\": \"dwca\"," + "      \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_host2\"," + "      \"citation\": \"The MSB Division of Host Collection2\"" + "    }]" + "}";
    final DatasetImpl datasetOrig = new DatasetImpl("name/space", URI.create("some:uri"), in -> in);
    JsonNode objectNode = new ObjectMapper().readTree(jsonConfig);
    datasetOrig.setConfig(objectNode);
    final List<Dataset> references = getReferences(datasetOrig);
    assertThat(references.size(), Is.is(2));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 60 with Dataset

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

the class DatasetImportUtilTest method getReferences.

public static List<Dataset> getReferences(Dataset dataset) {
    List<Dataset> referenceList = new ArrayList<>();
    final JsonNode config = dataset.getConfig();
    final JsonNode references = config.get("references");
    if (references != null && references.isArray()) {
        for (JsonNode reference : references) {
            final DatasetProxy datasetProxy = new DatasetProxy(dataset);
            datasetProxy.setConfig(reference);
            referenceList.add(datasetProxy);
        }
    }
    return referenceList;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetProxy(org.globalbioticinteractions.dataset.DatasetProxy)

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