Examples of QuerySolution


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

    ArrayList<VariableDetailsLight> variableDetailsLight = new ArrayList<VariableDetailsLight>();
     
    ResultSet results = rdfHandler.getVariableQuery(variableSearch.getModelUrl());
    int i=0;
    while (results.hasNext()) {
      QuerySolution solution = results.next();
      String variableName = "";
      String predicate = "";
     
      if (solution.getResource("?s") != null) {
        variableName = solution.getResource("?s").getURI();
      }
     
      String id = String.valueOf(i++);
      VariableDetails variableDetails = new VariableDetails(id,variableName);     
     
View Full Code Here

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

    int i = 1;
    for (OntologyTermData term : modelSearch.getTermList()) {
      ResultSet results = rdfHandler.getModelQuery(term.getMiriamURN());
      while (results.hasNext()) {
    
        QuerySolution solution = results.next();
        String modelName = "";
        int frequency = 0;

        if (solution.getResource("?m") != null) {
          modelName = solution.getResource("?m").getURI();
        }

        if (solution.getLiteral("?callret-1") != null) {
          frequency = solution.getLiteral("?callret-1").getInt();
        }

        if(modelName!=""){
          ModelDetails modelDetails = modelDetailsList.get(modelName);
          if(modelDetails == null){
View Full Code Here

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

    ArrayList<VariableDetailsLight> variableDetailsLight = new ArrayList<VariableDetailsLight>();
    ResultSet results = rdfHandler.getVariableAnnotationQuery(variableSearch.getVariableUrl());
   
    int i=0;
    while (results.hasNext()) {
      QuerySolution solution = results.next();
      String predicate = "";
      String annotation = "";
     
      if (solution.getResource("?p") != null) {
        predicate = solution.getResource("?p").getLocalName();
      }
      if (solution.getResource("?o") != null) {
        annotation = solution.getResource("?o").getURI();
      }
     
      VariableDetails variableDetails = new VariableDetails(String.valueOf(i++),variableSearch.getModelUrl(),variableSearch.getVariableUrl(),predicate,annotation);
     
      variableDetailsLight.add(variableDetails.getLightWeightAnnotation());
View Full Code Here

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

  public void testGetModelQuery(){
    ResultSet results = rdfHandler.getModelQuery("urn:miriam:obo.fma:FMA%3A9557");
   
    while (results.hasNext()) {
        
      QuerySolution solution = results.next();
      String modelName = "";
      int frequency = 0;

      if (solution.getResource("?m") != null) {
        modelName = solution.getResource("?m").getURI();
      }

      if (solution.getLiteral("?callret-1") != null) {
        frequency = solution.getLiteral("?callret-1").getInt();
      }
     
      System.out.println(modelName + " - " + frequency);
    }
  }
View Full Code Here

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

  public static QueryResult resultSetToBindingsList(final ResultSet solutions) {
    // System.out.println(solutions);
    try {
      String varname;
      QuerySolution sol;
      final QueryResult result = QueryResult.createInstance();
      Bindings binding;
      // System.out.println(solutions.hasNext());
      while (solutions.hasNext()) {
        sol = solutions.nextSolution();
        binding = new BindingsMap(); // Bindings.createNewInstance();
        final Iterator<String> it = sol.varNames();
        while (it.hasNext()) {
          varname = it.next();
          if (sol.contains(varname)) {
            if (sol.get(varname).isLiteral()) {
              if (sol.getLiteral(varname).getDatatypeURI() != null)
                binding
                    .add(
                        new Variable(varname),
                        TypedLiteralOriginalContent
                            .createTypedLiteral(
                                "\""
                                    + sol
                                        .getLiteral(
                                            varname)
                                        .getLexicalForm()
                                    + "\"",
                                "<"
                                    + sol
                                        .getLiteral(
                                            varname)
                                        .getDatatypeURI()
                                    + ">"));
              else {
                if (sol.getLiteral(varname).getLanguage() != null
                    && sol.getLiteral(varname)
                        .getLanguage().length() > 0) {
                  binding
                      .add(
                          new Variable(varname),
                          lupos.datastructures.items.literal.LiteralFactory
                              .createLanguageTaggedLiteral(
                                  "\""
                                      + sol
                                          .getLiteral(
                                              varname)
                                          .getLexicalForm()
                                      + "\"",
                                  sol
                                      .getLiteral(
                                          varname)
                                      .getLanguage()));
                } else
                  binding
                      .add(
                          new Variable(varname),
                          lupos.datastructures.items.literal.LiteralFactory
                              .createLiteral("\""
                                  + sol
                                      .getLiteral(
                                          varname)
                                      .getLexicalForm()
                                  + "\""));
              }
            } else {
              if (sol.get(varname).isAnon())
                binding
                    .add(
                        new Variable(varname),
                        new lupos.datastructures.items.literal.AnonymousLiteral(
                            sol
                                .getResource(
                                    varname)
                                .toString()));
              else
                binding
                    .add(
                        new Variable(varname),
                        lupos.datastructures.items.literal.LiteralFactory
                            .createURILiteral("<"
                                + sol
                                    .getResource(varname)
                                + ">"));
            }
          }
        }
View Full Code Here

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

  /*
   * patch from garpinc against nulls -
   * http://issues.semweb4j.org/browse/RTGO-65
   */
  public QueryRow next() {
    QuerySolution qs = this.resultSet.nextSolution();
    QueryRowImpl row = new QueryRowImpl();
    for(String v : this.table.getVariables()) {
      RDFNode node = qs.get(v);
      assert node != null : "null node for varname " + v
              + ". Do you have unbound variables in the query?";
      try {
        row.put(v, TypeConversion.toRDF2Go((node == null ? null : node.asNode())));
      } catch(ModelRuntimeException e) {
View Full Code Here

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

            ResultSet rs = qexec.execSelect() ;
           
            // The order of results is undefined.
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x.isLiteral() )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here

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

                qexec = QueryExecutionFactory.create(query, model) ;
               
                ResultSet resultsSet = qexec.execSelect();               
                for ( ; resultsSet.hasNext() ; )
                {
                    QuerySolution soln = resultsSet.nextSolution() ;                   
                    results.add(soln);                 
                }
            } finally {
                qexec.close() ;
            }
View Full Code Here

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

           
            // The order of results is undefined.
            System.out.println("Titles: ") ;
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here

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

        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
        try {
          ResultSet results = qexec.execSelect() ;
          for ( ; results.hasNext() ; )
          {
              QuerySolution soln = results.nextSolution() ;
              int count = soln.getLiteral("count").getInt() ;
              System.out.println("count = "+count) ;
          }
        } finally { qexec.close() ; }

        // Close the dataset.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.