Search in sources :

Example 41 with SailException

use of org.openrdf.sail.SailException in project blueprints by tinkerpop.

the class SailTest method testBlankNodes.

// blank nodes /////////////////////////////////////////////////////////////
@Test
public void testBlankNodes() throws Throwable {
    URI uriA = sail.getValueFactory().createURI("http://example.org/test/S_POG#a");
    URI uriB = sail.getValueFactory().createURI("http://example.org/test/S_POG#b");
    SailConnection sc = sail.getConnection();
    try {
        sc.begin();
        ValueFactory factory = sail.getValueFactory();
        BNode bNode = factory.createBNode();
        try {
            sc.addStatement(uriA, uriA, bNode);
        } catch (SailException se) {
            // FIXME: not supporting blank nodes ATM
            assertTrue(se.getCause() instanceof UnsupportedOperationException);
        }
        sc.commit();
    } finally {
        sc.rollback();
        sc.close();
    }
}
Also used : NotifyingSailConnection(org.openrdf.sail.NotifyingSailConnection) SailConnection(org.openrdf.sail.SailConnection) BNode(org.openrdf.model.BNode) ValueFactory(org.openrdf.model.ValueFactory) SailException(org.openrdf.sail.SailException) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 42 with SailException

use of org.openrdf.sail.SailException in project blueprints by tinkerpop.

the class GraphSailConnection method getStatementsInternal.

public CloseableIteration<? extends Statement, SailException> getStatementsInternal(final Resource subject, final URI predicate, final Value object, final boolean includeInferred, final Resource... contexts) throws SailException {
    int index = 0;
    if (null != subject) {
        index |= 0x1;
    }
    if (null != predicate) {
        index |= 0x2;
    }
    if (null != object) {
        index |= 0x4;
    }
    if (0 == contexts.length) {
        return createIteration(store.matchers[index].match(subject, predicate, object, null, includeInferred));
    } else {
        Collection<CloseableIteration<Statement, SailException>> iterations = new LinkedList<CloseableIteration<Statement, SailException>>();
        // TODO: as an optimization, filter on multiple contexts simultaneously (when context is not used in the matcher), rather than trying each context consecutively.
        for (Resource context : contexts) {
            index |= 0x8;
            Matcher m = store.matchers[index];
            iterations.add(createIteration(m.match(subject, predicate, object, context, includeInferred)));
        }
        return new CompoundCloseableIteration<Statement, SailException>(iterations);
    }
}
Also used : CloseableIteration(info.aduna.iteration.CloseableIteration) CompoundCloseableIteration(net.fortytwo.sesametools.CompoundCloseableIteration) CompoundCloseableIteration(net.fortytwo.sesametools.CompoundCloseableIteration) Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) SailException(org.openrdf.sail.SailException) LinkedList(java.util.LinkedList)

Example 43 with SailException

use of org.openrdf.sail.SailException in project blueprints by tinkerpop.

the class SailGraph method commit.

public void commit() {
    try {
        SailConnection sc = this.sailConnection.get();
        sc.commit();
        sc.begin();
    } catch (SailException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : SailConnection(org.openrdf.sail.SailConnection) SailException(org.openrdf.sail.SailException)

Example 44 with SailException

use of org.openrdf.sail.SailException in project blueprints by tinkerpop.

the class SailGraph method saveRDF.

/**
 * Save RDF data from the SailGraph.
 * Supported formats include rdf-xml, n-triples, turtle, n3, trix, or trig.
 *
 * @param output the OutputStream to which to write RDF data
 * @param format supported formats include rdf-xml, n-triples, turtle, n3, trix, or trig
 */
public void saveRDF(final OutputStream output, final String format) {
    try {
        this.commit();
        final SailConnection c = this.rawGraph.getConnection();
        try {
            c.begin();
            RDFWriter w = Rio.createWriter(getFormat(format), output);
            w.startRDF();
            CloseableIteration<? extends Statement, SailException> iter = c.getStatements(null, null, null, false);
            try {
                while (iter.hasNext()) {
                    w.handleStatement(iter.next());
                }
            } finally {
                iter.close();
            }
            w.endRDF();
        } finally {
            c.rollback();
            c.close();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SailConnection(org.openrdf.sail.SailConnection) RDFWriter(org.openrdf.rio.RDFWriter) SailException(org.openrdf.sail.SailException) SailException(org.openrdf.sail.SailException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RDFHandlerException(org.openrdf.rio.RDFHandlerException)

Example 45 with SailException

use of org.openrdf.sail.SailException in project blueprints by tinkerpop.

the class SailGraph method rollback.

public void rollback() {
    try {
        SailConnection sc = this.sailConnection.get();
        sc.rollback();
        sc.begin();
    } catch (SailException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : SailConnection(org.openrdf.sail.SailConnection) SailException(org.openrdf.sail.SailException)

Aggregations

SailException (org.openrdf.sail.SailException)46 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)17 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)14 RyaClientException (org.apache.rya.api.client.RyaClientException)13 SailConnection (org.openrdf.sail.SailConnection)12 AccumuloException (org.apache.accumulo.core.client.AccumuloException)11 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)11 Sail (org.openrdf.sail.Sail)11 InferenceEngineException (org.apache.rya.rdftriplestore.inference.InferenceEngineException)10 URI (org.openrdf.model.URI)10 RepositoryException (org.openrdf.repository.RepositoryException)10 MalformedQueryException (org.openrdf.query.MalformedQueryException)9 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)8 Statement (org.openrdf.model.Statement)8 SailRepository (org.openrdf.repository.sail.SailRepository)7 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)7 Resource (org.openrdf.model.Resource)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)4