use of org.eclipse.rdf4j.query.BooleanQuery in project rdf4j by eclipse.
the class RepositoryFederatedService method ask.
/**
* Evaluate the provided sparqlQueryString at the initialized {@link Repository} of this
* {@link FederatedService}. Insert bindings, send ask query and return final result
*/
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri) throws QueryEvaluationException {
try {
String sparqlQueryString = service.getAskQueryString();
BooleanQuery query = getConnection().prepareBooleanQuery(QueryLanguage.SPARQL, sparqlQueryString, baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
return query.evaluate();
} catch (MalformedQueryException e) {
throw new QueryEvaluationException(e);
} catch (RepositoryException e) {
throw new QueryEvaluationException("Repository for endpoint " + rep.toString() + " could not be initialized.", e);
}
}
use of org.eclipse.rdf4j.query.BooleanQuery in project rdf4j by eclipse.
the class SPARQLConnection method hasStatement.
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException {
try {
BooleanQuery query = prepareBooleanQuery(SPARQL, SOMETHING, "");
setBindings(query, subj, pred, obj, contexts);
return query.evaluate();
} catch (MalformedQueryException e) {
throw new RepositoryException(e);
} catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
Aggregations