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();
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations