Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.QueryExecution


  @Override
  public ClosableIterable<Statement> sparqlConstruct(String queryString)
          throws ModelRuntimeException {
    assertModel();
    Query query = QueryFactory.create(queryString);
    QueryExecution qexec = QueryExecutionFactory.create(query, this.jenaModel);
   
    if(query.isConstructType()) {
      com.hp.hpl.jena.rdf.model.Model m = qexec.execConstruct();
      Model resultModel = new ModelImplJena(null, m, Reasoning.none);
      resultModel.open();
      return resultModel;
    } else {
      throw new RuntimeException("Cannot handle this type of queries! Please use CONSTRUCT.");
View Full Code Here


   
    if(!query.isAskType()) {
      throw new ModelRuntimeException("The given query is not an ASK query");
    }
    // else
    QueryExecution qexec = QueryExecutionFactory.create(query, this.jenaModel);
    return qexec.execAsk();
  }
View Full Code Here

  }
 
  @Override
  public QueryResultTable sparqlSelect(String url, String queryString) {
    log.debug("Query " + queryString);
    QueryExecution qe = QueryExecutionFactory.sparqlService(url, queryString);
    return new QueryResultTableImpl(qe);
  }
View Full Code Here

  public ClosableIterable<Statement> queryConstruct(String query,
      String querylanguage) throws QueryLanguageNotSupportedException,
      MalformedQueryException, ModelRuntimeException {

    Query jenaQuery = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
        this.dataset);

    if (jenaQuery.isConstructType()) {
      com.hp.hpl.jena.rdf.model.Model m = qexec.execConstruct();
      Model resultModel = new ModelImplJena(null, m, Reasoning.none);
      resultModel.open();
      return resultModel;
    } else {
      throw new RuntimeException(
View Full Code Here

  @Override
  public ClosableIterable<Statement> sparqlConstruct(String query)
      throws ModelRuntimeException, MalformedQueryException {
    Query jenaQuery = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
        this.dataset);

    if (jenaQuery.isConstructType()) {
      com.hp.hpl.jena.rdf.model.Model m = qexec.execConstruct();
      Model resultModel = new ModelImplJena(null, m, Reasoning.none);
      resultModel.open();
      return resultModel;
    } else {
      throw new RuntimeException(
View Full Code Here

  @Override
  public ClosableIterable<Statement> sparqlDescribe(String query)
      throws ModelRuntimeException {
    Query jenaQuery = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
        this.dataset);

    if (jenaQuery.isDescribeType()) {
      com.hp.hpl.jena.rdf.model.Model m = qexec.execDescribe();
      Model resultModel = new ModelImplJena(null, m, Reasoning.none);
      resultModel.open();
      return resultModel;
    } else {
      throw new RuntimeException(
View Full Code Here

  @Override
  public boolean sparqlAsk(String query) throws ModelRuntimeException,
      MalformedQueryException {
    Query jenaQuery = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
        this.dataset);

    if (jenaQuery.isAskType()) {
      return qexec.execAsk();
    } else {
      throw new RuntimeException(
          "Cannot handle this type of query! Please use ASK.");
    }
  }
View Full Code Here

    if (this.countStatementsQuery == null) {
      this.countStatementsQuery = QueryFactory.create(query,
          com.hp.hpl.jena.query.Syntax.syntaxARQ);
    }

    QueryExecution exec = QueryExecutionFactory.create(
        this.countStatementsQuery, this.dataset, initialBindings);
    QueryResultTable result = new QueryResultTableImpl(exec);
    return Long
        .parseLong(result.iterator().next().getLiteralValue("count"));
  }
View Full Code Here

      "      }";

    Query query = QueryFactory.create(queryString);   
   
    // Execute the query and obtain results
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    ResultSet results = qe.execSelect();

    // Output query results
    ByteArrayOutputStream debug = new ByteArrayOutputStream();
    ResultSetFormatter.out(debug, results, query);
    logger.debug(debug.toString());

    // Important - free up resources used running the query
    qe.close();
       
    Assert.assertNotNull(model);
  }
View Full Code Here

    {
        Query query = modQuery.getQuery() ;

        try {
            String serviceURL = modRemote.getServiceURL() ;
            QueryExecution qe = QueryExecutionFactory.sparqlService(serviceURL, query) ;
            if ( modRemote.usePost() )
                HttpQuery.urlLimit = 0 ;

            QueryExecUtils.executeQuery(query, qe, modResults.getResultsFormat()) ;
        } catch (QueryExceptionHTTP ex)
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.QueryExecution

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.