Search in sources :

Example 16 with ShineRuntimeException

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

the class SesameGraph method remove.

public void remove(Resource tripleSubject, RDFProperty triplePredicate, String tripleObject) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
    URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
    try {
        conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(tripleObject, XMLSchema.STRING), contextResource);
    } catch (RepositoryException e) {
        throw new ShineRuntimeException(e);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) URI(org.openrdf.model.URI)

Example 17 with ShineRuntimeException

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

the class SesameGraph method createTempGraph.

public Graph createTempGraph() {
    try {
        if (!conn.isOpen()) {
            throw new IllegalStateException("Cannot create a temp graph on a closed graph!");
        }
        Repository inMemRepos = InMemoryRepositoryFactory.emptyRepository();
        String contextURI = null;
        if (contextResource.length > 0) {
            contextURI = contextResource[0].stringValue();
        }
        Graph tempGraph = new SesameGraph(inMemRepos.getConnection(), contextURI);
        tempGraphs.add(tempGraph);
        return tempGraph;
    } catch (RepositoryException ex) {
        throw new ShineRuntimeException("Unable to create temp graph!", ex);
    }
}
Also used : Repository(org.openrdf.repository.Repository) Graph(com.thoughtworks.studios.shine.semweb.Graph) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException)

Example 18 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException 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);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException) TupleQuery(org.openrdf.query.TupleQuery) 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 19 with ShineRuntimeException

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

the class SesameGraph method remove.

public void remove(Resource tripleSubject, RDFProperty triplePredicate, Integer integer) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
    URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
    try {
        conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(integer), XMLSchema.INTEGER), contextResource);
    } catch (RepositoryException e) {
        throw new ShineRuntimeException(e);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) URI(org.openrdf.model.URI)

Example 20 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException 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);
    }
}
Also used : BooleanQuery(org.openrdf.query.BooleanQuery) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException) 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)

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