Package org.openrdf.query.parser

Examples of org.openrdf.query.parser.GraphQueryModel


  }

  public SailGraphQuery prepareGraphQuery(QueryLanguage ql, String queryString, String baseURI)
    throws MalformedQueryException
  {
    GraphQueryModel parsedQuery = QueryParserUtil.parseGraphQuery(ql, queryString, baseURI);
    return new SailGraphQuery(parsedQuery, this);
  }
View Full Code Here


  }

  public GraphResult evaluate()
    throws StoreException
  {
    GraphQueryModel query = getParsedQuery();

    Cursor<? extends BindingSet> bindingsIter = evaluate(query);

    // Filters out all partial and invalid matches
    bindingsIter = new FilteringCursor<BindingSet>(bindingsIter) {

      @Override
      protected boolean accept(BindingSet bindingSet) {
        Value context = bindingSet.getValue("context");

        return bindingSet.getValue("subject") instanceof Resource
            && bindingSet.getValue("predicate") instanceof URI
            && bindingSet.getValue("object") instanceof Value
            && (context == null || context instanceof Resource);
      }

      @Override
      public String getName() {
        return "FilterOutPartialMatches";
      }
    };

    // Convert the BindingSet objects to actual RDF statements
    final ValueFactory vf = getConnection().getValueFactory();
    Cursor<Statement> stIter;
    stIter = new ConvertingCursor<BindingSet, Statement>(bindingsIter) {

      @Override
      protected Statement convert(BindingSet bindingSet) {
        Resource subject = (Resource)bindingSet.getValue("subject");
        URI predicate = (URI)bindingSet.getValue("predicate");
        Value object = bindingSet.getValue("object");
        Resource context = (Resource)bindingSet.getValue("context");

        if (context == null) {
          return vf.createStatement(subject, predicate, object);
        }
        else {
          return vf.createStatement(subject, predicate, object, context);
        }
      }

      @Override
      protected String getName() {
        return "CreateStatement";
      }
    };

    return new GraphResultImpl(query.getQueryNamespaces(), stIter);
  }
View Full Code Here

      QueryModel query;
      if (queryNode instanceof ASTTupleQuery) {
        query = new TupleQueryModel(tupleExpr);
      }
      else if (queryNode instanceof ASTGraphQuery) {
        query = new GraphQueryModel(tupleExpr, namespaces);
      }
      else {
        throw new RuntimeException("Unexpected query type: " + queryNode.getClass());
      }
View Full Code Here

      ASTQuery queryNode = qc.getQuery();
      if (queryNode instanceof ASTSelectQuery) {
        query = new TupleQueryModel(tupleExpr);
      }
      else if (queryNode instanceof ASTConstructQuery) {
        query = new GraphQueryModel(tupleExpr, prefixes);
      }
      else if (queryNode instanceof ASTAskQuery) {
        query = new BooleanQueryModel(tupleExpr);
      }
      else if (queryNode instanceof ASTDescribeQuery) {
        query = new GraphQueryModel(tupleExpr, prefixes);
      }
      else {
        throw new RuntimeException("Unexpected query type: " + queryNode.getClass());
      }
View Full Code Here

TOP

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

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.