Examples of SPARQLResult


Examples of com.hp.hpl.jena.sparql.resultset.SPARQLResult

        action.beginRead() ;
        QueryExecution qExec = null ;
        try {
            Dataset dataset = decideDataset(action, query, queryStringLog) ;
            qExec = createQueryExecution(query, dataset) ;
            SPARQLResult result = executeQuery(action, qExec, query, queryStringLog) ;
           
            // Deals with exceptions itself.
            sendResults(action, result, query.getPrologue()) ;
        } catch (QueryCancelledException ex) {
            // Additional counter information.
View Full Code Here

Examples of com.hp.hpl.jena.sparql.resultset.SPARQLResult

            // to see if the timeout-end-of-query goes off. 
           
            //rs = ResultSetFactory.copyResults(rs) ;

            log.info(format("[%d] exec/select", action.id)) ;
            return new SPARQLResult(rs) ;
        }

        if ( query.isConstructType() )
        {
            Model model = qExec.execConstruct() ;
            log.info(format("[%d] exec/construct", action.id)) ;
            return new SPARQLResult(model) ;
        }

        if ( query.isDescribeType() )
        {
            Model model = qExec.execDescribe() ;
            log.info(format("[%d] exec/describe",action.id)) ;
            return new SPARQLResult(model) ;
        }

        if ( query.isAskType() )
        {
            boolean b = qExec.execAsk() ;
            log.info(format("[%d] exec/ask",action.id)) ;
            return new SPARQLResult(b) ;
        }

        errorBadRequest("Unknown query type - "+queryStringLog) ;
        return null ;
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.resultset.SPARQLResult

        ResultsFormat format = ResultsFormat.guessSyntax(resultFile) ;
       
        if ResultsFormat.isRDFGraphSyntax(format) )
        {
            Model m = FileManager.get().loadModel(resultFile) ;
            return new SPARQLResult(m) ;
        }
           
        // Attempt to handle as a resulset or boolean result.s
        SPARQLResult x = ResultSetFactory.result(resultFile) ;
        return x ;
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.resultset.SPARQLResult

        validateQuery(action, query) ;
       
        // Assumes finished whole thing by end of sendResult.
        action.beginRead() ;
        try {
            SPARQLResult result = executeQuery(action, query, queryStringLog) ;
            sendResults(action, result) ;
        } finally { action.endRead() ; }
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.resultset.SPARQLResult

//            // Not necessary if we are inside a read lock until the end of sending results.
//            rs = ResultSetFactory.copyResults(rs) ;

            log.info(format("[%d] OK/select", action.id)) ;
            return new SPARQLResult(rs) ;
        }

        if ( query.isConstructType() )
        {
            Model model = qexec.execConstruct() ;
            log.info(format("[%d] OK/construct", action.id)) ;
            return new SPARQLResult(model) ;
        }

        if ( query.isDescribeType() )
        {
            Model model = qexec.execDescribe() ;
            log.info(format("[%d] OK/describe",action.id)) ;
            return new SPARQLResult(model) ;
        }

        if ( query.isAskType() )
        {
            boolean b = qexec.execAsk() ;
            log.info(format("[%d] OK/ask",action.id)) ;
            return new SPARQLResult(b) ;
        }

        errorBadRequest("Unknown query type - "+queryStringLog) ;
        return null ;
    }
View Full Code Here

Examples of no.priv.garshol.duke.utils.SparqlResult

      int offset = parseOffset(query);
      if (pagesize == 0)
        // this means paging has been turned off completely
        assertTrue("paging not truly disabled", limit == -1 && offset == -1);

      SparqlResult result = new SparqlResult();
      for (String var : vars)
        result.addVariable(var);

      int end;
      if (limit == -1)
        end = rows.length;
      else
        end = Math.min(offset + limit, rows.length);
      if (offset == -1)
        offset = 0; // we start at zero even so
      for (int ix = offset; ix < end; ix++)
        result.addRow(rows[ix]);

      pages++;
     
      return result;
    }
View Full Code Here

Examples of no.priv.garshol.duke.utils.SparqlResult

        thisquery += (" limit " + pagesize + " offset " + (pageno * pagesize));

      if (logger != null)
        logger.debug("SPARQL query: " + thisquery);

      SparqlResult result = runQuery(endpoint, thisquery);
      variables = result.getVariables();
      page = result.getRows();

      if (triple_mode && !page.isEmpty() && page.get(0).length != 3)
        throw new DukeConfigException("In triple mode SPARQL queries must " +
                                      "produce exactly three columns!");

View Full Code Here

Examples of no.priv.garshol.duke.utils.SparqlResult

public class SparqlClientTest {

  @Test
  public void testEmpty() throws IOException {
    SparqlResult result = load("sparql-empty.xml");
    assertEquals(0, result.getRows().size());
    assertEquals(0, result.getVariables().size());
  }
View Full Code Here

Examples of no.priv.garshol.duke.utils.SparqlResult

    assertEquals(0, result.getVariables().size());
  }

  @Test
  public void testOneRow() throws IOException {
    SparqlResult result = load("sparql-onerow.xml");

    assertEquals(1, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
   
    assertEquals(1, result.getRows().size());
    String[] row = result.getRows().get(0);
    assertEquals(1, row.length);
    assertEquals("1", row[0]);
  }
View Full Code Here

Examples of no.priv.garshol.duke.utils.SparqlResult

    assertEquals("1", row[0]);
  }

  @Test
  public void testOneRow2Col() throws IOException {
    SparqlResult result = load("sparql-onerow2col.xml");

    assertEquals(2, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
    assertEquals("y", result.getVariables().get(1));
   
    assertEquals(1, result.getRows().size());
    String[] row = result.getRows().get(0);
    assertEquals(2, row.length);
    assertEquals("1", row[0]);
    assertEquals("http://example.org", row[1]);
  }
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.