use of org.eclipse.rdf4j.repository.event.RepositoryConnectionListener in project rdf4j by eclipse.
the class NotifyingRepositoryConnectionWrapper method setAutoCommit.
@Override
@Deprecated
public void setAutoCommit(boolean autoCommit) throws RepositoryException {
boolean wasAutoCommit = isAutoCommit();
getDelegate().setAutoCommit(autoCommit);
if (activated && wasAutoCommit != autoCommit) {
for (RepositoryConnectionListener listener : listeners) {
listener.setAutoCommit(getDelegate(), autoCommit);
}
if (autoCommit) {
for (RepositoryConnectionListener listener : listeners) {
listener.commit(getDelegate());
}
}
}
}
use of org.eclipse.rdf4j.repository.event.RepositoryConnectionListener in project rdf4j by eclipse.
the class NotifyingRepositoryConnectionWrapper method clearNamespaces.
@Override
public void clearNamespaces() throws RepositoryException {
if (activated && reportDeltas()) {
RepositoryResult<Namespace> namespaces;
namespaces = getDelegate().getNamespaces();
List<String> prefix = new ArrayList<String>();
try {
while (namespaces.hasNext()) {
Namespace ns = namespaces.next();
prefix.add(ns.getPrefix());
}
} finally {
namespaces.close();
}
getDelegate().clearNamespaces();
for (String p : prefix) {
removeNamespace(p);
}
} else if (activated) {
getDelegate().clearNamespaces();
for (RepositoryConnectionListener listener : listeners) {
listener.clearNamespaces(getDelegate());
}
} else {
getDelegate().clearNamespaces();
}
}
use of org.eclipse.rdf4j.repository.event.RepositoryConnectionListener 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.repository.event.RepositoryConnectionListener in project rdf4j by eclipse.
the class NotifyingRepositoryWrapper method getConnection.
@Override
public NotifyingRepositoryConnection getConnection() throws RepositoryException {
RepositoryConnection con = getDelegate().getConnection();
NotifyingRepositoryConnection ncon = new NotifyingRepositoryConnectionWrapper(this, con, getDefaultReportDeltas());
if (activated) {
for (RepositoryListener listener : listeners) {
listener.getConnection(this, ncon);
}
}
for (RepositoryConnectionListener l : conListeners) {
ncon.addRepositoryConnectionListener(l);
}
return ncon;
}
use of org.eclipse.rdf4j.repository.event.RepositoryConnectionListener in project rdf4j by eclipse.
the class NotifyingRepositoryConnectionWrapper method addWithoutCommit.
@Override
public void addWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
boolean reportEvent = activated;
if (reportEvent && reportDeltas()) {
// Only report if the statement is not present yet
reportEvent = !getDelegate().hasStatement(subject, predicate, object, false, contexts);
}
getDelegate().add(subject, predicate, object, contexts);
if (reportEvent) {
for (RepositoryConnectionListener listener : listeners) {
listener.add(getDelegate(), subject, predicate, object, contexts);
}
}
}
Aggregations