/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query) { return sparqlService(service, query, (HttpClient)null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @param defaultGraphURIs List of URIs to make up the default graph * @param namedGraphURIs List of URIs to make up the named graphs * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, List<String> defaultGraphURIs, List<String> namedGraphURIs) { return sparqlService(service, query, defaultGraphURIs, namedGraphURIs, null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query to execute * @param defaultGraph URI of the default graph * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query, String defaultGraph) { return sparqlService(service, query, defaultGraph, null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @param defaultGraph URI of the default graph * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, String defaultGraph) { return sparqlService(service, query, defaultGraph, null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query to execute * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query) { return sparqlService(service, query, (HttpClient)null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query to execute * @param defaultGraphURIs List of URIs to make up the default graph * @param namedGraphURIs List of URIs to make up the named graphs * @param client HTTP client * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query, List<String> defaultGraphURIs, List<String> namedGraphURIs, HttpClient client) { return sparqlService(service, query, defaultGraphURIs, namedGraphURIs, client, null); }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query to execute * @param defaultGraph URI of the default graph * @param client HTTP client * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query, String defaultGraph, HttpClient client) { return sparqlService(service, query, client, null); }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @param defaultGraph URI of the default graph * @param client HTTP client * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, String defaultGraph, HttpClient client) { return sparqlService(service, query, defaultGraph, client, null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @param defaultGraphURIs List of URIs to make up the default graph * @param namedGraphURIs List of URIs to make up the named graphs * @param client HTTP client * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, List<String> defaultGraphURIs, List<String> namedGraphURIs, HttpClient client) { return sparqlService(service, query, defaultGraphURIs, namedGraphURIs, client, null) ; }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query to execute * @param defaultGraphURIs List of URIs to make up the default graph * @param namedGraphURIs List of URIs to make up the named graphs * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query, List<String> defaultGraphURIs, List<String> namedGraphURIs) { return sparqlService(service, query, defaultGraphURIs, namedGraphURIs, null, null) ; }
static public QueryExecution sparqlService(String service, String query, HttpClient client) { return sparqlService(service, query, client, null); } /** Create a QueryExecution that will access a SPARQL service over HTTP
/*package*/ static void query(String URL, String query, Consumer<QueryExecution> body) { try (QueryExecution qExec = QueryExecutionFactory.sparqlService(URL, query) ) { body.accept(qExec); } } }
/*package*/ static void query(String URL, String query, Consumer<QueryExecution> body) { try (QueryExecution qExec = QueryExecutionFactory.sparqlService(URL, query) ) { body.accept(qExec); } } }
/*package*/ static void query(String URL, String query, Consumer<QueryExecution> body) { try (QueryExecution qExec = QueryExecutionFactory.sparqlService(URL, query) ) { body.accept(qExec); } } }
private boolean execAsk(String queryStr) { Query askQuery = QueryFactory.create(queryStr); try (QueryExecution qe = QueryExecutionFactory.sparqlService(endpointURI, askQuery)) { return qe.execAsk(); } }
public void sparqlConstructQuery(String queryStr, Model model) throws RDFServiceException { Query query = createQuery(queryStr); QueryExecution qe = QueryExecutionFactory.sparqlService(readEndpointURI, query); try { qe.execConstruct(model); } catch (Exception e) { log.error("Error executing CONSTRUCT against remote endpoint: " + queryStr); } finally { qe.close(); } }
/** Create a QueryExecution that will access a SPARQL service over HTTP * @param service URL of the remote service * @param query Query string to execute * @param client HTTP client * @param httpContext HTTP Context * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, HttpClient client, HttpContext httpContext) { checkNotNull(service, "URL for service is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), client) ; }
/** * query a SPARQL endpoint with a given ASK query */ public boolean askTripleStore(String sparqlQuery, String endpoint) { logger.debug("askTripleStore on {} execute {}", endpoint, sparqlQuery); long start = getTime(); Query query = QueryFactory.create(sparqlQuery); QueryExecution qExe = QueryExecutionFactory.sparqlService(endpoint, query); boolean b = qExe.execAsk(); this.logTime(getTime() - start, "askFromTripleStore: " + sparqlQuery); return b; }
@Override public Integer call() throws Exception{ String query = "SELECT DISTINCT (count(?s) AS ?count) { { ?s ?p ?o . } UNION { GRAPH ?g { ?s ?p ?o .} } }"; QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(sparqlEndPoint,query); int size = qe.execSelect().next().get("count").asLiteral().getInt(); return size; } });
public Model retrieveModel(String graphName) { String queryTemplate = "CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o } . }"; ParameterizedSparqlString pps = new ParameterizedSparqlString(); pps.setCommandText(queryTemplate); pps.setIri("g", graphName); Query query = QueryFactory.create(pps.toString()); QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, query); Model model = qexec.execConstruct(); return model; }