Sha256: 9482b351d9e6bf33084d7a8ba795559d04d4e045d6f39ff6060c2f390489acc9
Contents?: true
Size: 1.61 KB
Versions: 29
Compression:
Stored size: 1.61 KB
Contents
module ActiveFedora::Associations ## # Finds the objects which associate with a given record and are contained # within the given container. Uses #repository to find the objects. class ContainedFinder attr_reader :container, :repository, :proxy_class delegate :contained_ids, to: :container # @param [#contained_ids] container a container that records are stored # under. # @param [#translate_uri_to_id, #find] repository a repository to build # objects from. # @param [ActiveFedora::Base] proxy_class class that represents an # ore:Proxy def initialize(container:, repository:, proxy_class:) @container = container @repository = repository @proxy_class = proxy_class end # @param [ActiveFedora::Base] record a record which you want to find the # reference node for. # @return [Array<ActiveFedora::Base>] This returns whatever type # repository.find returns. def find(record) record.reload repository.find(matching_ids(record)) end private def matching_ids(record) IDComposite.new(proxy_ids(record) & contained_ids, repository.translate_uri_to_id) end def proxy_ids(record) relation_subjects(record) end # This could be done with Prefer InboundReferences, but that is # a slow fedora call def relation_subjects(record) query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel( [[:has_model, proxy_class.to_class_uri], [:proxyFor, record.id]] ) ActiveFedora::SolrService.query(query, fl: 'id').map(&:rdf_uri) end end end
Version data entries
29 entries across 29 versions & 1 rubygems