use of org.apache.jena.query.QueryExecException in project jena by apache.
the class QueryIterAssign method accept.
@Override
public Binding accept(Binding binding) {
BindingMap b = BindingFactory.create(binding);
for (Var v : exprs.getVars()) {
// if "binding", not "b" used, we get (Lisp) "let"
// semantics, not the desired "let*" semantics
Node n = exprs.get(v, b, getExecContext());
if (n == null)
// Expression failed to evaluate - no assignment
continue;
// Check is already has a value; if so, must be sameValueAs
if (b.contains(v)) {
// Optimization may linearize to push a stream through an (extend).
if (false && mustBeNewVar)
throw new QueryExecException("Already set: " + v);
Node n2 = b.get(v);
if (!n2.sameValueAs(n))
// Error in single assignment.
return null;
continue;
}
b.add(v, n);
}
return b;
}
use of org.apache.jena.query.QueryExecException in project jena by apache.
the class QueryEngineBase method prepareDataset.
private DatasetGraph prepareDataset(DatasetGraph originalDataset, Query query) {
DatasetDescription dsDesc = DatasetDescription.create(query, context);
DatasetGraph dsg = originalDataset;
if (dsg != null) {
if (dsDesc != null) {
if (query.hasDatasetDescription())
dsg = dynamicDataset(dsDesc, dsg, false);
}
return dsg;
}
// No DatasetGraph
if (!query.hasDatasetDescription())
throw new QueryExecException("No dataset and no dataset description for query");
// DatasetDescription : Build it.
String baseURI = query.getBaseURI();
if (baseURI == null)
baseURI = IRIs.getSystemBase().str();
dsg = DatasetUtils.createDatasetGraph(dsDesc, baseURI);
return dsg;
}
use of org.apache.jena.query.QueryExecException in project jena by apache.
the class QueryExecDataset method constructQuads.
// -- Construct Quads
@Override
public Iterator<Quad> constructQuads() {
checkNotClosed();
if (!query.isConstructType())
throw new QueryExecException("Attempt to get a CONSTRUCT model from a " + labelForQuery(query) + " query");
// This causes there to be no PROJECT around the pattern.
// That in turn, exposes the initial bindings.
query.setQueryResultStar(true);
startQueryIterator();
Template template = query.getConstructTemplate();
return TemplateLib.calcQuads(template.getQuads(), queryIterator);
}
use of org.apache.jena.query.QueryExecException in project jena by apache.
the class QueryExecDataset method constructTriples.
@Override
public Iterator<Triple> constructTriples() {
checkNotClosed();
if (!query.isConstructType())
throw new QueryExecException("Attempt to get a CONSTRUCT model from a " + labelForQuery(query) + " query");
// This causes there to be no PROJECT around the pattern.
// That in turn, exposes the initial bindings.
query.setQueryResultStar(true);
startQueryIterator();
Template template = query.getConstructTemplate();
return TemplateLib.calcTriples(template.getTriples(), queryIterator);
}
use of org.apache.jena.query.QueryExecException in project jena by apache.
the class QueryExecDataset method ask.
@Override
public boolean ask() {
checkNotClosed();
if (!query.isAskType())
throw new QueryExecException("Attempt to have boolean from a " + labelForQuery(query) + " query");
startQueryIterator();
boolean r;
try {
// Not hasNext because setting timeout1 which applies to getting
// the first result, not testing for it.
queryIterator.next();
r = true;
} catch (NoSuchElementException ex) {
r = false;
} finally {
this.close();
}
return r;
}
Aggregations