Search in sources :

Example 6 with SparqlQueryException

use of uk.ac.ebi.spot.goci.sparql.exception.SparqlQueryException in project goci by EBISPOT.

the class SparqlTemplate method ask.

public boolean ask(String sparql) {
    sparql = getPrefixString().concat(sparql);
    if (askCache.containsKey(sparql)) {
        return askCache.get(sparql);
    }
    Graph g = getJenaQueryExecutionService().getDefaultGraph();
    Query q1 = QueryFactory.create(sparql, Syntax.syntaxARQ);
    QueryExecution execute = null;
    try {
        execute = getJenaQueryExecutionService().getQueryExecution(g, q1, false);
        boolean result = execute.execAsk();
        askCache.put(sparql, result);
        return result;
    } catch (LodeException e) {
        throw new SparqlQueryException("Failed to execute ask '" + sparql + "'", e);
    } finally {
        if (execute != null) {
            execute.close();
            if (g != null) {
                g.close();
            }
        }
    }
}
Also used : Graph(com.hp.hpl.jena.graph.Graph) Query(com.hp.hpl.jena.query.Query) LodeException(uk.ac.ebi.fgpt.lode.exception.LodeException) SparqlQueryException(uk.ac.ebi.spot.goci.sparql.exception.SparqlQueryException) QueryExecution(com.hp.hpl.jena.query.QueryExecution)

Aggregations

SparqlQueryException (uk.ac.ebi.spot.goci.sparql.exception.SparqlQueryException)6 ResultSet (com.hp.hpl.jena.query.ResultSet)4 Graph (com.hp.hpl.jena.graph.Graph)3 ParameterizedSparqlString (com.hp.hpl.jena.query.ParameterizedSparqlString)3 Query (com.hp.hpl.jena.query.Query)3 QueryExecution (com.hp.hpl.jena.query.QueryExecution)3 URI (java.net.URI)3 LodeException (uk.ac.ebi.fgpt.lode.exception.LodeException)3 QuerySolution (com.hp.hpl.jena.query.QuerySolution)2 DataIntegrityViolationException (uk.ac.ebi.spot.goci.pussycat.exception.DataIntegrityViolationException)2 QuerySolutionMap (com.hp.hpl.jena.query.QuerySolutionMap)1 RDFNode (com.hp.hpl.jena.rdf.model.RDFNode)1 ResourceImpl (com.hp.hpl.jena.rdf.model.impl.ResourceImpl)1 ArrayList (java.util.ArrayList)1 NoRenderableDataException (uk.ac.ebi.spot.goci.pussycat.exception.NoRenderableDataException)1 PussycatSessionNotReadyException (uk.ac.ebi.spot.goci.pussycat.exception.PussycatSessionNotReadyException)1 Filter (uk.ac.ebi.spot.goci.pussycat.lang.Filter)1 SparqlAssociationRenderlet (uk.ac.ebi.spot.goci.sparql.pussycat.renderlet.SparqlAssociationRenderlet)1 SparqlTraitRenderlet (uk.ac.ebi.spot.goci.sparql.pussycat.renderlet.SparqlTraitRenderlet)1