Search in sources :

Example 61 with Dataset

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

the class DatasetTest method unknownResourceURL.

@Test(expected = IOException.class)
public void unknownResourceURL() throws IOException, URISyntaxException {
    URL resource = getClass().getResource("archive.zip");
    File archive = new File(resource.toURI());
    assertThat(archive.exists(), is(true));
    URI parentDir = archive.getParentFile().toURI();
    Dataset dataset = new DatasetImpl("some/namespace", parentDir, inStream -> inStream);
    assertThat(dataset.retrieve(URI.create("archivezz.zip")), is(notNullValue()));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) File(java.io.File) URI(java.net.URI) URL(java.net.URL) Test(org.junit.Test)

Example 62 with Dataset

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

the class NodeFactoryNeo4j method createInteraction.

@Override
public Interaction createInteraction(Study study) throws NodeFactoryException {
    InteractionNode interactionNode;
    Node node = graphDb.createNode();
    StudyNode studyNode = getOrCreateStudy(study);
    interactionNode = new InteractionNode(node);
    interactionNode.createRelationshipTo(studyNode, RelTypes.DERIVED_FROM);
    Dataset dataset = getOrCreateDatasetNoTx(study.getOriginatingDataset());
    if (dataset instanceof DatasetNode) {
        interactionNode.createRelationshipTo(dataset, RelTypes.ACCESSED_AT);
    }
    return interactionNode;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) JsonNode(com.fasterxml.jackson.databind.JsonNode) LocationNode(org.eol.globi.domain.LocationNode) EnvironmentNode(org.eol.globi.domain.EnvironmentNode) SpecimenNode(org.eol.globi.domain.SpecimenNode) Node(org.neo4j.graphdb.Node) SeasonNode(org.eol.globi.domain.SeasonNode) DatasetNode(org.eol.globi.domain.DatasetNode) StudyNode(org.eol.globi.domain.StudyNode) InteractionNode(org.eol.globi.domain.InteractionNode) InteractionNode(org.eol.globi.domain.InteractionNode) StudyNode(org.eol.globi.domain.StudyNode) DatasetNode(org.eol.globi.domain.DatasetNode)

Example 63 with Dataset

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

the class NodeFactoryNeo4j method createStudyNode.

private StudyNode createStudyNode(Study study, Node node) {
    StudyNode studyNode;
    studyNode = new StudyNode(node, study.getTitle());
    studyNode.setCitation(study.getCitation());
    studyNode.setDOI(study.getDOI());
    if (study.getDOI() != null) {
        String doiString = study.getDOI().toString();
        createExternalIdRelationIfExists(node, doiString, RelTypes.HAS_DOI);
    }
    String externalId = getExternalIdOrDOI(study);
    studyNode.setExternalId(externalId);
    createExternalIdRelationIfExists(node, externalId, RelTypes.HAS_EXTERNAL_ID);
    Dataset dataset = getOrCreateDatasetNoTx(study.getOriginatingDataset());
    if (dataset instanceof DatasetNode) {
        studyNode.createRelationshipTo(dataset, RelTypes.IN_DATASET);
    }
    studyNode.getUnderlyingNode().setProperty(StudyConstant.TITLE_IN_NAMESPACE, getIdInNamespace(study));
    return studyNode;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) StudyNode(org.eol.globi.domain.StudyNode) DatasetNode(org.eol.globi.domain.DatasetNode)

Example 64 with Dataset

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

the class NodeFactoryNeo4j3 method getOrCreateDatasetNoTx.

@Override
protected Dataset getOrCreateDatasetNoTx(Dataset originatingDataset) {
    Dataset datasetCreated = null;
    if (originatingDataset != null && StringUtils.isNotBlank(originatingDataset.getNamespace())) {
        Node node = getGraphDb().findNode(NodeLabel.Dataset, DatasetConstant.NAMESPACE, originatingDataset.getNamespace());
        Node datasetNode = node == null ? createDatasetNode(originatingDataset) : node;
        datasetCreated = new DatasetNode(datasetNode);
    }
    return datasetCreated;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetNode(org.eol.globi.domain.DatasetNode) LocationNode(org.eol.globi.domain.LocationNode) StudyNode(org.eol.globi.domain.StudyNode) Node(org.neo4j.graphdb.Node) SeasonNode(org.eol.globi.domain.SeasonNode) EnvironmentNode(org.eol.globi.domain.EnvironmentNode) DatasetNode(org.eol.globi.domain.DatasetNode)

Example 65 with Dataset

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

the class ExporterAssociationsBase method addStudyInfo.

protected void addStudyInfo(StudyNode study, Map<String, String> properties) {
    final Dataset originatingDataset = study.getOriginatingDataset();
    properties.put(EOLDictionary.SOURCE, originatingDataset == null ? study.getCitation() : originatingDataset.getCitation());
    properties.put(EOLDictionary.REFERENCE_ID, "globi:ref:" + study.getNodeID());
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset)

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