use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class NodeUtil method findStudies.
public static void findStudies(GraphDatabaseService graphService, StudyNodeListener listener) {
Index<Node> studyIndex = graphService.index().forNodes("studies");
IndexHits<Node> hits = studyIndex.query("title", "*");
for (Node hit : hits) {
listener.onStudy(new StudyNode(hit));
}
hits.close();
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class ExporterOccurrences method addOccurrenceProperties.
private void addOccurrenceProperties(Node locationNode, Relationship collectedRelationship, Map<String, String> properties, Node specimenNode, Study study) throws IOException {
if (specimenNode != null) {
Iterable<Relationship> relationships = specimenNode.getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
Iterator<Relationship> iterator = relationships.iterator();
if (iterator.hasNext()) {
Relationship classifiedAs = iterator.next();
if (classifiedAs != null) {
Node taxonNode = classifiedAs.getEndNode();
if (taxonNode.hasProperty(PropertyAndValueDictionary.EXTERNAL_ID)) {
String taxonId = (String) taxonNode.getProperty(PropertyAndValueDictionary.EXTERNAL_ID);
if (taxonId != null) {
properties.put(EOLDictionary.TAXON_ID, taxonId);
}
}
if (taxonNode.hasProperty(PropertyAndValueDictionary.NAME)) {
String taxonName = (String) taxonNode.getProperty(PropertyAndValueDictionary.NAME);
if (taxonName != null) {
properties.put(EOLDictionary.SCIENTIFIC_NAME, taxonName);
}
}
}
}
}
properties.put(EOLDictionary.OCCURRENCE_ID, "globi:occur:" + specimenNode.getId());
addProperty(properties, specimenNode, SpecimenConstant.BASIS_OF_RECORD_LABEL, EOLDictionary.BASIS_OF_RECORD);
addProperty(properties, specimenNode, SpecimenConstant.LIFE_STAGE_LABEL, EOLDictionary.LIFE_STAGE);
addProperty(properties, specimenNode, SpecimenConstant.PHYSIOLOGICAL_STATE_LABEL, EOLDictionary.PHYSIOLOGICAL_STATE);
addProperty(properties, specimenNode, SpecimenConstant.BODY_PART_LABEL, EOLDictionary.BODY_PART);
addProperty(properties, locationNode, LocationConstant.LATITUDE, EOLDictionary.DECIMAL_LATITUDE);
addProperty(properties, locationNode, LocationConstant.LONGITUDE, EOLDictionary.DECIMAL_LONGITUDE);
if (locationNode != null && locationNode.hasProperty(LocationConstant.ALTITUDE)) {
properties.put(EOLDictionary.VERBATIM_ELEVATION, locationNode.getProperty(LocationConstant.ALTITUDE).toString() + " m");
}
addProperty(properties, ((StudyNode) study).getUnderlyingNode(), StudyConstant.TITLE, EOLDictionary.EVENT_ID);
addCollectionDate(properties, collectedRelationship, EOLDictionary.EVENT_DATE);
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class ExporterAggregateUtil method exportDistinctInteractionsByStudy.
public static void exportDistinctInteractionsByStudy(Writer writer, GraphDatabaseService graphDatabase, RowWriter rowWriter) throws IOException {
DB db = DBMaker.newMemoryDirectDB().compressionEnable().transactionDisable().make();
final Map<Fun.Tuple3<Long, String, String>, List<String>> studyOccAggregate = db.createTreeMap("studyOccAggregate").make();
NodeUtil.findStudies(graphDatabase, new StudyNodeListener() {
@Override
public void onStudy(StudyNode aStudy) {
collectDistinctInteractions(aStudy, studyOccAggregate);
}
});
for (Map.Entry<Fun.Tuple3<Long, String, String>, List<String>> distinctInteractions : studyOccAggregate.entrySet()) {
rowWriter.writeRow(writer, new StudyNode(graphDatabase.getNodeById(distinctInteractions.getKey().a)), distinctInteractions.getKey().b, distinctInteractions.getKey().c, distinctInteractions.getValue());
}
db.close();
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationWithURL.
@Test
public void createStudyDOIlookupCitationWithURL() throws NodeFactoryException {
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("title", "some source", null, "http://bla"));
new LinkerDOI(getGraphDb()).linkStudy(new DOIResolverThatFails(), study);
assertThat(study.getSource(), is("some source"));
assertThat(study.getCitation(), is("http://bla"));
assertThat(study.getTitle(), is("title"));
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationEnabled.
@Test
public void createStudyDOIlookupCitationEnabled() throws NodeFactoryException {
StudyImpl title = new StudyImpl("title", "some source", null, "some citation");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, true);
originatingDataset.setConfig(objectNode);
title.setOriginatingDataset(originatingDataset);
StudyNode study = getNodeFactory().getOrCreateStudy(title);
new LinkerDOI(getGraphDb()).linkStudy(new TestDOIResolver(), study);
assertThat(study.getSource(), is("some source"));
assertThat(study.getDOI(), is("doi:some citation"));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
}
Aggregations