From 84bb48af5f3fbaeecb40dacc380157894b6e0320 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 11 Nov 2022 11:39:59 -0800 Subject: [PATCH 1/5] Add a traject setting that allows the component identifiers to be configured --- lib/arclight/traject/ead2_component_config.rb | 15 +++++++++++---- lib/arclight/traject/ead2_config.rb | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 8c48afab4..1d7c9d924 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -29,6 +29,7 @@ provide 'title_normalizer', 'Arclight::NormalizedTitle' provide 'reader_class_name', 'Arclight::Traject::NokogiriNamespacelessReader' provide 'logger', Logger.new($stderr) + provide 'component_identifier_format', '%s%s' end NAME_ELEMENTS = %w[corpname famname name persname].freeze @@ -68,6 +69,8 @@ # NOTE: All fields should be stored in Solr # ================== to_field 'ref_ssi' do |record, accumulator, _context| + next if context.output_hash['ref_ssi'] + accumulator << if record.attribute('id').blank? strategy = Arclight::MissingIdStrategy.selected hexdigest = strategy.new(record).to_hexdigest @@ -90,10 +93,14 @@ end to_field 'id' do |_record, accumulator, context| - accumulator << [ - settings[:root].output_hash['id'], - context.output_hash['ref_ssi'] - ].join + next if context.output_hash['id'] + + data = { + ref_id: context.output_hash['ref_ssi']&.first, + root_id: settings[:root].output_hash['id']&.first, + } + + accumulator << (settings[:component_identifier_format] % data) end to_field 'title_filing_ssi', extract_xpath('./did/unittitle'), first_only diff --git a/lib/arclight/traject/ead2_config.rb b/lib/arclight/traject/ead2_config.rb index b2371f9bf..deae22501 100644 --- a/lib/arclight/traject/ead2_config.rb +++ b/lib/arclight/traject/ead2_config.rb @@ -58,6 +58,7 @@ provide 'solr_writer.commit_on_close', 'true' provide 'repository', ENV.fetch('REPOSITORY_ID', nil) provide 'logger', Logger.new($stderr) + provide 'component_traject_config', File.join(__dir__, 'ead2_component_config.rb') end each_record do |_record, context| @@ -274,6 +275,7 @@ def increment provide :depth, 1 provide :logger, context.settings[:logger] provide :component_traject_config, context.settings[:component_traject_config] + provide :component_identifier_format, context.settings[:component_identifier_format] if context.settings[:component_identifier_format] end i.load_config_file(context.settings[:component_traject_config]) From cd3631fadb07fc776b394a20fec7b98d45910451 Mon Sep 17 00:00:00 2001 From: apple Date: Mon, 11 Dec 2023 18:29:49 -0500 Subject: [PATCH 2/5] Modify traject setting for component_identifier_format --- lib/arclight/traject/ead2_component_config.rb | 5 +++-- lib/arclight/traject/ead2_config.rb | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 1d7c9d924..dcca0f82d 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -68,7 +68,7 @@ # # NOTE: All fields should be stored in Solr # ================== -to_field 'ref_ssi' do |record, accumulator, _context| +to_field 'ref_ssi' do |record, accumulator, context| next if context.output_hash['ref_ssi'] accumulator << if record.attribute('id').blank? @@ -96,8 +96,8 @@ next if context.output_hash['id'] data = { - ref_id: context.output_hash['ref_ssi']&.first, root_id: settings[:root].output_hash['id']&.first, + ref_id: context.output_hash['ref_ssi']&.first } accumulator << (settings[:component_identifier_format] % data) @@ -300,6 +300,7 @@ provide :counter, context.settings[:counter] provide :depth, context.settings[:depth].to_i + 1 provide :component_traject_config, context.settings[:component_traject_config] + provide :component_identifier_format, context.settings[:component_identifier_format] end i.load_config_file(context.settings[:component_traject_config]) diff --git a/lib/arclight/traject/ead2_config.rb b/lib/arclight/traject/ead2_config.rb index deae22501..7cce3421f 100644 --- a/lib/arclight/traject/ead2_config.rb +++ b/lib/arclight/traject/ead2_config.rb @@ -275,7 +275,6 @@ def increment provide :depth, 1 provide :logger, context.settings[:logger] provide :component_traject_config, context.settings[:component_traject_config] - provide :component_identifier_format, context.settings[:component_identifier_format] if context.settings[:component_identifier_format] end i.load_config_file(context.settings[:component_traject_config]) From ddc57c18f413ade140c22b44a6cfb9659963539c Mon Sep 17 00:00:00 2001 From: apple Date: Tue, 12 Dec 2023 09:57:14 -0500 Subject: [PATCH 3/5] Change default component_identifier_format to include underscore This breaking change closes #1318 --- app/models/arclight/parent.rb | 2 +- lib/arclight/traject/ead2_component_config.rb | 2 +- lib/arclight/traject/ead2_config.rb | 1 - .../arclight/breadcrumb_component_spec.rb | 12 +++---- spec/features/aeon_web_ead_request_spec.rb | 2 +- spec/features/arclight_spec.rb | 2 +- spec/features/collection_context_spec.rb | 12 +++---- spec/features/collection_filtering_spec.rb | 6 ++-- spec/features/collection_page_spec.rb | 16 ++++----- spec/features/component_page_spec.rb | 22 ++++++------ spec/features/document_tools_spec.rb | 2 +- spec/features/google_form_request_spec.rb | 10 +++--- spec/features/item_breadcrumbs_spec.rb | 2 +- spec/features/many_component_ead_spec.rb | 2 +- spec/features/online_content_spec.rb | 6 ++-- spec/features/traject/ead2_indexing_spec.rb | 34 +++++++++---------- spec/models/arclight/parent_spec.rb | 2 +- 17 files changed, 67 insertions(+), 68 deletions(-) diff --git a/app/models/arclight/parent.rb b/app/models/arclight/parent.rb index cf8856cdb..3d4489fe7 100644 --- a/app/models/arclight/parent.rb +++ b/app/models/arclight/parent.rb @@ -25,7 +25,7 @@ def collection? def global_id return id if eadid == id - "#{eadid}#{id}" + "#{eadid}_#{id}" end end end diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index dcca0f82d..03498af05 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -29,7 +29,7 @@ provide 'title_normalizer', 'Arclight::NormalizedTitle' provide 'reader_class_name', 'Arclight::Traject::NokogiriNamespacelessReader' provide 'logger', Logger.new($stderr) - provide 'component_identifier_format', '%s%s' + provide 'component_identifier_format', '%s_%s' end NAME_ELEMENTS = %w[corpname famname name persname].freeze diff --git a/lib/arclight/traject/ead2_config.rb b/lib/arclight/traject/ead2_config.rb index 7cce3421f..b2371f9bf 100644 --- a/lib/arclight/traject/ead2_config.rb +++ b/lib/arclight/traject/ead2_config.rb @@ -58,7 +58,6 @@ provide 'solr_writer.commit_on_close', 'true' provide 'repository', ENV.fetch('REPOSITORY_ID', nil) provide 'logger', Logger.new($stderr) - provide 'component_traject_config', File.join(__dir__, 'ead2_component_config.rb') end each_record do |_record, context| diff --git a/spec/components/arclight/breadcrumb_component_spec.rb b/spec/components/arclight/breadcrumb_component_spec.rb index 1a664dde5..1e9909285 100644 --- a/spec/components/arclight/breadcrumb_component_spec.rb +++ b/spec/components/arclight/breadcrumb_component_spec.rb @@ -29,8 +29,8 @@ it 'renders only that many breadcrumb links' do expect(rendered).to have_selector 'li', text: 'my repository' - expect(rendered).to have_link 'DEF', href: '/catalog/abc123def' - expect(rendered).not_to have_link 'GHI', href: '/catalog/abc123ghi' + expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def' + expect(rendered).not_to have_link 'GHI', href: '/catalog/abc123_ghi' end it 'renders an ellipsis if there are more links than the count' do @@ -43,14 +43,14 @@ it 'skips some breadcrumb links' do expect(rendered).not_to have_selector 'li', text: 'my repository' - expect(rendered).not_to have_link 'DEF', href: '/catalog/abc123def' - expect(rendered).to have_link 'GHI', href: '/catalog/abc123ghi' + expect(rendered).not_to have_link 'DEF', href: '/catalog/abc123_def' + expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi' end end it 'renders breadcrumb links' do expect(rendered).to have_selector 'li', text: 'my repository' - expect(rendered).to have_link 'DEF', href: '/catalog/abc123def' - expect(rendered).to have_link 'GHI', href: '/catalog/abc123ghi' + expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def' + expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi' end end diff --git a/spec/features/aeon_web_ead_request_spec.rb b/spec/features/aeon_web_ead_request_spec.rb index e5b254c99..92310d34d 100644 --- a/spec/features/aeon_web_ead_request_spec.rb +++ b/spec/features/aeon_web_ead_request_spec.rb @@ -7,7 +7,7 @@ it 'creates a request link' do visit solr_document_path 'm0198-xml' - within '#m0198-xmlaspace_ref11_d0s-hierarchy-item' do + within '#m0198-xml_aspace_ref11_d0s-hierarchy-item' do click_link 'Pages 1-78' end expect(page).to have_css( diff --git a/spec/features/arclight_spec.rb b/spec/features/arclight_spec.rb index ea78d787f..dbb882578 100644 --- a/spec/features/arclight_spec.rb +++ b/spec/features/arclight_spec.rb @@ -10,7 +10,7 @@ describe 'eadid with a period' do it 'is visitable with a hyphen' do - visit solr_document_path('m0198-xmlaspace_ref11_d0s') + visit solr_document_path('m0198-xml_aspace_ref11_d0s') expect(page).to have_css 'h1', text: 'Pages 1-78' end end diff --git a/spec/features/collection_context_spec.rb b/spec/features/collection_context_spec.rb index 9cd8785cf..acd307c4b 100644 --- a/spec/features/collection_context_spec.rb +++ b/spec/features/collection_context_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Collection context', js: true do - let(:doc_id) { 'aoa271aspace_6ea193f778e553ca9ea0d00a3e5a1891' } + let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' } before do visit solr_document_path(id: doc_id) @@ -15,17 +15,17 @@ end it 'siblings are not expanded' do - expect(page).to have_css '.al-toggle-view-children.collapsed[href="#collapsible-hierarchy-aoa271aspace_b70574c7229e6f237f780579cc04595d"]' + expect(page).to have_css '.al-toggle-view-children.collapsed[href="#collapsible-hierarchy-aoa271_aspace_b70574c7229e6f237f780579cc04595d"]' end it 'direct ancestors are expanded' do - expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_f934f1add34289f28bd0feb478e68275.show', visible: :visible - expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_238a0567431f36f49acea49ef576d408.show', visible: :visible - expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671.show', visible: :visible + expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_f934f1add34289f28bd0feb478e68275.show', visible: :visible + expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_238a0567431f36f49acea49ef576d408.show', visible: :visible + expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671.show', visible: :visible end it 'siblings above are hidden' do - expect(page).not_to have_css '#aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' + expect(page).not_to have_css '#aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' end end end diff --git a/spec/features/collection_filtering_spec.rb b/spec/features/collection_filtering_spec.rb index f6c6c5f12..1de5e4eff 100644 --- a/spec/features/collection_filtering_spec.rb +++ b/spec/features/collection_filtering_spec.rb @@ -38,7 +38,7 @@ context 'when on a record view' do it 'has the a select input with the "this collection" option selected' do - visit solr_document_path('lc0100aspace_327a75c226d44aa1a769edb4d2f13c6e') + visit solr_document_path('lc0100_aspace_327a75c226d44aa1a769edb4d2f13c6e') within 'form.search-query-form' do expect(page).to have_select('Search', selected: 'this collection') @@ -46,7 +46,7 @@ end it 'searches within the collection context by default' do - visit solr_document_path('aoa271aspace_dba76dab6f750f31aa5fc73e5402e71d') + visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d') fill_in 'q', with: 'File' click_button 'Search' @@ -56,7 +56,7 @@ end it 'allows the user to choose to search all collections' do - visit solr_document_path('aoa271aspace_dba76dab6f750f31aa5fc73e5402e71d') + visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d') select 'all collections', from: 'Search within' fill_in 'q', with: 'File' diff --git a/spec/features/collection_page_spec.rb b/spec/features/collection_page_spec.rb index 91c3ed16c..a760ab375 100644 --- a/spec/features/collection_page_spec.rb +++ b/spec/features/collection_page_spec.rb @@ -191,20 +191,20 @@ it 'sub components are viewable and expandable' do within '#collection-context' do - within '#aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do + within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do click_link 'View' - within '#aoa271aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do + within '#aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do expect(page).to have_link 'Constitution and by-laws' end click_link 'Expand' expect(page).to have_link 'Reports' - el = find_by_id('aoa271aspace_238a0567431f36f49acea49ef576d408-hierarchy-item') + el = find_by_id('aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item') evaluate_script "window.scrollTo(0,#{el.rect.y - 100})" sleep 1 - within '#aoa271aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do + within '#aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do click_link 'View' expect(page).to have_link 'Expansion Plan' - within '#aoa271aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do + within '#aoa271_aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do click_link 'View' expect(page).to have_link 'Initial Phase' expect(page).to have_link 'Phase II: Expansion' @@ -215,7 +215,7 @@ end it 'includes the number of direct children of the component' do - within '#aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do + within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do expect(page).to have_css( '.al-number-of-children-badge', text: /25/ @@ -243,7 +243,7 @@ end context 'content with file downloads', js: true do - let(:doc_id) { 'a0011-xmlaspace_ref6_lx4' } + let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do within '.al-show-actions-box-downloads-container' do @@ -260,7 +260,7 @@ end context 'with EAD documents which require Aeon requests' do - let(:doc_id) { 'm0198-xmlaspace_ref11_d0s' } + let(:doc_id) { 'm0198-xml_aspace_ref11_d0s' } it 'renders links to the Aeon request form' do expect(page).to have_css '.al-request' diff --git a/spec/features/component_page_spec.rb b/spec/features/component_page_spec.rb index 440a625c8..fddeb49f3 100644 --- a/spec/features/component_page_spec.rb +++ b/spec/features/component_page_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Component Page' do - let(:doc_id) { 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' } + let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' } let(:download_config) do ActiveSupport::HashWithIndifferentAccess.new( default: { @@ -52,7 +52,7 @@ end describe 'Indexed Terms subjects section' do - let(:doc_id) { 'aoa271aspace_01daa89087641f7fc9dbd7a10d3f2da9' } + let(:doc_id) { 'aoa271_aspace_01daa89087641f7fc9dbd7a10d3f2da9' } it 'includes subjects dt subheading text' do expect(page).to have_css('dt.blacklight-access_subjects', text: 'Subjects:') @@ -70,7 +70,7 @@ end describe 'metadata' do - let(:doc_id) { 'aoa271aspace_dc2aaf83625280ae2e193beb3f4aea78' } + let(:doc_id) { 'aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78' } it 'uses our rules for displaying containers' do expect(page).to have_css('dd', text: 'Box 1, Folder 4-5') @@ -143,7 +143,7 @@ end context 'duplicate titles' do - let(:doc_id) { 'lc0100aspace_c5ef89d4ae68bb77e7c641f3edb3f1c8' } + let(:doc_id) { 'lc0100_aspace_c5ef89d4ae68bb77e7c641f3edb3f1c8' } it 'does not highlight duplicate titles' do within '#collection-context .al-hierarchy-highlight' do @@ -153,7 +153,7 @@ end context 'when there are more than ten previous sibling documents for the current document' do - let(:doc_id) { 'lc0100aspace_ca60f0c03c4638b89e0348c3c6f7b50e' } + let(:doc_id) { 'lc0100_aspace_ca60f0c03c4638b89e0348c3c6f7b50e' } it 'hides all but the first sibling document items' do within '#collection-context' do @@ -178,18 +178,18 @@ end context 'when on a deeply nested component' do - let(:doc_id) { 'aoa271aspace_6ea193f778e553ca9ea0d00a3e5a1891' } + let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' } it 'enables expanding nodes outside of own ancestor tree' do within '#collection-context' do - find('#aoa271aspace_01daa89087641f7fc9dbd7a10d3f2da9-hierarchy-item .al-toggle-view-children').click + find('#aoa271_aspace_01daa89087641f7fc9dbd7a10d3f2da9-hierarchy-item .al-toggle-view-children').click expect(page).to have_css '.document-title-heading', text: 'Miscellaneous 1999' end end it 'includes ancestor\'s preceding sibling when clicking ancestor\'s Expand button' do within '#collection-context' do - within('#collapsible-hierarchy-aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671') do + within('#collapsible-hierarchy-aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671') do first('.btn-secondary', text: 'Expand').click end expect(page).to have_css '.document-title-heading', text: 'Officers and directors - lists, 1961, n.d.' @@ -198,11 +198,11 @@ end context 'when on a component with an eadid with . normalized to -' do - let(:doc_id) { 'pc0170-xmlaspace_ref1_z0j' } + let(:doc_id) { 'pc0170-xml_aspace_ref1_z0j' } it 'expands child nodes when clicked' do within '#collection-context' do - find('#pc0170-xmlaspace_ref5_edi-hierarchy-item .al-toggle-view-children').click + find('#pc0170-xml_aspace_ref5_edi-hierarchy-item .al-toggle-view-children').click expect(page).to have_css '.document-title-heading', text: 'Restricted images, 1979-2000' end end @@ -237,7 +237,7 @@ end context 'content with file downloads', js: true do - let(:doc_id) { 'a0011-xmlaspace_ref6_lx4' } + let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do within '.al-show-actions-box-downloads-container' do diff --git a/spec/features/document_tools_spec.rb b/spec/features/document_tools_spec.rb index ae80d5d3c..52e1ebb99 100644 --- a/spec/features/document_tools_spec.rb +++ b/spec/features/document_tools_spec.rb @@ -23,7 +23,7 @@ end context 'for components' do - let(:doc_id) { 'm0198-xmlaspace_ref11_d0s' } + let(:doc_id) { 'm0198-xml_aspace_ref11_d0s' } pending 'renders the bookmark option' do expect(page).to have_css('.al-document-title-bar form.bookmark-toggle') diff --git a/spec/features/google_form_request_spec.rb b/spec/features/google_form_request_spec.rb index ba03ffec0..7d72f9e77 100644 --- a/spec/features/google_form_request_spec.rb +++ b/spec/features/google_form_request_spec.rb @@ -6,11 +6,11 @@ context 'when container is present' do context 'repository is requestable' do it 'form is present with filled out values' do - visit solr_document_path 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' + visit solr_document_path 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' within 'form' do expect(page).to have_css( - 'input[name="entry.1980510262"][value$="catalog/aoa271aspace_843e8f9f22bac69872d0802d6fffbb04"]', + 'input[name="entry.1980510262"][value$="catalog/aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04"]', visible: :hidden ) expect(page).to have_css('input[name="entry.619150170"][value="Alpha Omega Alpha Archives, 1894-1992"]', @@ -25,7 +25,7 @@ context 'repository is not requestable' do it 'form is absent' do - visit solr_document_path 'm0198-xmlaspace_ref14_di4' + visit solr_document_path 'm0198-xml_aspace_ref14_di4' expect(page).not_to have_css 'form' end end @@ -34,7 +34,7 @@ context 'when container is absent' do it 'form is absent' do - visit solr_document_path 'aoa271aspace_238a0567431f36f49acea49ef576d408' + visit solr_document_path 'aoa271_aspace_238a0567431f36f49acea49ef576d408' expect(page).not_to have_css 'form' end end @@ -57,7 +57,7 @@ end it 'shows up in context' do - visit solr_document_path 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' + visit solr_document_path 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' within '#collection-context' do expect(page).to have_css 'form[action*="https://docs.google.com"]', count: 3 end diff --git a/spec/features/item_breadcrumbs_spec.rb b/spec/features/item_breadcrumbs_spec.rb index 79332cc10..16a35d89e 100644 --- a/spec/features/item_breadcrumbs_spec.rb +++ b/spec/features/item_breadcrumbs_spec.rb @@ -23,7 +23,7 @@ end it 'show page breadcrumbs' do - visit solr_document_path id: 'aoa271aspace_e8755922a9336970292ca817983e7139' + visit solr_document_path id: 'aoa271_aspace_e8755922a9336970292ca817983e7139' expect(page).to have_css 'li.breadcrumb-item a', count: 5 end end diff --git a/spec/features/many_component_ead_spec.rb b/spec/features/many_component_ead_spec.rb index 4aa23b57a..4df0d1ef5 100644 --- a/spec/features/many_component_ead_spec.rb +++ b/spec/features/many_component_ead_spec.rb @@ -16,7 +16,7 @@ within '#collection-context' do click_link 'View' click_link 'Expand' - within '#collapsible-hierarchy-lc0100aspace_327a75c226d44aa1a769edb4d2f13c6e' do + within '#collapsible-hierarchy-lc0100_aspace_327a75c226d44aa1a769edb4d2f13c6e' do expect(page).to have_css 'li.al-collection-context', count: 202 end end diff --git a/spec/features/online_content_spec.rb b/spec/features/online_content_spec.rb index 0b69b261e..7411913c2 100644 --- a/spec/features/online_content_spec.rb +++ b/spec/features/online_content_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' RSpec.describe 'Online Content' do - let(:doc_id) { 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' } + let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' } before { visit solr_document_path(id: doc_id) } describe 'Viewer' do context 'embedded content' do - let(:doc_id) { 'a0011-xmlaspace_ref6_lx4' } + let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders digital object viewer initialization markup', js: true do expect(page).to have_css( @@ -20,7 +20,7 @@ end context 'non-embeddable content' do - let(:doc_id) { 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' } + let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' } it 'renders a list of links', js: true do expect(page).to have_link 'Folder of digitized stuff' diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index aa51a9daf..212acfbf4 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -144,7 +144,7 @@ def components(result) end it 'id' do - expect(first_component).to include 'id' => ['a0011-xmlaspace_ref6_lx4'] + expect(first_component).to include 'id' => ['a0011-xml_aspace_ref6_lx4'] end it 'has_online_content' do @@ -211,7 +211,7 @@ def components(result) let(:fixture_path) do Arclight::Engine.root.join('spec', 'fixtures', 'ead', 'sample', 'large-components-list.xml') end - let(:nested_component) { all_components.find { |c| c['id'] == ['lc0100aspace_32ad9025a3a286358baeae91b5d7696e'] } } + let(:nested_component) { all_components.find { |c| c['id'] == ['lc0100_aspace_32ad9025a3a286358baeae91b5d7696e'] } } it 'builds the results' do expect(all_components.length).to eq 404 @@ -235,8 +235,8 @@ def components(result) let(:fixture_path) do Arclight::Engine.root.join('spec', 'fixtures', 'ead', 'nlm', 'ncaids544-id-test.xml') end - let(:component_with_descendants) { all_components.find { |c| c['id'] == ['ncaids544-testd0e452'] } } - let(:nested_component) { all_components.find { |c| c['id'] == ['ncaids544-testd0e631'] } } + let(:component_with_descendants) { all_components.find { |c| c['id'] == ['ncaids544-test_d0e452'] } } + let(:nested_component) { all_components.find { |c| c['id'] == ['ncaids544-test_d0e631'] } } it 'counts child components' do expect(component_with_descendants['child_component_count_isi']).to eq [9] @@ -271,7 +271,7 @@ def components(result) describe 'component-level' do it 'indexes own notes, not notes from descendants' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671'] } expect(component).to include 'scopecontent_html_tesm' expect(component['scopecontent_html_tesm']).to include(a_string_matching(/provide important background context./)) expect(component['scopecontent_html_tesm']).not_to include(a_string_matching(/correspondence, and a nametag./)) @@ -395,7 +395,7 @@ def components(result) let(:component_with_many_parents) { all_components.find { |c| c['ref_ssi'] == ['aspace_f934f1add34289f28bd0feb478e68275'] } } it 'parent_unittitles should be displayable and searchable' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671'] } %w[parent_unittitles_ssm parent_unittitles_tesim].each do |field| expect(component[field]).to contain_exactly( 'Alpha Omega Alpha Archives, 1894-1992' @@ -428,12 +428,12 @@ def components(result) end it 'only indexes containers within a given component' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'] } expect(component['containers_ssim']).to eq ['box 1', 'folder 1'] end it 'only indexes containers at the same level of the component' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671'] } expect(component['containers_ssim']).to be_nil end end @@ -456,7 +456,7 @@ def components(result) end it 'indexes controlaccess subjects within a component' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_81c806b82a14c3c79d395bbd383b886f'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_81c806b82a14c3c79d395bbd383b886f'] } %w[access_subjects_ssm access_subjects_ssim].each do |field| expect(component).to include field expect(component[field]).to contain_exactly 'Minutes' @@ -510,13 +510,13 @@ def components(result) describe 'component-level' do it 'indexes names in a shared names field' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'] } expect(component).to include 'names_ssim' expect(component['names_ssim']).to include_ignoring_whitespace 'Robertson\'s Crab House' end it 'indexes names in fields for specific name types, regardless of ' do - component = all_components.find { |c| c['id'] == ['aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'] } + component = all_components.find { |c| c['id'] == ['aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'] } expect(component['corpname_ssim']).to include_ignoring_whitespace 'Robertson\'s Crab House' expect(component['persname_ssim']).to include_ignoring_whitespace 'Anfinsen, Christian B.' end @@ -529,7 +529,7 @@ def components(result) end it 'indexes geognames' do - component = all_components.find { |d| d['id'] == ['aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'] } + component = all_components.find { |d| d['id'] == ['aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'] } expect(component).to include 'geogname_ssim' expect(component['geogname_ssim']).to include('Popes Creek (Md.)') @@ -544,7 +544,7 @@ def components(result) end it 'creates date_range_isim' do - component = all_components.find { |d| d['id'] == ['aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671'] } + component = all_components.find { |d| d['id'] == ['aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671'] } date_range = component['date_range_isim'] expect(date_range).to be_an Array expect(date_range.length).to eq 75 @@ -603,7 +603,7 @@ def components(result) end context 'when is direct child of component' do - let(:component) { all_components.find { |c| c['id'] == ['aoa271aspace_e6db65d47e891d61d69c2798c68a8f02'] } } + let(:component) { all_components.find { |c| c['id'] == ['aoa271_aspace_e6db65d47e891d61d69c2798c68a8f02'] } } it 'gets the digital object' do expect(component['digital_objects_ssm']).to eq( @@ -618,7 +618,7 @@ def components(result) end context 'when is child of the in a component' do - let(:component) { all_components.find { |c| c['id'] == ['aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'] } } + let(:component) { all_components.find { |c| c['id'] == ['aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'] } } it 'gets the digital objects' do expect(component['digital_objects_ssm']).to eq( @@ -649,10 +649,10 @@ def components(result) expect(all_components).not_to be_empty expect(first_component['ref_ssi']).to contain_exactly('al_4bf70b448ac8351a147acff1dd8b1c0b9a791980') - expect(first_component['id']).to contain_exactly('ehllHemingwayErnest-sampleal_4bf70b448ac8351a147acff1dd8b1c0b9a791980') + expect(first_component['id']).to contain_exactly('ehllHemingwayErnest-sample_al_4bf70b448ac8351a147acff1dd8b1c0b9a791980') expect(second_component['ref_ssi']).to contain_exactly('al_54b06e5ad77cab05ec7f6beeaca50022c47d9c7b') - expect(second_component['id']).to contain_exactly('ehllHemingwayErnest-sampleal_54b06e5ad77cab05ec7f6beeaca50022c47d9c7b') + expect(second_component['id']).to contain_exactly('ehllHemingwayErnest-sample_al_54b06e5ad77cab05ec7f6beeaca50022c47d9c7b') expect(second_component['parent_ssim']).to equal_array_ignoring_whitespace( %w[ehllHemingwayErnest-sample al_4bf70b448ac8351a147acff1dd8b1c0b9a791980] diff --git a/spec/models/arclight/parent_spec.rb b/spec/models/arclight/parent_spec.rb index 3b8a2fc8d..79a1d7f43 100644 --- a/spec/models/arclight/parent_spec.rb +++ b/spec/models/arclight/parent_spec.rb @@ -15,7 +15,7 @@ end it 'returns a correct global identifier' do - expect(instance.global_id).to eq '123abc' + expect(instance.global_id).to eq '123_abc' end end end From 512d70081700e6dc630c0ed021ead57c4fc82aaa Mon Sep 17 00:00:00 2001 From: Sean Aery Date: Tue, 12 Dec 2023 20:37:37 -0500 Subject: [PATCH 4/5] Refactor Parent.global_id so identifier format only has to be configured in one place. Advances #1318 - Capture the concatenated/formatted IDs at indexing time, in parent_ids_ssim array - Use that data instead of global_id --- .../arclight/breadcrumb_component.rb | 2 +- .../breadcrumbs_hierarchy_component.html.erb | 4 ++-- app/models/arclight/parent.rb | 10 --------- app/models/concerns/arclight/solr_document.rb | 2 +- lib/arclight/traject/ead2_component_config.rb | 5 +++++ .../arclight/breadcrumb_component_spec.rb | 10 +++++---- spec/models/arclight/parent_spec.rb | 21 ------------------- spec/models/arclight/parents_spec.rb | 16 +++++++------- 8 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 spec/models/arclight/parent_spec.rb diff --git a/app/components/arclight/breadcrumb_component.rb b/app/components/arclight/breadcrumb_component.rb index 103b616d7..89dec1ca9 100644 --- a/app/components/arclight/breadcrumb_component.rb +++ b/app/components/arclight/breadcrumb_component.rb @@ -29,7 +29,7 @@ def components yield build_repository_link @document.parents.each do |parent| - yield tag.li(class: 'breadcrumb-item') { link_to(parent.label, solr_document_path(parent.global_id)) } + yield tag.li(class: 'breadcrumb-item') { link_to(parent.label, solr_document_path(parent.id)) } end end diff --git a/app/components/arclight/breadcrumbs_hierarchy_component.html.erb b/app/components/arclight/breadcrumbs_hierarchy_component.html.erb index 51004efed..bb63f4328 100644 --- a/app/components/arclight/breadcrumbs_hierarchy_component.html.erb +++ b/app/components/arclight/breadcrumbs_hierarchy_component.html.erb @@ -9,12 +9,12 @@ <% if collection %>