Search in sources :

Example 11 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, Resource tripleObject) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
    URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
    AbstractSesameResource sesameObject = (AbstractSesameResource) tripleObject;
    try {
        conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, sesameObject.getSesameNativeResource(), 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 12 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, Integer object) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
    URI sesameNativePredicate = getSesameNativeProperty(predicate);
    try {
        conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.INTEGER), 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 13 with ShineRuntimeException

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

the class SesameGraph method renderSPARQLResultsAsXML.

public void renderSPARQLResultsAsXML(String sparql, OutputStream stream) {
    try {
        Query query = conn.prepareQuery(QueryLanguage.SPARQL, sparql);
        contextualize(query);
        if (query instanceof TupleQuery) {
            renderTupleQuery(query, new SPARQLResultsXMLWriter(stream));
        } else {
            renderBooleanQuery(query, new SPARQLBooleanXMLWriter(stream));
        }
        stream.flush();
    } catch (UnsupportedSPARQLStatementException e) {
        throw e;
    } catch (Exception e) {
        throw new ShineRuntimeException("Could not render sparql results as XML: <<" + sparql + ">>", e);
    }
}
Also used : SPARQLResultsXMLWriter(org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter) 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) SPARQLBooleanXMLWriter(org.openrdf.query.resultio.sparqlxml.SPARQLBooleanXMLWriter) 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 14 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, Boolean object) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
    URI sesameNativePredicate = getSesameNativeProperty(predicate);
    try {
        conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(String.valueOf(object), XMLSchema.BOOLEAN), 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 15 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, Resource object) {
    AbstractSesameResource sesameSubject = (AbstractSesameResource) subject;
    URI sesameNativePredicate = getSesameNativeProperty(predicate);
    AbstractSesameResource sesameObject = (AbstractSesameResource) object;
    try {
        conn.add(sesameSubject.getSesameNativeResource(), sesameNativePredicate, sesameObject.getSesameNativeResource(), 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)

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