/** Gets a given resource (including the #this reference) from a model. **/ public static Resource getResource(String url, Model model) { List<Resource> matchingSubjects = model.listSubjects() .filterKeep(s -> s.getURI() != null) .filterKeep(s -> s.getURI().equalsIgnoreCase(url) || s.getURI().equalsIgnoreCase(url + "#this")).toList(); if (matchingSubjects.isEmpty()) { return null; } checkState(matchingSubjects.size() == 1, "Model %s didn't contain %s", model, url); return matchingSubjects.get(0); }
@Override public ExtendedIterator<ReifiedStatement> filterKeep( final Predicate<ReifiedStatement> f ) { return iter.filterKeep(f); }
@Override public ExtendedIterator<RDFNode> filterKeep( final Predicate<RDFNode> f ) { return iter.filterKeep(f); }
/** Calculate graph.find(?, rdfs:member, ?) */ public static Iterator<Triple> rdfsMember(Graph graph, Node s, Node o) { ExtendedIterator<Triple> iter = graph.find(s, Node.ANY, o) ; return iter.filterKeep(filterRDFSmember) ; }
/** Answer an iterator over all the reification triples that this Reifier exposes (ie all if Standard, none otherwise) that match m. */ public static ExtendedIterator<Triple> findExposed(Graph graph, Triple match) { ExtendedIterator<Triple> it = graph.find(match) ; it = it.filterKeep(filterReif) ; return WrappedIterator.create(it) ; }
/** * <p>Answer an iterator over all of the classes that are declared to be equivalent classes to * this class. Each element of the iterator will be an {@link OntClass}.</p> * @return An iterator over the classes equivalent to this class. * @exception ProfileException If the {@link Profile#EQUIVALENT_CLASS()} property is not supported in the current language profile. */ @Override public ExtendedIterator<OntClass> listEquivalentClasses() { return listAs( getProfile().EQUIVALENT_CLASS(), "EQUIVALENT_CLASS", OntClass.class ).filterKeep( new UniqueFilter<OntClass>()); }
/** * <p>Answer an iterator over all of the classes that this class is declared to be disjoint with. * Each element of the iterator will be an {@link OntClass}.</p> * @return An iterator over the classes disjoint with this class. * @exception ProfileException If the {@link Profile#DISJOINT_WITH()} property is not supported in the current language profile. */ @Override public ExtendedIterator<OntClass> listDisjointWith() { return listAs( getProfile().DISJOINT_WITH(), "DISJOINT_WITH", OntClass.class ).filterKeep( new UniqueFilter<OntClass>() ) ; }
/** * Internal variant of find which omits the filters which block illegal RDF data. * @param pattern a TriplePattern to be matched against the data */ public ExtendedIterator<Triple> findFull(TriplePattern pattern) { checkOpen(); this.requirePrepared(); return bEngine.find(pattern).filterKeep( new UniqueFilter<Triple>()); }
private ExtendedIterator<RDFList> getSecuredRDFListIterator( final Set<Action> perm) { return WrappedIterator .create(new RDFListIterator(holder.getBaseItem())).filterKeep( new RDFListSecFilter<>(this, perm)); }
@Override public ExtendedIterator<Triple> find(final Node s, final Node p, final Node o) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Triple> retval = holder.getBaseItem().find(s, p, o); if (!canRead(Triple.ANY)) { retval = retval.filterKeep(new PermTripleFilter(Action.Read, this)); } return retval; }
@Override public ExtendedIterator<Triple> find(final Triple m) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Triple> retval = holder.getBaseItem().find(m); if (!canRead(Triple.ANY)) { retval = retval.filterKeep(new PermTripleFilter(Action.Read, this)); } return retval; }
protected ExtendedIterator<Statement> getStatementIterator(final Action perm) { return holder.getBaseItem().listProperties() .filterKeep(new ContainerFilter()) .filterKeep(new PermStatementFilter(perm, this)); }
@Override public SecuredResIterator listSubjectsWithProperty(final Property p, final RDFNode o) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Resource> rIter = holder.getBaseItem().listSubjectsWithProperty(p, o); if (!canRead(Triple.ANY)) { rIter = rIter.filterKeep(new ResourceFilter(p, o)); } return new SecuredResIterator(holder.getSecuredItem(), rIter); }
@Override public SecuredNodeIterator<RDFNode> listObjects() throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<RDFNode> nIter = holder.getBaseItem().listObjects(); if (!canRead(Triple.ANY)) { nIter = nIter.filterKeep(new ObjectFilter()); } return new SecuredNodeIterator<>(holder.getSecuredItem(), nIter); }
@Override public SecuredNodeIterator<RDFNode> listObjectsOfProperty(final Property p) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<RDFNode> nIter = holder.getBaseItem().listObjectsOfProperty(p); if (!canRead(Triple.ANY)) { nIter = nIter.filterKeep(new ObjectFilter(p)); } return new SecuredNodeIterator<>(holder.getSecuredItem(), nIter); }
@Override public SecuredResIterator listResourcesWithProperty(final Property p, final double o) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Resource> rIter = holder.getBaseItem().listResourcesWithProperty(p, o); if (!canRead(Triple.ANY)) { rIter = rIter.filterKeep(new ResourceFilter(p, ResourceFactory.createTypedLiteral(o))); } return new SecuredResIterator(holder.getSecuredItem(), rIter); }
@Override public SecuredResIterator listResourcesWithProperty(final Property p, final long o) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Resource> rIter = holder.getBaseItem().listResourcesWithProperty(p, o); if (!canRead(Triple.ANY)) { rIter = rIter.filterKeep(new ResourceFilter(p, ResourceFactory.createTypedLiteral(o))); } return new SecuredResIterator(holder.getSecuredItem(), rIter); }
@Override public SecuredResIterator listSubjectsWithProperty(final Property p, final String o) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); ExtendedIterator<Resource> rIter = holder.getBaseItem().listSubjectsWithProperty(p, o); if (!canRead(Triple.ANY)) { rIter = rIter.filterKeep(new ResourceFilter(p, ResourceFactory.createPlainLiteral(o))); } return new SecuredResIterator(holder.getSecuredItem(), rIter); }
private int count(final Action action) { final Iterator<RDFList> iter = new RDFListIterator((RDFList) getBaseRDFNode()); return WrappedIterator.create(iter).filterKeep(new RDFListSecFilter<>(getSecuredRDFList(), action)) .toList().size(); }
/** * <p>Answer an iterator over all of the comment literals for this resource.</p> * @return An iterator over RDF {@link Literal}'s. * @exception ProfileException If the {@link Profile#COMMENT()} property is not supported in the current language profile. */ @Override public ExtendedIterator<RDFNode> listComments( String lang ) { checkProfile( getProfile().COMMENT(), "COMMENT" ); return WrappedIterator.create( listProperties( getProfile().COMMENT() ) ) .filterKeep( new LangTagFilter( lang ) ) .mapWith( s -> s.getObject() ); }