Class: Hyrax::Dashboard::NestedCollectionsSearchBuilder

Inherits:
CollectionSearchBuilder show all
Defined in:
app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb

Overview

Responsible for searching for collections of the same type that are not the given collection

Instance Attribute Summary collapse

Attributes inherited from CollectionSearchBuilder

#access

Instance Method Summary collapse

Methods inherited from CollectionSearchBuilder

#add_sorting_to_solr, #gated_discovery_filters, #models, #sort_field, #with_access

Methods included from FilterByType

#filter_models

Constructor Details

#initialize(access:, collection:, scope:, nesting_attributes:, nest_direction:) ⇒ NestedCollectionsSearchBuilder

Returns a new instance of NestedCollectionsSearchBuilder.

Parameters:

  • access (Symbol)

    :edit, :read, :discover - With the given :access what all can

  • collection (::Collection)
  • scope (Object)

    Typically a controller that responds to #current_ability, #blackligh_config

  • nesting_attributes (NestingAttributes)

    an object encapsulating nesting attributes of the collection

  • nest_direction (Symbol)

    (:as_parent or :as_child) the direction we are adding nesting to this collection


11
12
13
14
15
16
17
# File 'app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb', line 11

def initialize(access:, collection:, scope:, nesting_attributes:, nest_direction:)
  super(scope)
  @collection = collection
  @discovery_permissions = extract_discovery_permissions(access)
  @nesting_attributes = nesting_attributes
  @nest_direction = nest_direction
end

Instance Attribute Details

#discovery_permissionsObject (readonly)

Override for Hydra::AccessControlsEnforcement


20
21
22
# File 'app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb', line 20

def discovery_permissions
  @discovery_permissions
end

Instance Method Details

#show_only_other_collections_of_the_same_collection_type(solr_parameters) ⇒ Object


27
28
29
30
31
32
33
34
# File 'app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb', line 27

def show_only_other_collections_of_the_same_collection_type(solr_parameters)
  solr_parameters[:fq] ||= []
  solr_parameters[:fq] += [
    "-" + Hyrax::SolrQueryBuilderService.construct_query_for_ids([limit_ids]),
    Hyrax::SolrQueryBuilderService.construct_query(Hyrax.config.collection_type_index_field => @collection.collection_type_gid)
  ]
  solr_parameters[:fq] += limit_clause if limit_clause # add limits to prevent illegal nesting arrangements
end

#with_pagination(solr_parameters) ⇒ Object


23
24
25
# File 'app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb', line 23

def with_pagination(solr_parameters)
  solr_parameters[:rows] = 1000
end