/** 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); }
/** 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, (HttpAuthenticator)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 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 * @return QueryExecution */ static public QueryExecution sparqlService(String service, Query query) { return sparqlService(service, query, (HttpAuthenticator)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); }
@Override public QueryResultTable sparqlSelect(String url, String queryString) { log.debug("Query " + queryString); QueryExecution qe = QueryExecutionFactory.sparqlService(url, queryString); return new QueryResultTableImpl(qe); }
/** * Returns the {@link QueryExecution} associated with the given query. * * @param query the SPARQL query. * @return the {@link QueryExecution} associated with the given query. */ QueryExecution execution(final String query) { return QueryExecutionFactory.sparqlService( sparqlEndpoint, QueryFactory.create(QueryFactory.create(query))); }
/** * Query a given KBox endpoint. * * @param sparql a valid SPARQL query. * @param address the ServerAddress of the service that will be queried. * @return an ResultSet containing the elements retrieved by the given SPARQL query. */ public static ResultSet queryService(String sparql, ServerAddress address) { QueryExecution qe = QueryExecutionFactory.sparqlService( address.getQueryURL(), sparql); ResultSet results = qe.execSelect(); return results; } }
@Override public void run() { try{ System.out.println("Offset: "+ currentOffset); logger.info("next offset {}, size {}", currentOffset, endpointSize); String query = "SELECT DISTINCT * { ?s ?p ?o . } ORDER BY ASC(?s) LIMIT 10000 OFFSET " + currentOffset; QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(sparqlEndPoint, query); qe.addParam("timeout","20000"); ResultSet rs = qe.execSelect(); while(rs.hasNext()){ sparqlIterator.add(rs.next()); } } catch (Exception e){ logger.error("Error parsing SPARQL Endpoint {}. Error message {}", sparqlEndPoint, e.getMessage()); throw e; } } };
/** 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) { checkNotNull(service, "URL for service is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query)) ; }
/** 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 authenticator HTTP Authenticator * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, HttpAuthenticator authenticator) { checkNotNull(service, "URL for service is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), authenticator) ; }
private boolean execAsk(String queryStr) { Query askQuery = QueryFactory.create(queryStr); QueryExecution qe = QueryExecutionFactory.sparqlService(endpointURI, askQuery); try { return qe.execAsk(); } 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 defaultGraph URI of the default graph * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, String defaultGraph) { checkNotNull(service, "URL for service is null") ; //checkNotNull(defaultGraph, "IRI for default graph is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), defaultGraph) ; }
@Override public QueryExecution getQueryExecution() throws IOException, DataServiceFault { return QueryExecutionFactory.sparqlService(this.getConfig().getSparqlEndpoint(), this.getQuery()); }
/** 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 authenticator HTTP Authenticator * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, String defaultGraph, HttpAuthenticator authenticator) { checkNotNull(service, "URL for service is null") ; //checkNotNull(defaultGraph, "IRI for default graph is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), defaultGraph, authenticator) ; }
/** 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) { checkNotNull(service, "URL for service is null") ; //checkNotNull(defaultGraphURIs, "List of default graph URIs is null") ; //checkNotNull(namedGraphURIs, "List of named graph URIs is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), defaultGraphURIs, namedGraphURIs) ; }
/** 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 authenticator HTTP Authenticator * @return QueryExecution */ static public QueryExecution sparqlService(String service, String query, List<String> defaultGraphURIs, List<String> namedGraphURIs, HttpAuthenticator authenticator) { checkNotNull(service, "URL for service is null") ; //checkNotNull(defaultGraphURIs, "List of default graph URIs is null") ; //checkNotNull(namedGraphURIs, "List of named graph URIs is null") ; checkArg(query) ; return sparqlService(service, QueryFactory.create(query), defaultGraphURIs, namedGraphURIs, authenticator) ; }
@Override protected QueryExecution getQueryExecution(final Query query) { // cast to QueryEngineHTTP to allow us to set the basic http auth credentials and // default graph URI final QueryEngineHTTP qe = (QueryEngineHTTP)QueryExecutionFactory.sparqlService( repoConfig.getFullRepositoryUrl( RepositoryLocale.SPARQL_URL ), query ); if ( repoConfig.getSearchUsername() != null && repoConfig.getSearchPassword() != null ) { qe.setBasicAuthentication( repoConfig.getSearchUsername(), repoConfig.getSearchPassword().toCharArray() ); qe.addDefaultGraph( RepositoryHttpConfig.PUBLISHED_NG ); } return qe; }
@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; } });