Search in sources :

Example 21 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class SesameGraph method addStatement.

public void addStatement(Resource subject, RDFProperty predicate, String object) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
    URI sesameNativePredicate = getSesameNativeProperty(predicate);
    try {
        conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.STRING), contextResource);
    } catch (RepositoryException e) {
        throw new ShineRuntimeException("Could not add statement << [" + subject + "] [" + predicate + "] [" + object + "] >>", e);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) URI(org.openrdf.model.URI)

Example 22 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException 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);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailQuery(org.openrdf.repository.sail.SailQuery) Query(org.openrdf.query.Query) TupleQuery(org.openrdf.query.TupleQuery) BooleanQuery(org.openrdf.query.BooleanQuery) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException) MalformedQueryException(org.openrdf.query.MalformedQueryException) MalformedSPARQLException(com.thoughtworks.studios.shine.semweb.MalformedSPARQLException) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) TupleQueryResultHandlerException(org.openrdf.query.TupleQueryResultHandlerException) MoreThanOneResultFoundException(com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException) MalformedSPARQLException(com.thoughtworks.studios.shine.semweb.MalformedSPARQLException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) OpenRDFException(org.openrdf.OpenRDFException) NoSuchElementException(java.util.NoSuchElementException) MalformedQueryException(org.openrdf.query.MalformedQueryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)

Example 23 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class SesameGraph method select.

public List<BoundVariables> select(String sparqlSelect) {
    List<BoundVariables> results = new LinkedList<>();
    TupleQueryResult tupleQueryResult = getTupleQueryResult(sparqlSelect);
    try {
        while (tupleQueryResult.hasNext()) {
            results.add(new SesameBoundVariables(tupleQueryResult.getBindingNames(), tupleQueryResult.next()));
        }
    } catch (QueryEvaluationException e) {
        throw new ShineRuntimeException(e);
    }
    return results;
}
Also used : BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) TupleQueryResult(org.openrdf.query.TupleQueryResult) LinkedList(java.util.LinkedList)

Aggregations

ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)23 RepositoryException (org.openrdf.repository.RepositoryException)16 URI (org.openrdf.model.URI)8 IOException (java.io.IOException)7 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)7 MoreThanOneResultFoundException (com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException)6 Graph (com.thoughtworks.studios.shine.semweb.Graph)5 MalformedSPARQLException (com.thoughtworks.studios.shine.semweb.MalformedSPARQLException)5 UnsupportedSPARQLStatementException (com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)5 NoSuchElementException (java.util.NoSuchElementException)5 OpenRDFException (org.openrdf.OpenRDFException)5 MalformedQueryException (org.openrdf.query.MalformedQueryException)5 TupleQueryResultHandlerException (org.openrdf.query.TupleQueryResultHandlerException)5 RDFHandlerException (org.openrdf.rio.RDFHandlerException)5 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)3 BooleanQuery (org.openrdf.query.BooleanQuery)3 TupleQuery (org.openrdf.query.TupleQuery)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)2 Transformer (javax.xml.transform.Transformer)2 TransformerException (javax.xml.transform.TransformerException)2