Search in sources :

Example 71 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestOpAsQuery method roundTripQuery.

// query->algebra->OpAsQuery->query
private static Query[] roundTripQuery(String query) {
    Query orig = QueryFactory.create(query, Syntax.syntaxSPARQL_11);
    Op toReconstruct = Algebra.compile(orig);
    Query got = OpAsQuery.asQuery(toReconstruct);
    Query[] r = { orig, got };
    return r;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 72 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestOpAsQuery method roundTripQueryQuad.

// query->algebra/quads->OpAsQuery->query
private static Query[] roundTripQueryQuad(String query) {
    Query orig = QueryFactory.create(query, Syntax.syntaxSPARQL_11);
    Op toReconstruct = Algebra.compile(orig);
    toReconstruct = Algebra.toQuadForm(toReconstruct);
    Query got = OpAsQuery.asQuery(toReconstruct);
    Query[] r = { orig, got };
    return r;
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 73 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestOpAsQuery method test_AlgebraToQuery.

// algebra->OpAsQuery->query
public static void test_AlgebraToQuery(String input, String expected) {
    Op op = SSE.parseOp(input);
    Query orig = QueryFactory.create(expected, Syntax.syntaxSPARQL_11);
    stripNamespacesAndBase(orig);
    Query got = OpAsQuery.asQuery(op);
    Assert.assertEquals(orig, got);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 74 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestPattern2Join method test3.

private static void test3(String pattern, String... joinForm) {
    Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * " + pattern);
    Op op = Algebra.compile(q.getQueryPattern());
    test(op, joinForm);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Example 75 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestClassify method classifyJ.

public static void classifyJ(String pattern, boolean expected) {
    String qs1 = "PREFIX : <http://example/>\n";
    String qs = qs1 + "SELECT * " + pattern;
    Query query = QueryFactory.create(qs, Syntax.syntaxARQ);
    Op op = Algebra.compile(query.getQueryPattern());
    if (!(op instanceof OpJoin))
        fail("Not a join: " + pattern);
    boolean nonLinear = JoinClassifier.isLinear((OpJoin) op);
    assertEquals("Join: " + pattern, expected, nonLinear);
}
Also used : Query(org.apache.jena.query.Query) OpJoin(org.apache.jena.sparql.algebra.op.OpJoin)

Aggregations

Query (org.apache.jena.query.Query)106 Test (org.junit.Test)22 Op (org.apache.jena.sparql.algebra.Op)17 QueryExecution (org.apache.jena.query.QueryExecution)13 ResultSet (org.apache.jena.query.ResultSet)11 Var (org.apache.jena.sparql.core.Var)11 HashMap (java.util.HashMap)9 QuerySolution (org.apache.jena.query.QuerySolution)9 ContractTest (org.xenei.junit.contract.ContractTest)9 Node (org.apache.jena.graph.Node)8 WhereHandler (org.apache.jena.arq.querybuilder.handlers.WhereHandler)7 VarExprList (org.apache.jena.sparql.core.VarExprList)7 Element (org.apache.jena.sparql.syntax.Element)7 Triple (org.apache.jena.graph.Triple)6 Before (org.junit.Before)6 Map (java.util.Map)5 QueryEngineHTTP (org.apache.jena.sparql.engine.http.QueryEngineHTTP)5 Context (org.apache.jena.sparql.util.Context)5 StringReader (java.io.StringReader)4 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)4