use of org.apache.jena.graph.Graph in project jena by apache.
the class container method execEvaluatedConcrete.
// Ask directly.
private QueryIterator execEvaluatedConcrete(Binding binding, Node containerNode, Node predicate, Node member, ExecutionContext execCxt) {
QueryIterator input = QueryIterSingleton.create(binding, execCxt);
Graph graph = execCxt.getActiveGraph();
QueryIterator qIter = new QueryIterTriplePattern(input, new Triple(containerNode, predicate, member), execCxt);
return qIter;
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class container method execEvaluatedCalc.
// Ask by finding all the rdf:_N + rdf:type
private QueryIterator execEvaluatedCalc(Binding binding, Node containerNode, Node predicate, Node member, ExecutionContext execCxt) {
Graph graph = execCxt.getActiveGraph();
if (!containerNode.isVariable()) {
// Container a ground term.
if (!GraphContainerUtils.isContainer(execCxt.getActiveGraph(), containerNode, typeNode))
return IterLib.noResults(execCxt);
return oneContainer(binding, containerNode, member, execCxt);
}
// Container a variable.
Collection<Node> c = null;
if (member.isVariable())
c = findContainers(graph, typeNode);
else
c = findContainingContainers(graph, typeNode, member);
QueryIterConcat cIter = new QueryIterConcat(execCxt);
Var cVar = Var.alloc(containerNode);
for (Node cn : c) {
//Binding the container node.
Binding b = BindingFactory.binding(binding, cVar, cn);
Node m = member;
// Special case of ?x rdfs:member ?x
if (Var.isVar(member) && member.equals(cVar)) {
m = cn;
}
cIter.add(oneContainer(b, cn, m, execCxt));
}
return cIter;
//throw new QueryFatalException(Utils.className(this)+": Arg 1 is too hard : "+containerNode) ;
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class listIndex method execOneList.
@Override
protected QueryIterator execOneList(Binding binding, Node listNode, Node predicate, List<Node> objectArgs, ExecutionContext execCxt) {
if (Var.isVar(listNode))
throw new ExprEvalException("ListIndex : subject not a list or variable bound to a list");
if (objectArgs.size() != 2)
throw new ExprEvalException("ListIndex : object not a list of length 2");
Node indexNode = objectArgs.get(0);
Node memberNode = objectArgs.get(1);
Graph graph = execCxt.getActiveGraph();
if (Var.isVar(indexNode) && !Var.isVar(memberNode))
return findIndex(graph, binding, listNode, Var.alloc(indexNode), memberNode, execCxt);
if (!Var.isVar(indexNode) && Var.isVar(memberNode))
return getByIndex(graph, binding, listNode, indexNode, Var.alloc(memberNode), execCxt);
if (!Var.isVar(indexNode) && !Var.isVar(memberNode))
return testSlotValue(graph, binding, listNode, indexNode, memberNode, execCxt);
return findIndexMember(graph, binding, listNode, Var.alloc(indexNode), Var.alloc(memberNode), execCxt);
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestLangTurtle method parseOneTriple.
private static Triple parseOneTriple(String... strings) {
Graph graph = parse(strings);
assertEquals(1, graph.size());
return graph.find(null, null, null).next();
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestGraphUnionRead method gr_union_05.
@Test
public void gr_union_05() {
List<Node> gnodes = list();
Graph g = new GraphUnionRead(dsg, gnodes);
long x = Iter.count(g.find(null, null, null));
assertEquals(0, x);
}
Aggregations