Search in sources :

Example 1 with GraphUtilException

use of org.eclipse.rdf4j.model.util.GraphUtilException in project rdf4j by eclipse.

the class DAWGTestResultSetParser method endRDF.

@Override
public void endRDF() throws RDFHandlerException {
    try {
        Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET);
        List<String> bindingNames = getBindingNames(resultSetNode);
        tqrHandler.startQueryResult(bindingNames);
        Iterator<Value> solIter = GraphUtil.getObjectIterator(graph, resultSetNode, SOLUTION);
        while (solIter.hasNext()) {
            Value solutionNode = solIter.next();
            if (solutionNode instanceof Resource) {
                reportSolution((Resource) solutionNode, bindingNames);
            } else {
                throw new RDFHandlerException("Value for " + SOLUTION + " is not a resource: " + solutionNode);
            }
        }
        tqrHandler.endQueryResult();
    } catch (GraphUtilException e) {
        throw new RDFHandlerException(e.getMessage(), e);
    } catch (TupleQueryResultHandlerException e) {
        throw new RDFHandlerException(e.getMessage(), e);
    }
}
Also used : RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) Resource(org.eclipse.rdf4j.model.Resource) Value(org.eclipse.rdf4j.model.Value) GraphUtilException(org.eclipse.rdf4j.model.util.GraphUtilException)

Example 2 with GraphUtilException

use of org.eclipse.rdf4j.model.util.GraphUtilException in project rdf4j by eclipse.

the class DAWGTestBooleanParser method endRDF.

@Override
public void endRDF() throws RDFHandlerException {
    try {
        Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET);
        Literal booleanLit = GraphUtil.getUniqueObjectLiteral(graph, resultSetNode, BOOLEAN);
        if (booleanLit.equals(DAWGTestResultSetSchema.TRUE)) {
            value = true;
        } else if (booleanLit.equals(DAWGTestResultSetSchema.FALSE)) {
            value = false;
        } else {
            throw new RDFHandlerException("Invalid boolean value: " + booleanLit);
        }
    } catch (GraphUtilException e) {
        throw new RDFHandlerException(e.getMessage(), e);
    }
}
Also used : RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) Literal(org.eclipse.rdf4j.model.Literal) Resource(org.eclipse.rdf4j.model.Resource) GraphUtilException(org.eclipse.rdf4j.model.util.GraphUtilException)

Aggregations

Resource (org.eclipse.rdf4j.model.Resource)2 GraphUtilException (org.eclipse.rdf4j.model.util.GraphUtilException)2 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)2 Literal (org.eclipse.rdf4j.model.Literal)1 Value (org.eclipse.rdf4j.model.Value)1 TupleQueryResultHandlerException (org.eclipse.rdf4j.query.TupleQueryResultHandlerException)1