use of org.eol.globi.util.NodeTypeDirection in project eol-globi-data by jhpoelen.
the class ExporterOccurrences method doExportStudy.
@Override
public void doExportStudy(StudyNode study, ExportUtil.Appender writer, boolean includeHeader) throws IOException {
final List<IOException> first10Exceptions = new ArrayList<>();
NodeUtil.handleCollectedRelationships(new NodeTypeDirection(study.getUnderlyingNode()), collectedRel -> {
Node specimenNode = collectedRel.getEndNode();
if (isSpecimenClassified(specimenNode)) {
try {
handleSpecimen(study, writer, collectedRel, specimenNode);
} catch (IOException e) {
if (first10Exceptions.size() < 10) {
first10Exceptions.add(e);
}
}
}
});
if (first10Exceptions.size() > 0) {
throw first10Exceptions.get(0);
}
}
use of org.eol.globi.util.NodeTypeDirection 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.NodeTypeDirection 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();
}
}
use of org.eol.globi.util.NodeTypeDirection in project eol-globi-data by jhpoelen.
the class ExporterSiteMapForNames method export.
@Override
public void export(GraphDatabaseService graphDatabase, File baseDir) throws StudyImporterException {
Set<String> names = new HashSet<String>();
names.add("Homo sapiens");
NodeUtil.findStudies(graphDatabase, node -> NodeUtil.handleCollectedRelationships(new NodeTypeDirection(new StudyNode(node).getUnderlyingNode()), specimen -> {
final Iterable<Relationship> relationships = specimen.getEndNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
if (relationships.iterator().hasNext()) {
final Node endNode = relationships.iterator().next().getEndNode();
final TaxonNode taxonNode = new TaxonNode(endNode);
names.add(taxonNode.getName());
}
}));
final String queryParamName = "interactionType=interactsWith&sourceTaxon=";
final String siteMapLocation = "https://depot.globalbioticinteractions.org/snapshot/target/data/sitemap/names/";
SiteMapUtils.generateSiteMap(names, baseDir, queryParamName, siteMapLocation);
}
Aggregations