Package com.hp.hpl.jena.query

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


       
        // Potentially expensive query.
        String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
        // See http://www.openjena.org/ARQ/app_api.html
       
        Query query = QueryFactory.create(sparqlQueryString) ;
        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
        try {
          ResultSet results = qexec.execSelect() ;
          for ( ; results.hasNext() ; )
          {
View Full Code Here


       
        // Potentially expensive query.
        String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
        // See http://www.openjena.org/ARQ/app_api.html
       
        Query query = QueryFactory.create(sparqlQueryString) ;
        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
        ResultSet results = qexec.execSelect() ;
        ResultSetFormatter.out(results) ;
        qexec.close() ;

View Full Code Here

/** Convert an Op expression in SPARQL syntax, that is, the reverse of algebra generation */  
public class OpAsQuery
{
    public static Query asQuery(Op op)
    {
        Query query = QueryFactory.make() ;
       
        Converter v = new Converter(query) ;
        //OpWalker.walk(op, v) ;
        op.visit(v) ;
       
        List<Var> vars = v.projectVars;
        query.setQueryResultStar(vars.isEmpty()); // SELECT * unless we are projecting
        Iterator<Var> iter = vars.iterator();
        for (; iter.hasNext();) {
            Var var = iter.next();
            if (v.varExpression.containsKey(var))
                query.addResultVar(var, v.varExpression.get(var));
            else
                query.addResultVar(var);
        }
       
        ElementGroup eg = v.currentGroup ;
        query.setQueryPattern(eg) ;
        query.setQuerySelectType() ;
       
        query.setResultVars() ;
        return query ;
    }
View Full Code Here

        assertEquals("http://theyknow.whatiswhat.com/text<withAngleBrackets>",uri);
    }

    @Test
    public void testQueryParsing() {
        Query q=QueryFactory.create(
                "PREFIX basekb: <http://rdf.basekb.com/ns/> \n" +
                        "\n" +
                        "SELECT * {basekb:en.brad_pitt ?p ?o .}"
                );
        assertTrue(true);
View Full Code Here

        assertTrue(true);
    }

    //  @Test
    public void testBinding() {
        Query q=QueryFactory.create(
                "SELECT ?dayName WHERE {"+
                        "   FILTER (!bound(?dayIDCheck))"+
                        "}"+
                        "BINDINGS ?dayIDCheck ?dayName {"+
                        "   (0 'Sunday'@en)"+
View Full Code Here

    //
    public static void appendConstruct(Model outModel,
            String queryString,
            Model inModel,
            QuerySolution bindings) {
        Query query=QueryFactory.create(queryString);
        QueryExecution qe=QueryExecutionFactory.create(query,inModel);
        try {
            if(null!=bindings) {
                qe.setInitialBinding(bindings);
            }
View Full Code Here

   * @throws Exception
   */
  public static QueryResult executeQuery(Model model, String sparqlQuery, String form) throws Exception {
    QueryExecution qe = null;
    try {
      Query query = QueryFactory.create(sparqlQuery);
      qe = QueryExecutionFactory.create(query, model);
      if ( log.isDebugEnabled() ) {
        log.debug("QueryExecution class: " +qe.getClass().getName());
      }
      return executeQuery(query, qe, sparqlQuery, form);
View Full Code Here

      return queryResult;
    }
   
    // use Jena to determine what kind of query this is (AG doesn't seem to provide an operation for this)
    // so we call the appropriate execution method:
    Query query = QueryFactory.create(sparqlQuery);

    // only one of these results is captured
    TriplesIterator tripleIter = null;
    ValueSetIterator valSetIter = null;
    Boolean askResult = null;

   
    queryResult.setContentType("text/plain");

    // SELECT
    if ( query.isSelectType() ) {
      valSetIter = sq.select();
    }
    // DESCRIBE
    else if ( query.isDescribeType() ) {
      tripleIter = sq.describe();
    }
    // CONSTRUCT
    else if ( query.isConstructType() ) {
      tripleIter = sq.construct();
    }
    // ASK
    else if ( query.isAskType() ) {
      askResult = Boolean.valueOf(sq.ask());
    }

    if ( valSetIter != null ) {
      queryResult.setIsEmpty(! valSetIter.hasNext());
View Full Code Here

  }

  private QueryResult _executeQuery(_Conn _conn, String sparqlQuery, String form) throws Exception {
    log.debug(" _executeQuery called.");
   
    Query query = QueryFactory.create(sparqlQuery);
    VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create(query, _conn._graph);
   
    try {
      QueryResult queryResult = Sparql.executeQuery(query, vqe, sparqlQuery, form);
      return queryResult;
View Full Code Here

   
    if ( entities == null ) {
      entities = new ArrayList<IndividualInfo>();
    }
   
    Query query = QueryFactory.create(INDIVIDUALS_QUERY);
    QueryExecution qe = QueryExecutionFactory.create(query, ontModel);
   
    ResultSet results = qe.execSelect();
   
    while ( results.hasNext() ) {
View Full Code Here

TOP

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

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.