use of org.apache.jena.util.iterator.ExtendedIterator in project jena by apache.
the class ShapesParser method accTarget.
private static void accTarget(Collection<Target> acc, Graph shapesGraph, Node shape, TargetType targetType) {
ExtendedIterator<Triple> iter = shapesGraph.find(shape, targetType.predicate, null);
Graph graph;
switch(targetType) {
// Java 14 has "->"
case targetExtension:
graph = shapesGraph;
break;
// These do not need access to the shapes graph so don't force holding on the the graph reference.
case implicitClass:
case targetClass:
case targetNode:
case targetObjectsOf:
case targetSubjectsOf:
default:
graph = null;
break;
}
try {
iter.mapWith(triple -> Target.create(triple.getSubject(), targetType, triple.getObject(), graph)).forEachRemaining(target -> acc.add(target));
} finally {
iter.close();
}
}
use of org.apache.jena.util.iterator.ExtendedIterator in project jena by apache.
the class GenericPropertyFunction method bothUnbound.
private QueryIterator bothUnbound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
Var subjectVar = Var.alloc(subject.getName());
Graph graph = execCxt.getActiveGraph();
// Search for both Features and Geometry in the Graph. Reliant upon consistent usage of SpatialObject (which is base class of Feature and Geometry) if present.
ExtendedIterator<Triple> subjectTriples;
if (graph.contains(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
subjectTriples = graph.find(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE);
} else if (graph.contains(null, RDF.type.asNode(), Geo.FEATURE_NODE) || graph.contains(null, RDF.type.asNode(), Geo.GEOMETRY_NODE)) {
ExtendedIterator<Triple> featureTriples = graph.find(null, RDF.type.asNode(), Geo.FEATURE_NODE);
ExtendedIterator<Triple> geometryTriples = graph.find(null, RDF.type.asNode(), Geo.GEOMETRY_NODE);
subjectTriples = featureTriples.andThen(geometryTriples);
} else {
// Check for Geo Predicate Features in the Graph if no GeometryLiterals found.
subjectTriples = graph.find(null, SpatialExtension.GEO_LAT_NODE, null);
}
// Bind all the Spatial Objects or Geo Predicates once as the subject and search for corresponding Objects.
while (subjectTriples.hasNext()) {
Triple subjectTriple = subjectTriples.next();
Node boundSubject = subjectTriple.getSubject();
Binding subjectBind = BindingFactory.binding(binding, subjectVar, boundSubject);
QueryIterator queryIter = oneBound(subjectBind, boundSubject, predicate, object, execCxt);
queryIterConcat.add(queryIter);
}
return queryIterConcat;
}
Aggregations