use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method createStudyWithSameExternalIdInDifferentNamespace.
@Test
public void createStudyWithSameExternalIdInDifferentNamespace() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study1.setOriginatingDataset(new DatasetImpl("name/space", URI.create("foo:bar"), is -> is));
study1.setExternalId("foo:bar");
StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
StudyImpl study2 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study2.setOriginatingDataset(new DatasetImpl("name/spacz", URI.create("foo:bar"), is -> is));
study2.setExternalId("foo:bar");
StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
assertThat(study1Created.getExternalId(), is("foo:bar"));
assertThat(study1Created.getOriginatingDataset().getNamespace(), is("name/space"));
assertThat(study2Created.getExternalId(), is("foo:bar"));
assertThat(study2Created.getOriginatingDataset().getNamespace(), is("name/spacz"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method addDatasetToStudyNulls.
@Test
public void addDatasetToStudyNulls() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("my title", SOME_DOI, "some citation");
DatasetImpl dataset = new DatasetImpl(null, null, inStream -> inStream);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
assertThat(NodeUtil.getDataSetForStudy(study), is(nullValue()));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method addDatasetToStudy.
@Test
public void addDatasetToStudy() throws NodeFactoryException, IOException {
StudyImpl study1 = new StudyImpl("my title", SOME_DOI, "some citation");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
dataset.setConfig(objectNode);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
Dataset origDataset = study.getOriginatingDataset();
assertThat(origDataset, is(notNullValue()));
assertThat(origDataset.getArchiveURI().toString(), is("some:uri"));
assertThat(origDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"), is("false"));
String expectedConfig = new ObjectMapper().writeValueAsString(objectNode);
assertThat(new ObjectMapper().writeValueAsString(origDataset.getConfig()), is(expectedConfig));
Node datasetNode = NodeUtil.getDataSetForStudy(study);
assertThat(datasetNode.getProperty(DatasetConstant.NAMESPACE), is("some/namespace"));
assertThat(datasetNode.getProperty("archiveURI"), is("some:uri"));
assertThat(datasetNode.getProperty(DatasetConstant.SHOULD_RESOLVE_REFERENCES), is("false"));
StudyImpl otherStudy = new StudyImpl("my other title", SOME_DOI, "some citation");
otherStudy.setOriginatingDataset(dataset);
StudyNode studySameDataset = getNodeFactory().getOrCreateStudy(otherStudy);
Node datasetNodeOther = NodeUtil.getDataSetForStudy(studySameDataset);
assertThat(datasetNode.getId(), is(datasetNodeOther.getId()));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method createStudyWithDifferentExternalIdInSameNamespace.
@Test
public void createStudyWithDifferentExternalIdInSameNamespace() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study1.setOriginatingDataset(new DatasetImpl("name/space", URI.create("foo:bar"), is -> is));
study1.setExternalId("foo:bar");
StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
StudyImpl study2 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
study2.setOriginatingDataset(new DatasetImpl("name/space", URI.create("foo:bar"), is -> is));
study2.setExternalId("foo:baz");
StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
assertThat(study1Created.getExternalId(), is("foo:bar"));
assertThat(study2Created.getExternalId(), is("foo:baz"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method assertDataset.
protected void assertDataset(String citationKey) {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
objectNode.put(citationKey, "some citation");
dataset.setConfig(objectNode);
Dataset origDataset = getNodeFactory().getOrCreateDataset(dataset);
assertThat(origDataset, is(notNullValue()));
assertThat(origDataset.getArchiveURI().toString(), is("some:uri"));
assertThat(origDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"), is("false"));
assertThat(origDataset.getOrDefault(DatasetConstant.CITATION, "no citation"), is("some citation"));
assertThat(origDataset.getCitation(), is("some citation"));
assertThat(origDataset.getOrDefault(DatasetConstant.LAST_SEEN_AT, "1"), is(not("1")));
Dataset datasetAnother = getNodeFactory().getOrCreateDataset(dataset);
assertThat(((DatasetNode) datasetAnother).getNodeID(), is(((DatasetNode) origDataset).getNodeID()));
}
Aggregations