Package com.hp.hpl.jena.query

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


       
        // Query string.
        String queryString = prolog + NL +
            "SELECT ?title WHERE {?x dc:title ?title}" ;
       
        Query query = QueryFactory.create(queryString) ;
        // Print with line numbers
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        // Create a single execution of this query, apply to a model
        // which is wrapped up as a Dataset
       
View Full Code Here


    public static void main(String []args)
    {
        String s = "SELECT DISTINCT ?s { ?s ?p ?o }";
       
        // Parse
        Query query = QueryFactory.create(s) ;
        System.out.println(query) ;
       
        // Generate algebra
        Op op = Algebra.compile(query) ;
        op = Algebra.optimize(op) ;
View Full Code Here

   
    public static void main(String[] args)
    {
        Model model = createModel() ;
       
        Query query = QueryFactory.make() ;
        query.setQuerySelectType() ;
       
        // See also ExProg1
       
        ElementGroup elg = new ElementGroup() ;
       
        Var varTitle = Var.alloc("title") ;
        Var varX = Var.alloc("x") ;
       
        Triple t1 = new Triple(varX, DC.title.asNode(),  varTitle) ;
        elg.addTriplePattern(t1) ;
       
        // Adds a filter.  Need to wrap variable in a NodeVar.
        Expr expr = new E_Regex(new ExprVar(varTitle), "sparql", "i") ;
        ElementFilter filter = new  ElementFilter(expr) ;
        elg.addElementFilter(filter) ;
       
        // Attach the group to query. 
        query.setQueryPattern(elg) ;
       
        // Choose what we want - SELECT ?title
        query.addResultVar(varTitle) ;
       
        // Print query with line numbers
        // Prefix mapping just helps serialization
        query.getPrefixMapping().setNsPrefix("dc" , DC.getURI()) ;
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

        try {
View Full Code Here

       
        // Query string.
        String queryString = prolog + NL +
            "SELECT ?title WHERE {?x dc:title ?title}" ;
       
        Query query = QueryFactory.create(queryString) ;
        // Print with line numbers
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        // Create a single execution of this query, apply to a model
        // which is wrapped up as a Dataset
       
View Full Code Here

    static void performQuery(Model model, IndexLARQ index, String queryString)
    { 
        // Make globally available
        LARQ.setDefaultIndex(index) ;
       
        Query query = QueryFactory.create(queryString) ;
        query.serialize(System.out) ;
        System.out.println();
                                         
        QueryExecution qExec = QueryExecutionFactory.create(query, model) ;
        //LARQ.setDefaultIndex(qExec.getContext(), index) ;
        ResultSetFormatter.out(System.out, qExec.execSelect(), query) ;
View Full Code Here

   
    public static void main(String[] args)
    {
        Model model = createModel() ;
       
        Query query = QueryFactory.make() ;

        query.setQuerySelectType() ;
       
        // Build pattern
       
        ElementGroup elg = new ElementGroup() ;
       
        Var varTitle = Var.alloc("title") ;
        Var varX = Var.alloc("x") ;
       
        Triple t1 = new Triple(varX, DC.title.asNode(),  varTitle) ;
        elg.addTriplePattern(t1) ;
       
        // Don't use bNodes for anon variables.  The conversion is done in parsing.
        // BNodes here are assumed to be values from the target graph.
        Triple t2 = new Triple(varX, DC.description.asNode(), Var.alloc("desc")) ;
        elg.addTriplePattern(t2) ;
       
        // Attach the group to query. 
        query.setQueryPattern(elg) ;

        // Choose what we want - SELECT *
        //query.setQueryResultStar(true) ;
        query.addResultVar(varTitle) ;
       
        // Print query with line numbers
        // Prefix mapping just helps serialization
        query.getPrefixMapping().setNsPrefix("dc" , DC.getURI()) ;
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
       
        try {
View Full Code Here

    {
        // Call the function as java:arq.examples.ext.labelSearch or register it.
        String prologue = "PREFIX ext: <java:arq.examples.propertyfunction.>\n" ;

        String qs = prologue+"SELECT * { ?x ext:labelSearch 'EF' }" ;
        Query query = QueryFactory.create(qs) ;
        Model model = make() ;
        QueryExecution qExec = QueryExecutionFactory.create(query, model) ;
        try {
            ResultSet rs = qExec.execSelect() ;
            ResultSetFormatter.out(rs) ;
View Full Code Here

            StageGenerator origStageGen = (StageGenerator)ARQ.getContext().get(ARQ.stageGenerator) ;
            StageGenerator stageGenAlt = new StageGeneratorAlt(origStageGen) ;
            ARQ.getContext().set(ARQ.stageGenerator, stageGenAlt) ;
        }
       
        Query query = QueryFactory.create( StrUtils.strjoin("\n", queryString)) ;
        QueryExecution engine = QueryExecutionFactory.create(query, makeData()) ;
       
        // ... or set on a per-execution basis.
        if ( true )
        {
View Full Code Here

          "xslt-uri");

      log.info("Query is:\n" + theQuery);
      log.info("Stylesheet: " + stylesheet);

      Query query = QueryFactory.create(theQuery);

      if (type == LDAP)
        qe = new LdapQueryEngine(query, config);
      else
        qe = new SQLQueryEngine(query, config);
View Full Code Here

  }
 
  public QueryEngine prepareQuery(String queryS) throws SQLException, ConfigException
  {
    Model config = ExtractConfig.process("jdbc:hsqldb:mem:test", "org.hsqldb.jdbcDriver", "urn:ex:", "sa", "", new String[]{"TABLE1", "TABLE2"}, conn.getMetaData());
    Query query = QueryFactory.create(queryS);
    QueryEngine qe = new SQLQueryEngine(query, config);
    qe.setDataset(DatasetFactory.create());
    return qe;
  }
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.