/** * Perform the {@link QueryExecution} once. * * @param action * @param queryExecution * @param query * @param queryStringLog Informational string created from the initial query. * @return */ protected SPARQLResult executeQuery( HttpAction action, QueryExecution queryExecution, Query query, String queryStringLog) { setAnyTimeouts(queryExecution, action); if (query.isSelectType()) { ResultSet rs = queryExecution.execSelect(); // Force some query execution now. // If the timeout-first-row goes off, the output stream has not // been started so the HTTP error code is sent. rs.hasNext(); // If we wanted perfect query time cancellation, we could consume // the result now to see if the timeout-end-of-query goes off. // rs = ResultSetFactory.copyResults(rs) ; // action.log.info(format("[%d] exec/select", action.id)) ; return new SPARQLResult(rs); } if (query.isConstructType()) { Dataset dataset = queryExecution.execConstructDataset(); // action.log.info(format("[%d] exec/construct", action.id)); return new SPARQLResult(dataset); } if (query.isDescribeType()) { Model model = queryExecution.execDescribe(); // action.log.info(format("[%d] exec/describe", action.id)) ; return new SPARQLResult(model); } if (query.isAskType()) { boolean b = queryExecution.execAsk(); // action.log.info(format("[%d] exec/ask", action.id)) ; return new SPARQLResult(b); } ServletOps.errorBadRequest("Unknown query type - " + queryStringLog); return null; }
void runTestDescribe(Query query, QueryExecution qe) throws Exception { Model resultsActual = qe.execDescribe(); compareGraphResults(resultsActual, query); }
/** * Query SPARQL endpoint with a DESCRIBE query * * @param qExec QueryExecution encapsulating the query * @return model retrieved by querying the endpoint */ private Model getDescribeModel(QueryExecution qExec) { return qExec.execDescribe(ModelFactory.createDefaultModel()); }