@Override public synchronized void removeStatements( Resource subj, URI pred, Value obj, Resource... contexts) throws SailException { if (sail.isArchiving()) { CloseableIteration<? extends Statement, SailException> stmts; stmts = super.getStatements(subj, pred, obj, false, contexts); try { while (stmts.hasNext()) { Statement st = stmts.next(); Resource s = st.getSubject(); URI p = st.getPredicate(); Value o = st.getObject(); Resource ctx = st.getContext(); removeRevision(s, p); if (ctx instanceof URI && !ctx.equals(trx)) { if (modified.add(ctx)) { super.addStatement(getTrx(), MODIFIED, ctx, getTrx()); } BNode node = vf.createBNode(); super.addStatement(ctx, CONTAINED, node, getTrx()); super.addStatement(node, RDF.SUBJECT, s, getTrx()); super.addStatement(node, RDF.PREDICATE, p, getTrx()); super.addStatement(node, RDF.OBJECT, o, getTrx()); } } } finally { stmts.close(); } super.removeStatements(subj, pred, obj, contexts); } else { if (sail.getMaxArchive() > 0 && arch.size() <= sail.getMaxArchive()) { CloseableIteration<? extends Statement, SailException> stmts; stmts = super.getStatements(subj, pred, obj, false, contexts); try { int maxArchive = sail.getMaxArchive(); while (stmts.hasNext() && arch.size() <= maxArchive) { Statement st = stmts.next(); Resource ctx = st.getContext(); if (ctx instanceof URI && !ctx.equals(trx)) { arch.add(st); } } } finally { stmts.close(); } } super.removeStatements(subj, pred, obj, contexts); removeRevision(subj, pred); if (contexts != null && contexts.length > 0) { for (Resource ctx : contexts) { if (ctx != null && modified.add(ctx)) { addMetadata(currentTrx, MODIFIED, ctx, currentTrx); } } } } }
private void removeAllRevisions(Resource subj) throws SailException { CloseableIteration<? extends Statement, SailException> stmts; Resource s = getContainerURI(subj); stmts = super.getStatements(s, REVISION, null, true); try { while (stmts.hasNext()) { Statement st = stmts.next(); Value ctx = st.getObject(); if (ctx instanceof URI && modified.add((URI) ctx)) { addMetadata(getTrx(), MODIFIED, ctx, getTrx()); } super.removeStatements(s, REVISION, ctx); } } finally { stmts.close(); } }
private boolean removeRevision(Resource subj, URI pred) throws SailException { if (subj instanceof URI) { Resource h = getContainerURI(subj); if (revised.containsKey(h)) return false; revised.put(h, Boolean.TRUE); if (pred != null && !REVISION.equals(pred)) { removeAllRevisions(subj); addMetadata(h, REVISION, currentTrx, currentTrx); } else { URI uri = (URI) subj; String ns = uri.getNamespace(); if (ns.charAt(ns.length() - 1) != '#') { if (trx != null) { super.removeStatements(subj, REVISION, trx, trx); } revised.put(subj, Boolean.FALSE); } } addMetadata(currentTrx, CONTRIBUTED, h, currentTrx); return true; } return false; }
private void removeInformingGraph( URI activity, URI entity, Resource subj, URI pred, Value obj, Resource ctx) throws SailException { reify(activity, entity, subj, pred, obj, ctx); super.removeStatements(subj, pred, obj, ctx); }