use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j method createStudy.
@Override
public StudyNode createStudy(Study study) {
Transaction transaction = graphDb.beginTx();
StudyNode studyNode;
try {
Node node = graphDb.createNode();
studyNode = new StudyNode(node, study.getTitle());
studyNode.setSource(study.getSource());
studyNode.setCitation(study.getCitation());
studyNode.setDOI(study.getDOI());
if (StringUtils.isBlank(study.getExternalId()) && StringUtils.isNotBlank(study.getDOI())) {
studyNode.setExternalId(ExternalIdUtil.urlForExternalId(study.getDOI()));
} else {
studyNode.setExternalId(study.getExternalId());
}
studyNode.setSourceId(study.getSourceId());
Dataset dataset = getOrCreateDatasetNoTx(study.getOriginatingDataset());
if (dataset != null && dataset instanceof DatasetNode) {
studyNode.createRelationshipTo(dataset, RelTypes.IN_DATASET);
}
studies.add(node, StudyConstant.TITLE, study.getTitle());
studies.add(node, StudyConstant.TITLE_IN_NAMESPACE, getTitleInNamespace(study));
transaction.success();
} finally {
transaction.finish();
}
return studyNode;
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j method getOrCreateDatasetNoTx.
private Dataset getOrCreateDatasetNoTx(Dataset originatingDataset) {
Dataset datasetCreated = null;
if (originatingDataset != null && StringUtils.isNotBlank(originatingDataset.getNamespace())) {
IndexHits<Node> datasetHits = datasets.get(DatasetConstant.NAMESPACE, originatingDataset.getNamespace());
Node datasetNode = datasetHits.hasNext() ? datasetHits.next() : createDatasetNode(originatingDataset);
datasetCreated = new DatasetNode(datasetNode);
}
return datasetCreated;
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j method createInteraction.
@Override
public Interaction createInteraction(Study study) throws NodeFactoryException {
Transaction transaction = graphDb.beginTx();
InteractionNode interactionNode;
try {
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 != null && dataset instanceof DatasetNode) {
interactionNode.createRelationshipTo(dataset, RelTypes.ACCESSED_AT);
}
transaction.success();
} finally {
transaction.finish();
}
return interactionNode;
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class DatasetFinderLocalTest method init.
@Before
public void init() throws URISyntaxException {
URL accessFile = getClass().getResource("/test-cache/globalbioticinteractions/template-dataset/access.tsv");
assertNotNull(accessFile);
File cacheDir = new File(accessFile.toURI()).getParentFile().getParentFile().getParentFile();
datasetFinderLocal = new DatasetFinderLocal(cacheDir.getAbsolutePath(), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), cacheDir.getAbsolutePath()));
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class DatasetFinderLocalTest method dataset.
@Test
public void dataset() throws DatasetFinderException, URISyntaxException {
Dataset actual = datasetFinderLocal.datasetFor("globalbioticinteractions/template-dataset");
assertThat(actual, is(notNullValue()));
assertThat(actual.getConfigURI().toString(), endsWith("/test-cache/globalbioticinteractions/template-dataset/6bfc17b8717e6e8e478552f12404bc8887d691a155ffd9cd9bfc80cb6747c5d2!/template-dataset-8abd2ba18457288f33527193299504015fae6def/globi.json"));
assertThat(actual.getArchiveURI().toString(), is("https://github.com/globalbioticinteractions/template-dataset/archive/8abd2ba18457288f33527193299504015fae6def.zip"));
assertThat(actual.getCitation(), is("Jorrit H. Poelen. 2014. Species associations manually extracted from literature. Accessed on 2017-09-14T16:45:38Z via <https://github.com/globalbioticinteractions/template-dataset/archive/8abd2ba18457288f33527193299504015fae6def.zip>."));
}
Aggregations