use of org.apache.jena.sparql.graph.GraphUnionRead 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);
}
use of org.apache.jena.sparql.graph.GraphUnionRead in project jena by apache.
the class TestGraphUnionRead method gr_union_02.
@Test
public void gr_union_02() {
List<Node> gnodes = list(gn1, gn2);
Graph g = new GraphUnionRead(dsg, gnodes);
Node s = NodeFactory.createURI("http://example/s");
long x = Iter.count(g.find(s, null, null));
assertEquals(3, x);
}
use of org.apache.jena.sparql.graph.GraphUnionRead in project jena by apache.
the class DynamicDatasets method dynamicDataset.
/** Given a DatasetGraph and a query, form a DatasetGraph that
* is the dynamic dataset from the collection of graphs from the dataset
* that go to make up the default graph (union) and named graphs.
*/
public static DatasetGraph dynamicDataset(Collection<Node> defaultGraphs, Collection<Node> namedGraphs, DatasetGraph dsg, boolean defaultUnionGraph) {
Graph dft = new GraphUnionRead(dsg, defaultGraphs);
DatasetGraph dsg2 = new DatasetGraphMapLink(dft);
// The named graphs.
for (Node gn : namedGraphs) {
Graph g = GraphOps.getGraph(dsg, gn);
if (g != null)
dsg2.addGraph(gn, g);
}
if (dsg.getContext() != null)
dsg2.getContext().putAll(dsg.getContext());
if (defaultUnionGraph && defaultGraphs.size() == 0) {
// Create a union graph - there were no defaultGraphs explicitly named.
Graph unionGraph = new GraphUnionRead(dsg, namedGraphs);
dsg2.setDefaultGraph(unionGraph);
}
// read-only, <urn:x-arq:DefaultGraph> and <urn:x-arq:UnionGraph> processing.
dsg2 = new DynamicDatasetGraph(dsg2);
// Record what we've done.
// c.f. "ARQConstants.sysDatasetDescription" which is used to pass in a DatasetDescription
dsg2.getContext().set(ARQConstants.symDatasetDefaultGraphs, defaultGraphs);
dsg2.getContext().set(ARQConstants.symDatasetNamedGraphs, namedGraphs);
return dsg2;
}
use of org.apache.jena.sparql.graph.GraphUnionRead in project jena by apache.
the class TestGraphUnionRead method gr_union_06.
@Test
public void gr_union_06() {
List<Node> gnodes = list(gn1, gn1);
Graph g = new GraphUnionRead(dsg, gnodes);
long x = Iter.count(g.find(null, null, null));
assertEquals(2, x);
}
use of org.apache.jena.sparql.graph.GraphUnionRead in project jena by apache.
the class TestGraphUnionRead method gr_union_03.
@Test
public void gr_union_03() {
List<Node> gnodes = list(gn1, gn2, gn9);
Graph g = new GraphUnionRead(dsg, gnodes);
Node o = NodeFactory.createLiteral("g2");
long x = Iter.count(g.find(null, null, o));
assertEquals(1, x);
}
Aggregations