Search in sources :

Example 1 with MoreThanOneResultFoundException

use of com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException in project gocd by gocd.

the class SesameGraph method selectFirst.

public BoundVariables selectFirst(String sparqlSelect) {
    BoundVariables boundVariables;
    TupleQueryResult tupleQueryResult = getTupleQueryResult(sparqlSelect);
    try {
        if (!tupleQueryResult.hasNext()) {
            return null;
        }
        boundVariables = new SesameBoundVariables(tupleQueryResult.getBindingNames(), tupleQueryResult.next());
        if (tupleQueryResult.hasNext()) {
            tupleQueryResult.close();
            throw new MoreThanOneResultFoundException(sparqlSelect);
        }
    } catch (QueryEvaluationException e) {
        throw new ShineRuntimeException("Could not parse query: <<" + sparqlSelect + ">>", e);
    }
    return boundVariables;
}
Also used : BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) MoreThanOneResultFoundException(com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException) TupleQueryResult(org.openrdf.query.TupleQueryResult)

Aggregations

ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)1 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)1 MoreThanOneResultFoundException (com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException)1 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)1 TupleQueryResult (org.openrdf.query.TupleQueryResult)1