Skip to content

Commit

Permalink
Merge pull request #637 from IU-Libraries-Joint-Development/essi-2023…
Browse files Browse the repository at this point in the history
…_file_set_indexing

[ESSI-2023] add FileSet indexing re: parentage, collection branding use
  • Loading branch information
dlpierce authored Dec 13, 2024
2 parents 5a4467b + c32cd7a commit 9915840
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
13 changes: 12 additions & 1 deletion app/indexers/essi/file_set_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ class FileSetIndexer < Hyrax::FileSetIndexer
def generate_solr_document
super.tap do |solr_doc|
parent = object.parent
unless parent.nil?
collection_branding_info = object.collection_branding_info
if parent
solr_doc['parented_bsi'] = true
solr_doc['collection_branding_bsi'] = false
solr_doc['is_page_of_ssi'] = parent.id
solr_doc['parent_path_tesi'] = Rails.application.routes.url_helpers.polymorphic_path(parent)
elsif collection_branding_info
solr_doc['parented_bsi'] = false
solr_doc['collection_branding_bsi'] = true
solr_doc['is_collection_brand_of_ssi'] = collection_branding_info.collection_id
else
solr_doc['parented_bsi'] = false
solr_doc['collection_branding_bsi'] = false
end

solr_doc['word_boundary_tsi'] = IiifPrint::TextExtraction::AltoReader.new(object.extracted_text.content).json if object.extracted_text.present?
solr_doc[Solrizer.solr_name('iiif_index_strategy')] = IndexerHelper.iiif_index_strategy

Expand Down
4 changes: 3 additions & 1 deletion app/models/collection_branding_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def save(uploaded_file_id: nil, user_key: nil)
user = User.find_by_user_key(user_key)
attach_file_set(uploaded_file, user)
end
super()
result = super()
file_set&.save
return result
end

def file_set_image_path
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/collection_branding_infos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
target_url { '' }
height { 0 }
width { 0 }
file_set_id { '1' }
file_set_id { nil }
image_path { '/fake/path/to/image' }
end
initialize_with { CollectionBrandingInfo.new(collection_id: collection_id, filename: filename, role: role, alt_txt: alt_text, target_url: target_url, local_path: local_path, file_set_id: file_set_id, image_path: image_path) }
Expand All @@ -24,7 +24,7 @@
target_url { 'http://example.com/' }
height { 0 }
width { 0 }
file_set_id { '1' }
file_set_id { nil }
image_path { '/fake/path/to/image' }
end
initialize_with { CollectionBrandingInfo.new(collection_id: collection_id, filename: filename, role: role, alt_txt: alt_text, target_url: target_url, local_path: local_path, file_set_id: file_set_id, image_path: image_path) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/collection_branding_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe CollectionBrandingInfo, type: :model do
let(:banner) { FactoryBot.build(:collection_branding_banner) }
let(:file_set) { double(id: 'file_set_id', uri: 'file_set_uri') }
let(:file_set) { FactoryBot.create(:file_set, id: 'file_set_id', uri: 'file_set_uri') }
let(:version) { double(uri: 'version_uri') }
let(:versions) { double(any?: true, all: self, last: version) }

Expand Down

0 comments on commit 9915840

Please sign in to comment.