use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class LinkerTrustyNanoPubsTest method link.
@Test
public void link() throws NodeFactoryException, OpenRDFException, IOException, MalformedNanopubException, TrustyUriException {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com/dataset"));
populateDataset(dataset);
LinkerTrustyNanoPubs linker = new LinkerTrustyNanoPubs(getGraphDb());
linker.link();
Index<Node> nanopubs = getGraphDb().index().forNodes("nanopubs");
IndexHits<Node> hits = nanopubs.query("code:\"RA7XQvcOGTux6HTndtjAiVWXjEMZbQMH4yJIxTMCV8sx4\"");
assertThat(hits.hasNext(), is(true));
Node nanopubRef = hits.next();
assertThat(nanopubRef.getProperty("code"), is("RA7XQvcOGTux6HTndtjAiVWXjEMZbQMH4yJIxTMCV8sx4"));
Iterable<Relationship> rels = nanopubRef.getRelationships(NodeUtil.asNeo4j(RelTypes.SUPPORTS), Direction.INCOMING);
assertThat(rels.iterator().hasNext(), is(true));
Relationship rel = rels.iterator().next();
Iterable<Relationship> participants = rel.getStartNode().getRelationships(NodeUtil.asNeo4j(RelTypes.HAS_PARTICIPANT), Direction.OUTGOING);
Iterator<Relationship> iter = participants.iterator();
assertTrue(iter.hasNext());
iter.next();
assertTrue(iter.hasNext());
iter.next();
assertFalse(iter.hasNext());
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class LinkerTrustyNanoPubsTest method writingNanopub.
@Test
public void writingNanopub() throws NodeFactoryException, OpenRDFException, IOException, MalformedNanopubException, TrustyUriException {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com/dataset"));
NodeFactoryWithDatasetContext factory = populateDataset(dataset);
LinkerTrustyNanoPubs linker = new LinkerTrustyNanoPubs(getGraphDb());
linker.link();
DatasetNode datasetNode = (DatasetNode) factory.getOrCreateDataset(dataset);
Iterable<Relationship> rels = datasetNode.getUnderlyingNode().getRelationships(NodeUtil.asNeo4j(RelTypes.ACCESSED_AT), Direction.INCOMING);
InteractionNode interactionNode = new InteractionNode(rels.iterator().next().getStartNode());
String nanoPubText = LinkerTrustyNanoPubs.writeNanoPub(datasetNode, interactionNode);
InputStream rdfIn = IOUtils.toInputStream(nanoPubText);
String rdfActual = toTrigString(rdfIn);
String rdfExpected = toTrigString(getClass().getResourceAsStream("nanopub.trig"));
assertThat(rdfActual, is(rdfExpected));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForMetaTableIT method parseNaturalHistoryMuseum.
@Test
public void parseNaturalHistoryMuseum() throws IOException, StudyImporterException {
final Class<StudyImporterForMetaTable> clazz = StudyImporterForMetaTable.class;
final String name = "test-meta-globi-nhm.json";
final URL resource = clazz.getResource(name);
Assert.assertNotNull(resource);
final JsonNode config = new ObjectMapper().readTree(clazz.getResourceAsStream(name));
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
dataset.setConfig(config);
final List<JsonNode> tables = StudyImporterForMetaTable.collectTables(dataset);
assertThat(tables.size(), is(1));
JsonNode firstTable = tables.get(0);
String bibliographicCitation = firstTable.get("dcterms:bibliographicCitation").asText();
assertThat(bibliographicCitation, containsString("NHM Interactions Bank. http://dx.doi.org/10.5519/0060767"));
String resourceUrl = firstTable.get("url").asText();
// see https://github.com/jhpoelen/eol-globi-data/issues/266
// assertThat(resourceUrl, is("http://data.nhm.ac.uk/dataset/82e807f0-6273-4f19-be0a-7f7558442a25/resource/1f64e2cf-d738-4a7c-9e81-a1951eac635f/download/output.csv"));
assertThat(firstTable.get("headerRowCount").asInt(), is(1));
assertThat(firstTable.has("tableSchema"), is(true));
assertThat(firstTable.has("null"), is(true));
assertThat(firstTable.get("tableSchema").has("columns"), is(true));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method datasetWithNamespace.
private DatasetImpl datasetWithNamespace(String namespace) {
DatasetImpl dataset = new DatasetImpl(namespace, URI.create("some:uri"));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
dataset.setConfig(objectNode);
return dataset;
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method addDatasetToStudyNulls2.
@Test
public void addDatasetToStudyNulls2() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("my title", "some source", "some doi", "some citation");
DatasetImpl dataset = new DatasetImpl("some/namespace", null);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
Node datasetNode = NodeUtil.getDataSetForStudy(study);
assertThat(datasetNode.getProperty(DatasetConstant.NAMESPACE), is("some/namespace"));
assertThat(datasetNode.hasProperty(DatasetConstant.ARCHIVE_URI), is(false));
assertThat(datasetNode.getProperty(DatasetConstant.SHOULD_RESOLVE_REFERENCES), is("true"));
}
Aggregations