use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TestParserFactory method trig_01.
@Test
public void trig_01() {
String s = "{ <x> <p> <q> }";
CatchParserOutput sink = parseCapture(s, Lang.TRIG);
assertEquals(1, sink.startCalled);
assertEquals(1, sink.finishCalled);
assertEquals(0, sink.triples.size());
assertEquals(1, sink.quads.size());
Triple t = SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)");
Quad q = new Quad(Quad.tripleInQuad, t);
assertEquals(q, last(sink.quads));
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TestAPI method testARQConstructQuad_a_2.
// Test a)+2): Quads constructed in the default graph
@Test
public void testARQConstructQuad_a_2() {
String queryString = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }";
Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
QueryExecution qExec = QueryExecutionFactory.create(q, d);
Iterator<Quad> ts = qExec.execConstructQuads();
DatasetGraph result = DatasetGraphFactory.create();
long count = 0;
while (ts.hasNext()) {
count++;
result.add(ts.next());
}
DatasetGraph expected = DatasetGraphFactory.create();
expected.add(Quad.defaultGraphNodeGenerated, s.asNode(), p.asNode(), o.asNode());
assertEquals(1, count);
assertTrue(IsoMatcher.isomorphic(expected, result));
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TestAPI method testARQConstructQuad_b_2.
// Test b)+2)
@Test
public void testARQConstructQuad_b_2() {
String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH ?g1 {?s1 ?p1 'x1'} }";
Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
QueryExecution qExec = QueryExecutionFactory.create(q, d);
Iterator<Quad> ts = qExec.execConstructQuads();
DatasetGraph result = DatasetGraphFactory.create();
long count = 0;
while (ts.hasNext()) {
count++;
Quad qd = ts.next();
result.add(qd);
}
DatasetGraph expected = DatasetGraphFactory.create();
expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode());
assertEquals(1, count);
assertTrue(IsoMatcher.isomorphic(expected, result));
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TriGBlankNodeOutputTests method generateTuples.
@Override
protected Iterator<QuadWritable> generateTuples(int num) {
List<QuadWritable> qs = new ArrayList<QuadWritable>();
Node subject = NodeFactory.createBlankNode();
for (int i = 0; i < num; i++) {
Quad t = new Quad(NodeFactory.createURI("http://example.org/graphs/" + i), subject, NodeFactory.createURI("http://example.org/predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger));
qs.add(new QuadWritable(t));
}
return qs.iterator();
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class Template method getGraphPattern.
public Map<Node, BasicPattern> getGraphPattern() {
List<Quad> quads = getQuads();
HashMap<Node, BasicPattern> graphs = new HashMap<>();
for (Quad q : quads) {
BasicPattern bgp = graphs.get(q.getGraph());
if (bgp == null) {
bgp = new BasicPattern();
graphs.put(q.getGraph(), bgp);
}
bgp.add(q.asTriple());
}
return graphs;
}
Aggregations