Package com.hp.hpl.jena.query

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


            ResultSet rs = qExec.execSelect() ;
           
            if ( ! rs.hasNext() )
                throw new ARQException("Not found: var ?"+varname) ;

            QuerySolution qs = rs.nextSolution() ;
            RDFNode r = qs.get(varname) ;
            if ( rs.hasNext() )
                throw new ARQException("More than one: var ?"+varname) ;
            return r ;
        } finally { qExec.close() ; }
    }
View Full Code Here


            ResultSet rs = qExec.execSelect() ;
           
            if ( ! rs.hasNext() )
                return null ;

            QuerySolution qs = rs.nextSolution() ;
            RDFNode r = qs.get(varname) ;
            if ( rs.hasNext() )
                throw new ARQException("More than one: var ?"+varname) ;
            return r ;
        } finally { qExec.close() ; }
    }
View Full Code Here

            System.out.println(new MetadataWrapper(new SimpleTupleMetadata(
                    listColumnMetadata)));

            for (; rs.hasNext();)
            {
                QuerySolution qs = rs.next();
                List<String> lst = new ArrayList<String>();
                for (String varName : rs.getResultVars())
                {
                    RDFNode node = qs.get(varName);
                    // if node is null then it is a blank node
                    if (node == null)
                    {
                        lst.add("blankNode");
                    }
View Full Code Here

//      ResultSetFormatter.out(System.out, results, query) ;
      
      for ( ; results.hasNext() ; )
      {
        QuerySolution soln = results.nextSolution() ;
       
        RDFNode m = soln.get("model") ;       // Get a result variable by name.

        if (m == null) {
          logger.info("model uri is null.");
          continue;
        }

        String uri = m.asResource().getNameSpace();
        logger.debug("service uri: " + uri);
        if (IdsAndMappings.get(uri) == null) {
          IdsAndMappings.put(uri, new HashMap<String, String>());
        }
       
        for (String arg : argList) {
          RDFNode argNode = soln.get(arg) ;
          if (argNode != null && argNode.isResource()) {
            String retrieved_id = argNode.asResource().getLocalName();
            IdsAndMappings.get(uri).put(arg, retrieved_id);
          }
        }
View Full Code Here

//      ResultSetFormatter.out(System.out, results, query) ;
      
      for ( ; results.hasNext() ; )
      {
        QuerySolution soln = results.nextSolution() ;
        Map<String, String> attValues =
          new HashMap<String, String>();
       
        for (String arg : argList) {
          RDFNode argNode = soln.get(arg) ;
          if (argNode != null) {
            String value = argNode.toString();
            attValues.put(arg, value);
          }
        }
View Full Code Here

//      ResultSetFormatter.out(System.out, results, query) ;
      
      for ( ; results.hasNext() ; )
      {
        QuerySolution soln = results.nextSolution() ;
       
        RDFNode s = soln.get("s") ;       // Get a result variable by name.
        RDFNode name = soln.get("name") ;       // Get a result variable by name.
        RDFNode address = soln.get("address") ;       // Get a result variable by name.

        if (s == null) {
          logger.info("service id is null.");
          continue;
        }
View Full Code Here

//      ResultSetFormatter.out(System.out, results, query) ;
      
      String serviceURI = "";
      for ( ; results.hasNext() ; )
      {
        QuerySolution soln = results.nextSolution() ;
        RDFNode x = soln.get("s") ;       // Get a result variable by name.
        serviceURI = x.toString();
        logger.info("Service with id " + x.toString() + " has been found with the address " + address);
        break;
      }
     
View Full Code Here

        tree.addStartElement(s_results);
        tree.startContent();

        while (results.hasNext()) {
            QuerySolution soln = results.next();

            tree.addStartElement(s_result);
            tree.startContent();

            Iterator<String> iter = soln.varNames();
            while (iter.hasNext()) {
                String var = iter.next();

                tree.addStartElement(s_binding);
                tree.addAttribute(_name, var);
                tree.startContent();

                RDFNode node = soln.get(var);

                if (node.isLiteral()) {
                    Literal lit = node.asLiteral();
                    tree.addStartElement(s_literal);
View Full Code Here

        if ( results.size() !=1 )  {
            Log.warn(this, "Multiple matches for EntityMap for : "+root) ;
            throw new SpatialIndexException("Multiple matches for EntityDefinition for : "+root) ;
        }
       
        QuerySolution qsol1 = results.get(0) ;
        String entityField = qsol1.getLiteral("entityField").getLexicalForm() ;
        String geoField = qsol1.getLiteral("geoField").getLexicalForm() ;
       
        EntityDefinition docDef = new EntityDefinition(entityField, geoField) ;
       
        String qs2 = StrUtils.strjoinNL("SELECT * { ?definition :hasSpatialPredicatePairs [ list:member [ :latitude ?latitude ; :longitude ?longitude ] ]}") ;
        Query query2 = QueryFactory.create(prologue+" "+qs2) ;
        QueryExecution qexec2 = QueryExecutionFactory.create(query2, model, qsol1) ;
        ResultSet rs2 = qexec2.execSelect() ;
        List<QuerySolution> mapEntries = ResultSetFormatter.toList(rs2) ;
       
        for ( QuerySolution qsol : mapEntries ) {
          Resource latitude = qsol.getResource("latitude") ;
            Resource longitude = qsol.getResource("longitude") ;
            docDef.addSpatialPredicatePair(latitude, longitude);
        }
              
        String qs3 = StrUtils.strjoinNL("SELECT * { ?definition :hasWKTPredicates [ list:member ?wkt ] }") ;
        Query query3 = QueryFactory.create(prologue+" "+qs3) ;
        QueryExecution qexec3 = QueryExecutionFactory.create(query3, model, qsol1) ;
        ResultSet rs3 = qexec3.execSelect() ;
        mapEntries = ResultSetFormatter.toList(rs3) ;
       
        for ( QuerySolution qsol : mapEntries ) {
          Resource wkt = qsol.getResource("wkt") ;
            docDef.addWKTPredicate(wkt);
        }
       
        String qs4 = StrUtils.strjoinNL("SELECT * { ?definition :spatialContextFactory ?factory }") ;
        Query query4 = QueryFactory.create(prologue+" "+qs4) ;
        QueryExecution qexec4 = QueryExecutionFactory.create(query4, model, qsol1) ;
        ResultSet rs4 = qexec4.execSelect() ;
        List<QuerySolution> results4 = ResultSetFormatter.toList(rs4) ;
        if (results4.size() ==0){
          return docDef;
        } else if ( results4.size() !=)  {
            Log.warn(this, "Multiple matches for SpatialContextFactory for : "+root) ;
            throw new SpatialIndexException("Multiple matches for SpatialContextFactory for : "+root) ;
        } else {
          QuerySolution qsol4 = results4.get(0);
          String spatialContextFactory = qsol4.getLiteral("factory").getLexicalForm() ;
          try {
            docDef.setSpatialContextFactory(spatialContextFactory);
          }catch (NoClassDefFoundError e){
            Log.warn(this, "Custom SpatialContextFactory lib is not ready in classpath:"+ e.getMessage()) ;
          }
View Full Code Here

        // Preparation pass : find the maximum width for each column
        for ( ; rs.hasNext() ; )
        {
            numRows++ ;
            QuerySolution rBind = rs.nextSolution() ;
            int col = -1 ;
            for ( String s1 : rs.getResultVars() )
            {
                col++;
                String rVar = s1;
View Full Code Here

TOP

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

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.