use of org.eol.globi.service.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 source", "some doi", "some citation");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
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 source", "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.eol.globi.service.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 source", "some doi", "some citation");
DatasetImpl dataset = new DatasetImpl(null, null);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
assertThat(NodeUtil.getDataSetForStudy(study), is(nullValue()));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method assertDataset.
private void assertDataset(String citationKey) {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
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.getOrDefault(DatasetConstant.LAST_SEEN_AT, "1"), is(not("1")));
Dataset datasetAnother = getNodeFactory().getOrCreateDataset(dataset);
assertThat(((DatasetNode) datasetAnother).getNodeID(), is(((DatasetNode) origDataset).getNodeID()));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForSaproxylicIntegrationTest method importAll.
@Test
public void importAll() throws StudyImporterException {
StudyImporter importer = new StudyImporterTestFactory(nodeFactory).instantiateImporter(StudyImporterForSaproxylic.class);
importer.setDataset(new DatasetImpl("some/test", URI.create("classpath:/org/eol/globi/data/saproxylic")));
importStudy(importer);
assertNotNull(taxonIndex.findTaxonByName("Fagus sylvatica"));
assertNotNull(taxonIndex.findTaxonByName("Epuraea variegata"));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForSeltmannIT method importArchive.
protected void importArchive(String archiveName) throws StudyImporterException {
StudyImporterForSeltmann importer = new StudyImporterForSeltmann(null, nodeFactory);
importer.setDataset(new DatasetImpl(null, URI.create(ARCHIVE_URI_PREFIX + archiveName)));
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
for (Study allStudy : allStudies) {
assertThat(allStudy.getSource(), startsWith("Digital Bee Collections Network, 2014 (and updates). Version: 2015-03-18. National Science Foundation grant DBI 0956388"));
assertThat(allStudy.getCitation(), is("Digital Bee Collections Network, 2014 (and updates). Version: 2015-03-18. National Science Foundation grant DBI 0956388"));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(allStudy);
for (Relationship specimen : specimens) {
Specimen spec = new SpecimenNode(specimen.getEndNode());
Term basisOfRecord = spec.getBasisOfRecord();
assertThat(basisOfRecord.getId(), either(is("TEST:PreservedSpecimen")).or(is("TEST:LabelObservation")));
assertThat(basisOfRecord.getName(), either(is("PreservedSpecimen")).or(is("LabelObservation")));
}
}
assertThat(taxonIndex.findTaxonByName("Megandrena mentzeliae"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Mentzelia tricuspis"), is(notNullValue()));
}
Aggregations