Search in sources :

Example 21 with RepositoryException

use of org.openrdf.repository.RepositoryException 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 22 with RepositoryException

use of org.openrdf.repository.RepositoryException 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 23 with RepositoryException

use of org.openrdf.repository.RepositoryException in project gocd by gocd.

the class InMemoryRepositoryFactory method emptyRepository.

public static Repository emptyRepository() {
    try {
        Repository repo = new SailRepository(new MemoryStore());
        repo.initialize();
        return repo;
    } catch (RepositoryException ex) {
        throw new ShineRuntimeException(ex);
    }
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailRepository(org.openrdf.repository.sail.SailRepository) RepositoryException(org.openrdf.repository.RepositoryException)

Example 24 with RepositoryException

use of org.openrdf.repository.RepositoryException 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)

Example 25 with RepositoryException

use of org.openrdf.repository.RepositoryException 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)

Aggregations

RepositoryException (org.openrdf.repository.RepositoryException)36 RepositoryConnection (org.openrdf.repository.RepositoryConnection)20 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)12 URI (org.openrdf.model.URI)12 YardException (org.apache.stanbol.entityhub.servicesapi.yard.YardException)10 Test (org.junit.Test)7 RdfRepresentation (org.apache.stanbol.entityhub.model.sesame.RdfRepresentation)5 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)5 IOException (java.io.IOException)4 Value (org.openrdf.model.Value)4 Repository (org.openrdf.repository.Repository)4 InputStreamReader (java.io.InputStreamReader)3 SparqlFieldQuery (org.apache.stanbol.entityhub.query.sparql.SparqlFieldQuery)3 BindingSet (org.openrdf.query.BindingSet)3 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)3 TupleQueryResult (org.openrdf.query.TupleQueryResult)3 SailRepository (org.openrdf.repository.sail.SailRepository)3 Graph (com.thoughtworks.studios.shine.semweb.Graph)2 RdfValueFactory (org.apache.stanbol.entityhub.model.sesame.RdfValueFactory)2 Model (org.openrdf.model.Model)2