Package org.openrdf.query

Examples of org.openrdf.query.GraphQuery


    queryBuilder.append(" CONSTRUCT *");
    queryBuilder.append(" FROM {} foaf:name {name};");
    queryBuilder.append("         foaf:mbox {mbox}");
    queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");

    GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SERQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    GraphResult result = query.evaluate();

    try {
      assertNotNull(result);
      assertTrue(result.hasNext());

View Full Code Here


    // resolve the query language String to a QueryLanguage
    QueryLanguage language = ConversionUtil.toOpenRDFQueryLanguage(queryLanguage);
   
    try {
      // determine query result
      GraphQuery query = this.connection.prepareGraphQuery(language, queryString);
      GraphQueryResult queryResult = query.evaluate();
     
      // wrap it in a GraphIterable
      return new GraphIterable(queryResult, null);
    } catch(OpenRDFException e) {
      throw new ModelRuntimeException(e);
View Full Code Here

 
  @Override
  public ClosableIterable<Statement> sparqlConstruct(String queryString)
          throws ModelRuntimeException {
    this.assertModel();
    GraphQuery query;
    try {
      query = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
      GraphQueryResult graphQueryResult = query.evaluate();
      return new StatementIterable(graphQueryResult, null);
    } catch(OpenRDFException e) {
      throw new ModelRuntimeException(e);
    }
  }
View Full Code Here

 
  @Override
  public ClosableIterable<Statement> sparqlDescribe(String queryString)
          throws ModelRuntimeException {
    this.assertModel();
    GraphQuery query;
    try {
      query = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
      GraphQueryResult graphQueryResult = query.evaluate();
      return new StatementIterable(graphQueryResult, null);
    } catch(OpenRDFException e) {
      throw new ModelRuntimeException(e);
    }
  }
View Full Code Here

        queryResult = tQuery.evaluate();
        registry = TupleQueryResultWriterRegistry.getInstance();
        view = TupleQueryResultView.getInstance();
      }
      else if (query instanceof GraphQuery) {
        GraphQuery gQuery = (GraphQuery)query;

        queryResult = gQuery.evaluate();
        registry = RDFWriterRegistry.getInstance();
        view = GraphQueryResultView.getInstance();
      }
      else if (query instanceof BooleanQuery) {
        BooleanQuery bQuery = (BooleanQuery)query;
View Full Code Here

    queryBuilder.append(" CONSTRUCT *");
    queryBuilder.append(" FROM {} foaf:name {name};");
    queryBuilder.append("         foaf:mbox {mbox}");
    queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");

    GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SERQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    GraphQueryResult result = query.evaluate();

    try {
      assertTrue(result != null);
      assertTrue(result.hasNext());

View Full Code Here

    assertConnected();

    GraphBuildingRDFHandler aHandler = new GraphBuildingRDFHandler();

    try {
      GraphQuery aQuery = mConnection.prepareGraphQuery(mQueryLang, theQuery);
      aQuery.evaluate(aHandler);     
      return aHandler.getGraph();   
    }
    catch (Exception e) {
      throw new QueryException(e);
    }
View Full Code Here

    }
    return (Value[][]) results.toArray(new Value[0][0]);
  }

  private static Graph doGraphQuery(RepositoryConnection con, String query) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    GraphQuery resultsTable = con.prepareGraphQuery(QueryLanguage.SPARQL, query);
    GraphQueryResult statements = resultsTable.evaluate();
    Graph g = new GraphImpl();

    Vector<Value[]> results = new Vector<Value[]>();
    for (int row = 0; statements.hasNext(); row++) {
      Statement pairs = statements.next();
View Full Code Here

    }
    return (Value[][]) results.toArray(new Value[0][0]);
  }

  private static Graph doGraphQuery(RepositoryConnection con, String query) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    GraphQuery resultsTable = con.prepareGraphQuery(QueryLanguage.SPARQL, query);
    GraphQueryResult statements = resultsTable.evaluate();
    Graph g = new GraphImpl();

    Vector<Value[]> results = new Vector<Value[]>();
    for (int row = 0; statements.hasNext(); row++) {
      Statement pairs = statements.next();
View Full Code Here

  public GraphQuery prepareGraphQuery(QueryLanguage language, final String query, String baseURI) throws RepositoryException, MalformedQueryException {

    if (language != QueryLanguage.SPARQL)
      throw new UnsupportedQueryLanguageException(" : Only SPARQL queries are supported");

    GraphQuery q = new VirtuosoGraphQuery() {
      public GraphQueryResult evaluate() throws QueryEvaluationException {
        return executeSPARQLForGraphResult(query, getDataset(), getIncludeInferred(), getBindings());
      }

      public void evaluate(RDFHandler handler) throws QueryEvaluationException, RDFHandlerException {
View Full Code Here

TOP

Related Classes of org.openrdf.query.GraphQuery

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.