Search in sources :

Example 1 with DescribeBuilder

use of org.apache.jena.arq.querybuilder.DescribeBuilder in project jena by apache.

the class WhereHandlerTest method testMakeSubQueryFromDescribe.

@Test
public void testMakeSubQueryFromDescribe() {
    AbstractQueryBuilder<?> sb = new DescribeBuilder().addWhere("?x", RDF.type, RDF.Alt);
    ElementSubQuery esq = handler.makeSubQuery(sb);
    Triple t1 = new Triple(NodeFactory.createVariable("x"), RDF.type.asNode(), RDF.Alt.asNode());
    TriplePath tp = new TriplePath(t1);
    ElementPathBlock epb = new ElementPathBlock();
    epb.addTriple(tp);
    Query q = new Query();
    q.setQuerySelectType();
    q.setQueryResultStar(true);
    q.setQueryPattern(epb);
    ElementSubQuery esq2 = new ElementSubQuery(q);
    WhereValidator wv = new WhereValidator(esq2);
    esq.visit(wv);
    assertTrue(wv.matching);
}
Also used : Triple(org.apache.jena.graph.Triple) ElementSubQuery(org.apache.jena.sparql.syntax.ElementSubQuery) DescribeBuilder(org.apache.jena.arq.querybuilder.DescribeBuilder) ElementSubQuery(org.apache.jena.sparql.syntax.ElementSubQuery) Query(org.apache.jena.query.Query) WhereValidator(org.apache.jena.arq.querybuilder.WhereValidator) TriplePath(org.apache.jena.sparql.core.TriplePath) ElementPathBlock(org.apache.jena.sparql.syntax.ElementPathBlock) Test(org.junit.Test)

Aggregations

DescribeBuilder (org.apache.jena.arq.querybuilder.DescribeBuilder)1 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)1 Triple (org.apache.jena.graph.Triple)1 Query (org.apache.jena.query.Query)1 TriplePath (org.apache.jena.sparql.core.TriplePath)1 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)1 ElementSubQuery (org.apache.jena.sparql.syntax.ElementSubQuery)1 Test (org.junit.Test)1