}
@Override
public void update(DiffReader diff) throws ModelRuntimeException {
if(this.isLocked()) {
throw new ModelRuntimeException("ModelSet is locked, cannot perform an update.");
}
// do not auto-commit
this.assertModel();
try {
this.connection.begin();
try {
try {
// remove
Iterator<? extends Statement> it = diff.getRemoved().iterator();
while(it.hasNext()) {
org.openrdf.model.Statement s = ConversionUtil.toOpenRDF(it.next(),
this.valueFactory);
this.connection.remove(s, s.getContext());
}
// add
it = diff.getAdded().iterator();
while(it.hasNext()) {
org.openrdf.model.Statement s = ConversionUtil.toOpenRDF(it.next(),
this.valueFactory);
this.connection.add(s, s.getContext());
}
this.connection.commit();
} catch(RepositoryException x) {
this.connection.rollback();
}
} finally {
this.connection.commit();
}
} catch(RepositoryException x) {
throw new ModelRuntimeException(x);
}
}