Class: Hyrax::CollectionSearchBuilder

Inherits:
SearchBuilder
  • Object
show all
Includes:
FilterByType
Defined in:
app/search_builders/hyrax/collection_search_builder.rb

Overview

Note:

the default_processor_chain defined by Blacklight::Solr::SearchBuilderBehavior provides many possible points of override

Our parent class is the generated SearchBuilder descending from Blacklight::SearchBuilder It includes Blacklight::Solr::SearchBuilderBehavior, Hydra::AccessControlsEnforcement, Hyrax::SearchFilters Allows :deposit as a valid type

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



13
14
15
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 13

def access
  @access
end

Instance Method Details

#add_sorting_to_solr(solr_parameters) ⇒ Object

Sort results by title if no query was supplied. This overrides the default ‘relevance’ sort.



37
38
39
40
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 37

def add_sorting_to_solr(solr_parameters)
  return if solr_parameters[:q]
  solr_parameters[:sort] ||= "#{sort_field} asc"
end

#discovery_permissionsObject

Overrides Hydra::AccessControlsEnforcement



16
17
18
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 16

def discovery_permissions
  @discovery_permissions = extract_discovery_permissions(@access)
end

#gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability) ⇒ Array<String>

If :deposit access is requested, check to see which collections the user has deposit or manage access to.

Returns:

  • (Array<String>)

    a list of filters to apply to the solr query



45
46
47
48
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 45

def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
  return super unless permission_types.include?("deposit")
  ["{!terms f=id}#{collection_ids_for_deposit.join(',')}"]
end

#modelsObject

This overrides the models in FilterByType



26
27
28
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 26

def models
  collection_classes
end

#sort_fieldString

Returns Solr field name indicating default sort order.

Returns:

  • (String)

    Solr field name indicating default sort order



21
22
23
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 21

def sort_field
  Solrizer.solr_name('title', :sortable)
end

#with_access(access) ⇒ Object



30
31
32
33
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 30

def with_access(access)
  @access = access
  super(access)
end