use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.
the class NotifyingRepositoryConnectionWrapper method removeWithoutCommit.
@Override
public void removeWithoutCommit(Resource subj, IRI pred, Value obj, Resource... ctx) throws RepositoryException {
if (activated && reportDeltas()) {
RepositoryResult<Statement> stmts;
stmts = getDelegate().getStatements(subj, pred, obj, false, ctx);
List<Statement> list = new ArrayList<Statement>();
try {
while (stmts.hasNext()) {
list.add(stmts.next());
}
} finally {
stmts.close();
}
getDelegate().remove(subj, pred, obj, ctx);
for (RepositoryConnectionListener listener : listeners) {
for (Statement stmt : list) {
Resource s = stmt.getSubject();
IRI p = stmt.getPredicate();
Value o = stmt.getObject();
Resource c = stmt.getContext();
listener.remove(getDelegate(), s, p, o, c);
}
}
} else if (activated) {
getDelegate().remove(subj, pred, obj, ctx);
for (RepositoryConnectionListener listener : listeners) {
listener.remove(getDelegate(), subj, pred, obj, ctx);
}
} else {
getDelegate().remove(subj, pred, obj, ctx);
}
}
use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.
the class AbstractRepositoryConnection method remove.
@Override
public void remove(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException {
OpenRDFUtil.verifyContextNotNull(contexts);
boolean localTransaction = startLocalTransaction();
try {
for (Statement st : statements) {
remove(st, contexts);
}
conditionalCommit(localTransaction);
} catch (RepositoryException e) {
conditionalRollback(localTransaction);
throw e;
} catch (RuntimeException e) {
conditionalRollback(localTransaction);
throw e;
}
}
use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.
the class RepositoryConfigUtil method getRepositoryConfig.
public static RepositoryConfig getRepositoryConfig(Model model, String repositoryID) {
Statement idStatement = getIDStatement(model, repositoryID);
if (idStatement == null) {
// No such config
return null;
}
Resource repositoryNode = idStatement.getSubject();
Resource context = idStatement.getContext();
Model contextGraph = model.filter(null, null, null, context);
return RepositoryConfig.create(contextGraph, repositoryNode);
}
use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.
the class RepositoryConfigUtil method getContext.
@Deprecated
public static Resource getContext(RepositoryConnection con, String repositoryID) throws RepositoryException, RepositoryConfigException {
Resource context = null;
Statement idStatement = getIDStatement(con, repositoryID);
if (idStatement != null) {
context = idStatement.getContext();
}
return context;
}
use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.
the class TurtleHandlingTest method writeTurtle.
/**
* Helper method to write the given model to Turtle and return an InputStream containing the results.
*
* @param statements
* @return An {@link InputStream} containing the results.
* @throws RDFHandlerException
*/
private InputStream writeTurtle(Model statements) throws RDFHandlerException {
StringWriter writer = new StringWriter();
RDFWriter turtleWriter = new TurtleWriter(writer);
turtleWriter.startRDF();
for (Statement nextStatement : statements) {
turtleWriter.handleStatement(nextStatement);
}
turtleWriter.endRDF();
return new ByteArrayInputStream(writer.toString().getBytes(Charset.forName("UTF-8")));
}
Aggregations