private RdfStream getResourceTriples ( final int limit , final FedoraResource resource ) { final PreferTag returnPreference ; if ( prefer != null && prefer . hasReturn ( ) ) { returnPreference = prefer . getReturn ( ) ; } else if ( prefer != null && prefer . hasHandling ( ) ) { returnPreference = prefer . getHandling ( ) ; } else { returnPreference = PreferTag . emptyTag ( ) ; } final LdpPreferTag ldpPreferences = new LdpPreferTag ( returnPreference ) ; final Predicate < Triple > tripleFilter = ldpPreferences . prefersServerManaged ( ) ? x -> true : IS_MANAGED_TRIPLE . negate ( ) ; final List < Stream < Triple > > streams = new ArrayList <> ( ) ; if ( returnPreference . getValue ( ) . equals ( "minimal" ) ) { streams . add ( getTriples ( resource , of ( PROPERTIES , MINIMAL ) ) . filter ( tripleFilter ) ) ; // Mementos already have the server managed properties in the PROPERTIES category // since mementos are immutable and these triples are no longer managed if ( ldpPreferences . prefersServerManaged ( ) && ! resource . isMemento ( ) ) { streams . add ( getTriples ( resource , of ( SERVER_MANAGED , MINIMAL ) ) ) ; } } else { streams . add ( getTriples ( resource , PROPERTIES ) . filter ( tripleFilter ) ) ; // Additional server-managed triples about this resource // Mementos already have the server managed properties in the PROPERTIES category // since mementos are immutable and these triples are no longer managed if ( ldpPreferences . prefersServerManaged ( ) && ! resource . isMemento ( ) ) { streams . add ( getTriples ( resource , SERVER_MANAGED ) ) ; } // containment triples about this resource if ( ldpPreferences . prefersContainment ( ) ) { if ( limit == - 1 ) { streams . add ( getTriples ( resource , LDP_CONTAINMENT ) ) ; } else { streams . add ( getTriples ( resource , LDP_CONTAINMENT ) . limit ( limit ) ) ; } } // LDP container membership triples for this resource if ( ldpPreferences . prefersMembership ( ) ) { streams . add ( getTriples ( resource , LDP_MEMBERSHIP ) ) ; } // Include inbound references to this object if ( ldpPreferences . prefersReferences ( ) ) { streams . add ( getTriples ( resource , INBOUND_REFERENCES ) ) ; } // Embed the children of this object if ( ldpPreferences . prefersEmbed ( ) ) { streams . add ( getTriples ( resource , EMBED_RESOURCES ) ) ; } } final RdfStream rdfStream = new DefaultRdfStream ( asNode ( resource ) , streams . stream ( ) . reduce ( empty ( ) , Stream :: concat ) ) ; if ( httpTripleUtil != null && ldpPreferences . prefersServerManaged ( ) ) { return httpTripleUtil . addHttpComponentModelsForResourceToStream ( rdfStream , resource , uriInfo , translator ( ) ) ; } return rdfStream ; }
This method returns a stream of RDF triples associated with this target resource