use of org.eol.globi.util.RelationshipListener in project eol-globi-data by jhpoelen.
the class ExporterRDF method exportStudy.
@Override
public void exportStudy(StudyNode study, ExportUtil.Appender appender, boolean includeHeader) throws IOException {
AtomicReference<IOException> lastException = new AtomicReference<>();
RelationshipListener handler = relationship -> {
try {
Node agentNode = relationship.getEndNode();
for (Relationship ixnR : agentNode.getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j())) {
writeStatement(appender, Arrays.asList(blankNode(ixnR), iriNode(HAS_TYPE), iriNode(INTERACTION)));
writeParticipantStatements(appender, ixnR, ixnR.getEndNode());
writeParticipantStatements(appender, ixnR, agentNode);
writeStatement(appender, Arrays.asList(blankNode(agentNode), iriNode(InteractType.valueOf(ixnR.getType().name()).getIRI()), blankNode(ixnR.getEndNode())));
}
} catch (IOException ex) {
lastException.set(ex);
}
};
NodeUtil.handleCollectedRelationships(new NodeTypeDirection(study.getUnderlyingNode()), handler);
if (lastException.get() != null) {
throw lastException.get();
}
}
use of org.eol.globi.util.RelationshipListener in project eol-globi-data by jhpoelen.
the class ExporterAssociations method doExportStudy.
@Override
public void doExportStudy(StudyNode study, ExportUtil.Appender writer, boolean includeHeader) throws IOException {
Map<String, String> properties = new TreeMap<String, String>();
AtomicReference<IOException> lastException = new AtomicReference<>();
RelationshipListener handler = collectedRel -> {
Node specimenNode = collectedRel.getEndNode();
if (isSpecimenClassified(specimenNode)) {
try {
handleSpecimen(study, writer, properties, specimenNode);
} catch (IOException ex) {
lastException.set(ex);
}
}
};
NodeUtil.handleCollectedRelationships(new NodeTypeDirection(study.getUnderlyingNode()), handler);
if (lastException.get() != null) {
throw lastException.get();
}
}
Aggregations