Package org.openrdf.query.parser

Examples of org.openrdf.query.parser.ParsedTupleQuery


                  Projection projection = new Projection(group, projectionElements);
                  Order order = "value".equals(_sortMode) ?
                      new Order(projection, new OrderElem(_valueVar, "forward".equals(_sortDirection))) :
                      new Order(projection, new OrderElem(_countVar, !"forward".equals(_sortDirection)));
                 
                  TupleQuery query = new MyTupleQuery(new ParsedTupleQuery(order), connection);
                  TupleQueryResult queryResult = query.evaluate();
                  try {
                    return createComponentState(queryResult);
                  } finally {
                      queryResult.close();
View Full Code Here


        return makeTupleQuery(new ProjectionElemList(new ProjectionElem(var.getName())), connection);
    }
   
    public TupleQuery makeTupleQuery(ProjectionElemList projectionElements, SailRepositoryConnection connection) {
        return new MyTupleQuery(
            new ParsedTupleQuery(makeProjection(projectionElements)),
            connection
        );
    }
View Full Code Here

              // TODO[dfhuynh]: This happens if the expression is just "value". I'm not sure what to do here.
              return null;
            }
           
            Projection projection = new Projection(t, projectionElements);
            TupleQuery query = new MyTupleQuery(new ParsedTupleQuery(projection), connection);
           
            return new ExpressionQueryResult(query, expressionResult.valueType, resultVar);
        }
        return null;
    }
View Full Code Here

  }

  public SailTupleQuery prepareTupleQuery(QueryLanguage ql, String queryString, String baseURI)
    throws MalformedQueryException
  {
    ParsedTupleQuery parsedQuery = QueryParserUtil.parseTupleQuery(ql, queryString, baseURI);
    return new SailTupleQuery(parsedQuery, this);
  }
View Full Code Here

    SailConnection con = store.getConnection();
    con.addStatement(foo, RDF.TYPE, bar);
    con.commit();

    ParsedTupleQuery query = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "SELECT X, P, Y FROM {X} P {Y}", null);
    TupleExpr tupleExpr = query.getTupleExpr();

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter = con.evaluate(tupleExpr, null,
        EmptyBindingSet.getInstance(), false);

    BindingSet bindingSet = iter.next();
View Full Code Here

      ParsedQuery query;

      ASTQuery queryNode = qc.getQuery();
      if (queryNode instanceof ASTSelectQuery) {
        query = new ParsedTupleQuery(tupleExpr);
      }
      else if (queryNode instanceof ASTConstructQuery) {
        query = new ParsedGraphQuery(tupleExpr, prefixes);
      }
      else if (queryNode instanceof ASTAskQuery) {
View Full Code Here

      TupleExpr tupleExpr = QueryModelBuilder.buildQueryModel(qc, new ValueFactoryImpl());

      ASTQuery queryNode = qc.getQuery();
      ParsedQuery query;
      if (queryNode instanceof ASTTupleQuery) {
        query = new ParsedTupleQuery(tupleExpr);
      }
      else if (queryNode instanceof ASTGraphQuery) {
        query = new ParsedGraphQuery(tupleExpr, namespaces);
      }
      else {
View Full Code Here

    }
    finally {
      stIter.close();
    }

    ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "SELECT S, P, O FROM {S} P {O} WHERE P = <" + pred.stringValue() + ">", null);

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter;
    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    try {
      assertTrue(iter.hasNext());

      BindingSet bindings = iter.next();
View Full Code Here

    con.addStatement(picasso, RDF.TYPE, painter);
    con.addStatement(guernica, RDF.TYPE, painting);
    con.addStatement(picasso, paints, guernica);
    con.commit();

    ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "SELECT C FROM {} rdf:type {C}", null);

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter;
    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    while (iter.hasNext()) {
      BindingSet bindings = iter.next();
      Value c = bindings.getValue("C");
      if (c instanceof Resource) {
        con.addStatement((Resource)c, RDF.TYPE, RDFS.CLASS);
      }
    }

    con.commit();

    // Simulate auto-commit

    assertEquals(3, countElements(con.getStatements(null, RDF.TYPE, RDFS.CLASS, false)));

    tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL, "SELECT P FROM {} P {}", null);
    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    while (iter.hasNext()) {
      BindingSet bindings = iter.next();
      Value p = bindings.getValue("P");
      if (p instanceof URI) {
View Full Code Here

    con.addStatement(picasso, RDF.TYPE, painter, context1);
    con.addStatement(guernica, RDF.TYPE, painting, context1);
    con.addStatement(picasso, paints, guernica, context1);
    con.commit();

    ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "select X from {X} rdf:type {Y} rdf:type {rdfs:Class}", null);
    TupleExpr tupleExpr = tupleQuery.getTupleExpr();

    MapBindingSet bindings = new MapBindingSet(1);

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter;
    iter = con.evaluate(tupleExpr, null, bindings, false);
View Full Code Here

TOP

Related Classes of org.openrdf.query.parser.ParsedTupleQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.