Sha256: 0f04534b1652b1c0471a9d6f2d9339835201be7eca09910856a3875f4b89ad5c

Contents?: true

Size: 910 Bytes

Versions: 34

Compression:

Stored size: 910 Bytes

Contents

module Hyrax
  # Searches for all collections that are parents of a given collection.
  class NestedCollectionsParentSearchBuilder < ::SearchBuilder
    include Hyrax::FilterByType
    attr_reader :child, :page, :limit

    # @param [scope] Typically the controller object
    # @param [child] The child collection
    def initialize(scope:, child:, page:)
      @child = child
      @page = page
      super(scope)
    end

    # Filters the query to only include the parent collections
    def parent_collections_only(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_ids(child.member_of_collection_ids)
    end
    self.default_processor_chain += [:parent_collections_only]

    def with_pagination(solr_parameters)
      solr_parameters[:page] = page
    end
    self.default_processor_chain += [:with_pagination]
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.5 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.4 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.3 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.9.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.8.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.7.2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.7.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.7.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.6.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.5.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.5.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.0.pre.beta2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.4.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.0.pre.beta1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.4.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.3.3 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-2.3.2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb