Package com.hp.hpl.jena.query

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


            "   ?Meal rdf:type food:MealCourse .\r\n" +
            "   ?Meal food:hasDrink ?Wine .\r\n" +
            "   ?Wine wine:hasColor ?WineColor" +
            queryEnd;

        Query query1 = QueryFactory.create( queryStr1 );
        Query query2 = QueryFactory.create( queryStr2 );

        // The following definitions from food ontology dictates that
        // PastaWithLightCreamCourse has white wine and RedMeatCourse
        // has red wine.
        //  Class(PastaWithLightCreamCourse partial
View Full Code Here


 
      // Then read the data from the file into the ontology model
      m.read( ontology );
 
      // Now read the query file into a query object
      Query q = QueryFactory.read( query );
 
      // Create a SPARQL-DL query execution for the given query and
      // ontology model
      QueryExecution qe = SparqlDLExecutionFactory.create( q, m );
 
      // We want to execute a SELECT query, do it, and return the result set
      ResultSet rs = qe.execSelect();
 
      // Print the query for better understanding
      System.out.println(q.toString());
     
      // There are different things we can do with the result set, for
      // instance iterate over it and process the query solutions or, what we
      // do here, just print out the results
      ResultSetFormatter.out( rs );
View Full Code Here

       
        // Force setup
        {
            getStore() ;
            getModStore().getDataset() ;
            Query query = modQuery.getQuery() ;
            QueryExecution qExec = QueryExecutionFactory.create(query, getModStore().getDataset()) ;
            // Don't execute
            qExec.abort();
        }
       
        if ( getModTime().timingEnabled() )
        {
            // Setup costs : flush classes into memory and establish connection
            getModTime().startTimer() ;
            long connectTime =  getModTime().endTimer() ;
            //System.out.println("Connect time:    "+timeStr(connectTime)) ;
           
            getModTime().startTimer() ;
            Query query = modQuery.getQuery() ;
            long javaTime = getModTime().endTimer() ;
           
            if ( isVerbose() )
                System.out.println("Class load time: "+getModTime().timeStr(javaTime)) ;
        }
       
       
        long totalTime = 0 ;
        try {
            getModTime().startTimer() ;
            for ( int i = 0 ; i < repeatCount ; i++ )
            {
//                if ( i == 2 )
//                {
//                    // Reset timer to forget classloading overhead
//                    getModTime().endTimer() ;
//                    getModTime().startTimer() ;
//                }
                   
                Query query = modQuery.getQuery() ;
                QueryExecution qExec = QueryExecutionFactory.create(query, getModStore().getDataset()) ;
               
                if ( isVerbose() )
                    PrintSDB.print(((QueryExecutionBase)qExec).getPlan().getOp()) ;
               
View Full Code Here

    }

    @Override
    protected void execCmd(List<String> positionalArgs)
    {
        Query query = modQuery.getQuery() ;
        compilePrint(getStore(), query) ;
    }
View Full Code Here

    public static QuerySolution[] executeSimpleSparql(Model model, String queryStr) {
        LinkedList results = new LinkedList();       
        model.enterCriticalSection(Lock.READ) ;//Concurrency protect, it is  absolutely not neccesary but is recommended
        try{
            Query query = QueryFactory.create(queryStr) ;
            QueryExecution qexec = null;
            try {
                qexec = QueryExecutionFactory.create(query, model) ;
               
                ResultSet resultsSet = qexec.execSelect();               
View Full Code Here

        return (subject+(" ")+predicate+(" ")+object);
    }
   
   
    public static boolean runQuestion(Model model,String queryString) {
        Query query = QueryFactory.create(queryString) ;
        QueryExecution qe = QueryExecutionFactory.create(query, model);       
        return qe.execAsk();
    }
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

            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

        return query ;
    }
   
    public static Element parseElement(String string)
    {
        final Query query = new Query () ;
        Action action = new Action() {
            @Override
            public void exec(SPARQLParser10 parser) throws Exception
            {
                Element el = parser.GroupGraphPattern() ;
                query.setQueryPattern(el) ;
            }
        } ;
        perform(query, string, action) ;
        return query.getQueryPattern() ;
    }
View Full Code Here

        return query.getQueryPattern() ;
    }
   
    public static Template parseTemplate(String string)
    {
        final Query query = new Query () ;
        Action action = new Action() {
            @Override
            public void exec(SPARQLParser10 parser) throws Exception
            {
                Template t = parser.ConstructTemplate() ;
                query.setConstructTemplate(t) ;
            }
        } ;
        perform(query, string, action) ;
        return query.getConstructTemplate() ;
    }
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.