diff --git a/app/helpers/solr_helper.rb b/app/helpers/solr_helper.rb new file mode 100644 index 000000000..77f3be142 --- /dev/null +++ b/app/helpers/solr_helper.rb @@ -0,0 +1,10 @@ +# app/helpers/solr_helper.rb +module SolrHelper + def solr_name(field_name, *opts) + if Module.const_defined?(:Solrizer) + ::Solrizer.solr_name(field_name, *opts) + else + ::ActiveFedora.index_field_mapper.solr_name(field_name) + end + end +end diff --git a/app/indexers/ams/work_indexer.rb b/app/indexers/ams/work_indexer.rb index 0ab656d2d..83227237c 100644 --- a/app/indexers/ams/work_indexer.rb +++ b/app/indexers/ams/work_indexer.rb @@ -1,5 +1,7 @@ module AMS class WorkIndexer < Hyrax::WorkIndexer + include SolrHelper + def generate_solr_document find_index_child_attributes(super) end @@ -13,9 +15,9 @@ def find_index_child_attributes(solr_doc) parent_indexable_properties = work_type.properties.select{|index,val| val["index_to_parent"]||index=="language"||index=="contributor"?true:false} parent_indexable_properties.each do |prop, config| solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] ||= [] - solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] |= work[Solrizer.solr_name(prop)] if work[Solrizer.solr_name(prop)] + solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] |= work[solr_name(prop)] if work[solr_name(prop)] solr_doc["#{prop}_ssim"] ||= [] - solr_doc["#{prop}_ssim"] |= work[Solrizer.solr_name(prop)] if work[Solrizer.solr_name(prop)] + solr_doc["#{prop}_ssim"] |= work[solr_name(prop)] if work[solr_name(prop)] end end end diff --git a/app/indexers/asset_indexer.rb b/app/indexers/asset_indexer.rb index fb1d1aa81..15bbc0494 100644 --- a/app/indexers/asset_indexer.rb +++ b/app/indexers/asset_indexer.rb @@ -17,7 +17,7 @@ def generate_solr_document solr_doc['broadcast_date_drsim'] = object.broadcast_date if object.broadcast_date solr_doc['created_date_drsim'] = object.created_date if object.created_date solr_doc['copyright_date_drsim'] = object.copyright_date if object.copyright_date - solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier + solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier solr_doc['intended_children_count_isi'] = object.intended_children_count.to_i if object.admin_data @@ -29,7 +29,7 @@ def generate_solr_document AnnotationTypesService.new.select_all_options.each do |type| # Use the ID defined in the AnnotationType service type_id = type[1] - solr_doc[ Solrizer.solr_name(type_id.underscore,'ssim') ] = object.try(type_id.to_sym) unless object.try(type_id.to_sym).empty? + solr_doc[ solr_name(type_id.underscore,'ssim') ] = object.try(type_id.to_sym) unless object.try(type_id.to_sym).empty? end #Indexing for search by batch_id diff --git a/app/indexers/digital_instantiation_indexer.rb b/app/indexers/digital_instantiation_indexer.rb index fbe81538a..45dfbee2b 100644 --- a/app/indexers/digital_instantiation_indexer.rb +++ b/app/indexers/digital_instantiation_indexer.rb @@ -13,7 +13,7 @@ class DigitalInstantiationIndexer < AMS::WorkIndexer def generate_solr_document super.tap do |solr_doc| - solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier + solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier if object.instantiation_admin_data #Indexing as english text so we can use it on asset show page solr_doc['instantiation_admin_data_tesim'] = object.instantiation_admin_data.gid if !object.instantiation_admin_data.gid.blank? diff --git a/app/indexers/essence_track_indexer.rb b/app/indexers/essence_track_indexer.rb index 3425c9ad1..f2380b4d6 100644 --- a/app/indexers/essence_track_indexer.rb +++ b/app/indexers/essence_track_indexer.rb @@ -13,7 +13,7 @@ class EssenceTrackIndexer < AMS::WorkIndexer # Uncomment this block if you want to add custom indexing behavior: def generate_solr_document super.tap do |solr_doc| - solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier + solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier end end end diff --git a/app/indexers/physical_instantiation_indexer.rb b/app/indexers/physical_instantiation_indexer.rb index 0a551d444..ca62075c5 100644 --- a/app/indexers/physical_instantiation_indexer.rb +++ b/app/indexers/physical_instantiation_indexer.rb @@ -13,7 +13,7 @@ class PhysicalInstantiationIndexer < AMS::WorkIndexer def generate_solr_document super.tap do |solr_doc| - solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier + solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier if object.instantiation_admin_data #Indexing as english text so we can use it on asset show page solr_doc['instantiation_admin_data_tesim'] = object.instantiation_admin_data.gid if !object.instantiation_admin_data.gid.blank? diff --git a/app/models/asset.rb b/app/models/asset.rb index 090fbeeef..b7aec9472 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -4,6 +4,7 @@ class Asset < ActiveFedora::Base include ::AMS::IdentifierService include ::AMS::CascadeDestroyMembers include ::AMS::AllMembers + include SolrHelper # @see Push#add_status_error VALIDATION_STATUSES = { @@ -230,7 +231,7 @@ def admin_data_gid=(new_admin_data_gid) end def admin_data_gid_document_field_name - Solrizer.solr_name('admin_data_gid', *index_admin_data_gid_as) + solr_name('admin_data_gid', *index_admin_data_gid_as) end def sonyci_id diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 3a1e8b071..2d0521830 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -6,6 +6,8 @@ class SolrDocument # Adds Hyrax behaviors to the SolrDocument. include Hyrax::SolrDocumentBehavior + include SolrHelper + # self.unique_key = 'id' # Email uses the semantic field mappings below to generate the body of an email. @@ -87,198 +89,198 @@ def digital_instantiations end def asset_types - self[Solrizer.solr_name('asset_types')] + self[solr_name('asset_types')] end def bulkrax_identifier - self[Solrizer.solr_name('bulkrax_identifier')] + self[solr_name('bulkrax_identifier')] end def genre - self[Solrizer.solr_name('genre')] + self[solr_name('genre')] end def episode_number - self[Solrizer.solr_name('episode_number')] + self[solr_name('episode_number')] end def spatial_coverage - self[Solrizer.solr_name('spatial_coverage')] + self[solr_name('spatial_coverage')] end def temporal_coverage - self[Solrizer.solr_name('temporal_coverage')] + self[solr_name('temporal_coverage')] end def audience_level - self[Solrizer.solr_name('audience_level')] + self[solr_name('audience_level')] end def audience_rating - self[Solrizer.solr_name('audience_rating')] + self[solr_name('audience_rating')] end def annotation - self[Solrizer.solr_name('annotation')] + self[solr_name('annotation')] end def rights_summary - self[Solrizer.solr_name('rights_summary')] + self[solr_name('rights_summary')] end def rights_link - self[Solrizer.solr_name('rights_link')] + self[solr_name('rights_link')] end def digitization_date - self[Solrizer.solr_name('digitization_date')] + self[solr_name('digitization_date')] end def dimensions - self[Solrizer.solr_name('dimensions')] + self[solr_name('dimensions')] end def format - self[Solrizer.solr_name('format')] + self[solr_name('format')] end def standard - self[Solrizer.solr_name('standard')] + self[solr_name('standard')] end def location - self[Solrizer.solr_name('location')] + self[solr_name('location')] end def media_type - self[Solrizer.solr_name('media_type')] + self[solr_name('media_type')] end def generations - self[Solrizer.solr_name('generations')] + self[solr_name('generations')] end def time_start - self[Solrizer.solr_name('time_start')] + self[solr_name('time_start')] end def duration - self[Solrizer.solr_name('duration')] + self[solr_name('duration')] end def colors - self[Solrizer.solr_name('colors')] + self[solr_name('colors')] end def language - self[Solrizer.solr_name('language')] + self[solr_name('language')] end def file_size - self[Solrizer.solr_name('file_size')] + self[solr_name('file_size')] end def data_rate - self[Solrizer.solr_name('data_rate')] + self[solr_name('data_rate')] end def track_type - self[Solrizer.solr_name('track_type')] + self[solr_name('track_type')] end def track_id - self[Solrizer.solr_name('track_id')] + self[solr_name('track_id')] end def encoding - self[Solrizer.solr_name('encoding')] + self[solr_name('encoding')] end def frame_rate - self[Solrizer.solr_name('frame_rate')] + self[solr_name('frame_rate')] end def playback_speed - self[Solrizer.solr_name('playback_speed')] + self[solr_name('playback_speed')] end def playback_speed_units - self[Solrizer.solr_name('playback_speed_units')] + self[solr_name('playback_speed_units')] end def sample_rate - self[Solrizer.solr_name('sample_rate')] + self[solr_name('sample_rate')] end def bit_depth - self[Solrizer.solr_name('bit_depth')] + self[solr_name('bit_depth')] end def frame_width - self[Solrizer.solr_name('frame_width')] + self[solr_name('frame_width')] end def frame_height - self[Solrizer.solr_name('frame_height')] + self[solr_name('frame_height')] end def aspect_ratio - self[Solrizer.solr_name('aspect_ratio')] + self[solr_name('aspect_ratio')] end def contributor_role - self[Solrizer.solr_name('contributor_role')] + self[solr_name('contributor_role')] end def portrayal - self[Solrizer.solr_name('portrayal')] + self[solr_name('portrayal')] end def digital_format - self[Solrizer.solr_name('digital_format')] + self[solr_name('digital_format')] end def local_identifier - self[Solrizer.solr_name('local_identifier')] + self[solr_name('local_identifier')] end def pbs_nola_code - self[Solrizer.solr_name('pbs_nola_code')] + self[solr_name('pbs_nola_code')] end def eidr_id - self[Solrizer.solr_name('eidr_id')] + self[solr_name('eidr_id')] end def topics - self[Solrizer.solr_name('topics')] + self[solr_name('topics')] end def subject - self[Solrizer.solr_name('subject')] + self[solr_name('subject')] end def local_instantiation_identifier - self[Solrizer.solr_name('local_instantiation_identifier')] + self[solr_name('local_instantiation_identifier')] end def tracks - self[Solrizer.solr_name('tracks')] + self[solr_name('tracks')] end def channel_configuration - self[Solrizer.solr_name('channel_configuration')] + self[solr_name('channel_configuration')] end def alternative_modes - self[Solrizer.solr_name('alternative_modes')] + self[solr_name('alternative_modes')] end def title concatenated_titles = [series_title, program_title, episode_number, episode_title, segment_title, clip_title, promo_title, raw_footage_title, - self[Solrizer.solr_name('title')] + self[solr_name('title')] ].flatten.select(&:present?).join('; ') # Wrap the return value in an array to behave like a multi-valued field, # even though this will always be a single value. @@ -286,64 +288,64 @@ def title end def series_title - self[Solrizer.solr_name('series_title')] + self[solr_name('series_title')] end def program_title - self[Solrizer.solr_name('program_title')] + self[solr_name('program_title')] end def episode_title - self[Solrizer.solr_name('episode_title')] + self[solr_name('episode_title')] end def segment_title - self[Solrizer.solr_name('segment_title')] + self[solr_name('segment_title')] end def raw_footage_title - self[Solrizer.solr_name('raw_footage_title')] + self[solr_name('raw_footage_title')] end def promo_title - self[Solrizer.solr_name('promo_title')] + self[solr_name('promo_title')] end def clip_title - self[Solrizer.solr_name('clip_title')] + self[solr_name('clip_title')] end def display_description - description = [raw_footage_description, segment_description, clip_description, promo_description, episode_description, program_description, series_description, self[Solrizer.solr_name('description')]].find(&:present?) + description = [raw_footage_description, segment_description, clip_description, promo_description, episode_description, program_description, series_description, self[solr_name('description')]].find(&:present?) description.first.truncate(100, separator: ' ') unless description.nil? end def series_description - self[Solrizer.solr_name('series_description')] + self[solr_name('series_description')] end def program_description - self[Solrizer.solr_name('program_description')] + self[solr_name('program_description')] end def episode_description - self[Solrizer.solr_name('episode_description')] + self[solr_name('episode_description')] end def segment_description - self[Solrizer.solr_name('segment_description')] + self[solr_name('segment_description')] end def raw_footage_description - self[Solrizer.solr_name('raw_footage_description')] + self[solr_name('raw_footage_description')] end def promo_description - self[Solrizer.solr_name('promo_description')] + self[solr_name('promo_description')] end def clip_description - self[Solrizer.solr_name('clip_description')] + self[solr_name('clip_description')] end def all_dates @@ -359,79 +361,79 @@ def all_dates def dates; all_dates; end def display_dates - { Solrizer.solr_name('date') => date, - Solrizer.solr_name('broadcast_date') => broadcast_date, - Solrizer.solr_name('created_date') => created_date, - Solrizer.solr_name('copyright_date') => copyright_date + { solr_name('date') => date, + solr_name('broadcast_date') => broadcast_date, + solr_name('created_date') => created_date, + solr_name('copyright_date') => copyright_date }.select{ |k,v| v.present? } end def date - self[Solrizer.solr_name('date')] + self[solr_name('date')] end def broadcast_date - self[Solrizer.solr_name('broadcast_date')] + self[solr_name('broadcast_date')] end def created_date - self[Solrizer.solr_name('created_date')] + self[solr_name('created_date')] end def copyright_date - self[Solrizer.solr_name('copyright_date')] + self[solr_name('copyright_date')] end def holding_organization - self[Solrizer.solr_name('holding_organization')] + self[solr_name('holding_organization')] end def holding_organization_ssim - self[Solrizer.solr_name('holding_organization','ssim')] + self[solr_name('holding_organization','ssim')] end def affiliation - self[Solrizer.solr_name('affiliation')] + self[solr_name('affiliation')] end def producing_organization - self[Solrizer.solr_name('producing_organization')] + self[solr_name('producing_organization')] end def level_of_user_access - self[Solrizer.solr_name('level_of_user_access', 'ssim')] + self[solr_name('level_of_user_access', 'ssim')] end def outside_url - self[Solrizer.solr_name('outside_url', 'ssim')] + self[solr_name('outside_url', 'ssim')] end def special_collections - self[Solrizer.solr_name('special_collections', 'ssim')] + self[solr_name('special_collections', 'ssim')] end def transcript_status - self[Solrizer.solr_name('transcript_status', 'ssim')] + self[solr_name('transcript_status', 'ssim')] end def organization - self[Solrizer.solr_name('organization', 'ssim')] + self[solr_name('organization', 'ssim')] end def sonyci_id - self[Solrizer.solr_name('sonyci_id', 'ssim')] + self[solr_name('sonyci_id', 'ssim')] end def licensing_info - self[Solrizer.solr_name('licensing_info', 'ssim')] + self[solr_name('licensing_info', 'ssim')] end def playlist_group - self[Solrizer.solr_name('playlist_group', 'ssim')] + self[solr_name('playlist_group', 'ssim')] end def playlist_order - self[Solrizer.solr_name('playlist_order', 'ssim')] + self[solr_name('playlist_order', 'ssim')] end def media_src(part) @@ -443,88 +445,88 @@ def digitized? end def identifying_data - { "id" => id, Solrizer.solr_name('admin_set') => admin_set } + { "id" => id, solr_name('admin_set') => admin_set } end def aapb_preservation_lto - self[Solrizer.solr_name('aapb_preservation_lto')] + self[solr_name('aapb_preservation_lto')] end def aapb_preservation_disk - self[Solrizer.solr_name('aapb_preservation_disk')] + self[solr_name('aapb_preservation_disk')] end def bulkrax_importer_id - self[Solrizer.solr_name('bulkrax_importer_id')] + self[solr_name('bulkrax_importer_id')] end def hyrax_batch_ingest_batch_id - self[Solrizer.solr_name('hyrax_batch_ingest_batch_id')] + self[solr_name('hyrax_batch_ingest_batch_id')] end def last_pushed - self[Solrizer.solr_name('last_pushed')] + self[solr_name('last_pushed')] end def last_updated - self[Solrizer.solr_name('last_updated')] + self[solr_name('last_updated')] end def needs_update - self[Solrizer.solr_name('needs_update')] + self[solr_name('needs_update')] end def special_collection_category - self[Solrizer.solr_name('special_collection_category', 'ssim')] + self[solr_name('special_collection_category', 'ssim')] end def canonical_meta_tag - self[Solrizer.solr_name('canonical_meta_tag', 'ssim')] + self[solr_name('canonical_meta_tag', 'ssim')] end def cataloging_status - self[Solrizer.solr_name('cataloging_status', 'ssim')] + self[solr_name('cataloging_status', 'ssim')] end def captions_url - self[Solrizer.solr_name('captions_url', 'ssim')] + self[solr_name('captions_url', 'ssim')] end def external_reference_url - self[Solrizer.solr_name('external_reference_url','ssim')] + self[solr_name('external_reference_url','ssim')] end def last_modified - self[Solrizer.solr_name('last_modified','ssim')] + self[solr_name('last_modified','ssim')] end def mavis_number - self[Solrizer.solr_name('mavis_number','ssim')] + self[solr_name('mavis_number','ssim')] end def project_code - self[Solrizer.solr_name('project_code','ssim')] + self[solr_name('project_code','ssim')] end def supplemental_material - self[Solrizer.solr_name('supplemental_material','ssim')] + self[solr_name('supplemental_material','ssim')] end def transcript_url - self[Solrizer.solr_name('transcript_url','ssim')] + self[solr_name('transcript_url','ssim')] end def transcript_source - self[Solrizer.solr_name('transcript_source','ssim')] + self[solr_name('transcript_source','ssim')] end def md5 # this nonsensical ':symbol' option indicates that I am selecting the _ssim suffix from down in solrizer - default was _tesim, which was wrong for this field - self[Solrizer.solr_name('md5', :symbol)] + self[solr_name('md5', :symbol)] end def proxy_start_time - self[Solrizer.solr_name('proxy_start_time','ssim')] + self[solr_name('proxy_start_time','ssim')] end def all_members(only: [], exclude: []) diff --git a/app/presenters/aapb/instantiation_admin_data_presenter.rb b/app/presenters/aapb/instantiation_admin_data_presenter.rb index 1c2053fd8..ffddc26af 100644 --- a/app/presenters/aapb/instantiation_admin_data_presenter.rb +++ b/app/presenters/aapb/instantiation_admin_data_presenter.rb @@ -1,6 +1,8 @@ module AAPB module InstantiationAdminDataPresenter extend ActiveSupport::Concern + include SolrHelper + included do def display_admin_data? !(aapb_preservation_lto.blank? && @@ -17,7 +19,7 @@ def attribute_to_html(field, options = {}) if attribute_indexed_to_parent?(field, work_class) && attribute_facetable?(field, work_class) # Use :symbol for field_name since all attributes indexed to parent are indexed as symbols. - field_name = Solrizer.solr_name(field, :symbol) + field_name = solr_name(field, :symbol) # Use parent SolrDocument to get value solr_document = ::SolrDocument.find(work_class.find(id).member_of.first.id) if work_class&.find(id)&.member_of&.present? diff --git a/app/renderers/hyrax/renderers/indexed_to_parent_renderer.rb b/app/renderers/hyrax/renderers/indexed_to_parent_renderer.rb index 84f9da465..38c34e774 100644 --- a/app/renderers/hyrax/renderers/indexed_to_parent_renderer.rb +++ b/app/renderers/hyrax/renderers/indexed_to_parent_renderer.rb @@ -1,6 +1,8 @@ module Hyrax module Renderers class IndexedToParentRenderer < Hyrax::Renderers::FacetedAttributeRenderer + include SolrHelper + def render markup = '' @@ -19,7 +21,7 @@ def render private def search_field - ERB::Util.h(Solrizer.solr_name(options.fetch(:search_field, field), :symbol, type: :string)) + ERB::Util.h(solr_name(options.fetch(:search_field, field), :symbol, type: :string)) end end end diff --git a/app/views/layouts/_head_tag_content.html.erb b/app/views/layouts/_head_tag_content.html.erb index 6b4f4833f..6a2deea1a 100644 --- a/app/views/layouts/_head_tag_content.html.erb +++ b/app/views/layouts/_head_tag_content.html.erb @@ -1,4 +1,4 @@ -<% #OVERRIDE Hyrax 4.0 to allow for dual boot %> +<%# OVERRIDE Hyrax 4.0 to allow for dual boot %> <%= csrf_meta_tag %> <%# Only display meta tag, which enables creation of the ActionCable @@ -18,7 +18,7 @@ signed in %>