use of com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException in project gocd by gocd.
the class SesameGraph method renderSPARQLResultsAsXML.
public void renderSPARQLResultsAsXML(String sparql, OutputStream stream) {
try {
Query query = conn.prepareQuery(QueryLanguage.SPARQL, sparql);
contextualize(query);
if (query instanceof TupleQuery) {
renderTupleQuery(query, new SPARQLResultsXMLWriter(stream));
} else {
renderBooleanQuery(query, new SPARQLBooleanXMLWriter(stream));
}
stream.flush();
} catch (UnsupportedSPARQLStatementException e) {
throw e;
} catch (Exception e) {
throw new ShineRuntimeException("Could not render sparql results as XML: <<" + sparql + ">>", e);
}
}
use of com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException in project gocd by gocd.
the class SesameGraph method contextualize.
private void contextualize(Query query) throws Exception {
if (contextVar == null) {
return;
}
TupleExpr tupleExpr = ((SailQuery) query).getParsedQuery().getTupleExpr();
tupleExpr.visit(new QueryModelVisitorBase() {
public void meet(StatementPattern node) throws Exception {
if (node.getContextVar() != null) {
throw new UnsupportedSPARQLStatementException("Attempted to execute a SPARQL statement with a GRAPH clause against a context aware graph.");
}
node.setContextVar(contextVar);
}
});
}
use of com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException in project gocd by gocd.
the class SesameGraph method getTupleQueryResult.
private TupleQueryResult getTupleQueryResult(String sparqlSelect) {
try {
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, sparqlSelect);
contextualize(tupleQuery);
return tupleQuery.evaluate();
} catch (UnsupportedSPARQLStatementException e) {
throw e;
} catch (Exception e) {
throw new ShineRuntimeException(e);
}
}
use of com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException in project gocd by gocd.
the class SesameGraph method getBooleanQueryResult.
private boolean getBooleanQueryResult(String sparqlSelect) {
try {
BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, sparqlSelect);
contextualize(booleanQuery);
return booleanQuery.evaluate();
} catch (UnsupportedSPARQLStatementException e) {
throw e;
} catch (Exception e) {
throw new ShineRuntimeException(e);
}
}
use of com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException in project gocd by gocd.
the class SesameGraph method validate.
public void validate(String arq) {
try {
Query query = conn.prepareQuery(QueryLanguage.SPARQL, arq);
contextualize(query);
} catch (UnsupportedSPARQLStatementException e) {
throw e;
} catch (MalformedQueryException e) {
throw new MalformedSPARQLException(e);
} catch (Exception e) {
throw new ShineRuntimeException(e);
}
}
Aggregations