Search in sources :

Example 1 with RSIterator

use of org.apache.jena.rdf.model.RSIterator in project jena by apache.

the class SecuredModelImpl method removeAllReifications.

/**
 * @sec.graph Update
 * @sec.triple Delete on every reification statement for each statement in
 *             statements.
 * @throws UpdateDeniedException
 * @throws DeleteDeniedException
 * @throws AuthenticationRequiredException if user is not authenticated and is
 *                                         required to be.
 */
@Override
public void removeAllReifications(final Statement s) throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
    checkUpdate();
    if (canDelete(new Triple(Node.ANY, RDF.subject.asNode(), wildCardNode(s.getSubject()))) && canDelete(new Triple(Node.ANY, RDF.predicate.asNode(), wildCardNode(s.getPredicate()))) && canDelete(new Triple(Node.ANY, RDF.object.asNode(), wildCardNode(s.getObject())))) {
        holder.getBaseItem().removeAllReifications(s);
    } else {
        final RSIterator iter = holder.getBaseItem().listReifiedStatements(s);
        try {
            while (iter.hasNext()) {
                final ReifiedStatement rs = iter.next();
                checkDelete(new Triple(rs.asNode(), RDF.subject.asNode(), wildCardNode(s.getSubject())));
                checkDelete(new Triple(rs.asNode(), RDF.predicate.asNode(), wildCardNode(s.getPredicate())));
                checkDelete(new Triple(rs.asNode(), RDF.object.asNode(), wildCardNode(s.getObject())));
            }
            holder.getBaseItem().removeAllReifications(s);
        } finally {
            iter.close();
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) ReifiedStatement(org.apache.jena.rdf.model.ReifiedStatement) SecuredReifiedStatement(org.apache.jena.permissions.model.SecuredReifiedStatement) RSIterator(org.apache.jena.rdf.model.RSIterator)

Example 2 with RSIterator

use of org.apache.jena.rdf.model.RSIterator in project jena by apache.

the class SecuredStatementImpl method removeReification.

/**
 * @sec.graph Update
 * @sec.triple Delete
 * @throws UpdateDeniedException
 * @throws DeleteDeniedException
 * @throws AuthenticationRequiredException if user is not authenticated and is
 *                                         required to be.
 */
@Override
public void removeReification() throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
    checkUpdate();
    if (!canDelete(Triple.ANY)) {
        StmtIterator iter = null;
        final RSIterator rsIter = holder.getBaseItem().listReifiedStatements();
        try {
            while (rsIter.hasNext()) {
                final ReifiedStatement stmt = rsIter.next();
                iter = stmt.listProperties();
                while (iter.hasNext()) {
                    final Statement s = iter.next();
                    checkDelete(s);
                }
            }
        } finally {
            rsIter.close();
            if (iter != null) {
                iter.close();
            }
        }
    }
    holder.getBaseItem().removeReification();
}
Also used : ReifiedStatement(org.apache.jena.rdf.model.ReifiedStatement) SecuredReifiedStatement(org.apache.jena.permissions.model.SecuredReifiedStatement) StmtIterator(org.apache.jena.rdf.model.StmtIterator) RSIterator(org.apache.jena.rdf.model.RSIterator) Statement(org.apache.jena.rdf.model.Statement) ReifiedStatement(org.apache.jena.rdf.model.ReifiedStatement) SecuredStatement(org.apache.jena.permissions.model.SecuredStatement) SecuredReifiedStatement(org.apache.jena.permissions.model.SecuredReifiedStatement)

Aggregations

SecuredReifiedStatement (org.apache.jena.permissions.model.SecuredReifiedStatement)2 RSIterator (org.apache.jena.rdf.model.RSIterator)2 ReifiedStatement (org.apache.jena.rdf.model.ReifiedStatement)2 Triple (org.apache.jena.graph.Triple)1 SecuredStatement (org.apache.jena.permissions.model.SecuredStatement)1 Statement (org.apache.jena.rdf.model.Statement)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1