Skip to content

Commit

Permalink
Remove support for the marcbib_xml field (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer authored and camillevilla committed Dec 4, 2018
1 parent c250b26 commit 54cbc49
Show file tree
Hide file tree
Showing 39 changed files with 92 additions and 121 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/display_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# the formats and whitelisting supported format types.
module DisplayType
def display_type
return nil unless (self[:marcfield] || mods).present?
return nil if eds?
@display_type ||= [marc_or_mods, collection_suffix].compact.join('_')
end

private

def marc_or_mods
return 'mods' if mods
return 'mods' if mods?
'marc'
end

Expand Down
9 changes: 7 additions & 2 deletions app/models/concerns/mods_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ module ModsData
configure_mods_display do
end
end

def mods?
self[:modsxml].present?
end

def mods
return nil unless self[:modsxml]
return nil unless mods?
@mods ||= render_mods_display(self)
end
def prettified_mods
return nil unless self["modsxml"]
return nil unless mods?
@prettified_mods ||= CodeRay::Duo[:xml, :div].highlight(self["modsxml"]).html_safe
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/marc_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def merge_matched_vernacular_fields
end

def append_unmatched_vernacular_fields
return unless marc.respond_to? :fields

marc.fields(['880']).each do |vern_field|
vernacular_field = MarcFieldWrapper.new(vern_field)
next unless vernacular_field.vernacular_matcher? &&
Expand Down
12 changes: 3 additions & 9 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,16 @@ class SolrDocument

delegate :empty?, :blank?, to: :to_h

def initialize(source_doc = {}, response = nil)
source_doc = source_doc.to_h if source_doc.respond_to?(:to_h)
source_doc[:marcfield] = (source_doc[:marcxml] || source_doc['marcxml'] || source_doc[:marcbib_xml] || source_doc['marcbib_xml'])
super
end

# TODO: change this to #to_param when we have upgraded to Blacklight 6.11.1
def id
(super || '').to_s.gsub('/', '%2F')
end

# The following shows how to setup this blacklight document to display marc documents
extension_parameters[:marc_source_field] = :marcfield
extension_parameters[:marc_source_field] = :marcxml
extension_parameters[:marc_format_type] = :marcxml
use_extension( Blacklight::Solr::Document::Marc) do |document|
document.key?( :marcxml ) || document.key?( :marcbib_xml )
document.key?(:marcxml)
end

use_extension(EdsExport) do |document|
Expand Down Expand Up @@ -116,7 +110,7 @@ def file_ids
self[:img_info] || self[:file_id] || []
end

concerning :MarcOrganizationAndArrangmenet do
concerning :MarcOrganizationAndArrangement do
def organization_and_arrangement
@organization_and_arrangement ||= OrganizationAndArrangement.new(self)
end
Expand Down
48 changes: 23 additions & 25 deletions app/views/catalog/_marc_search_results_document_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
<% if document.respond_to?(:to_marc) %>
<ul class="document-metadata dl-horizontal dl-invert results-metadata-section col-md-8">
<% if document[:vern_title_display].present? %>
<li><%= document[:vern_title_display].html_safe %></li>
<% end %>
<ul class="document-metadata dl-horizontal dl-invert results-metadata-section col-md-8">
<% if document[:vern_title_display].present? %>
<li><%= document[:vern_title_display].html_safe %></li>
<% end %>
<% uniform_title = get_uniform_title(document) %>
<% unless uniform_title.nil? %>
<% uniform_title[:fields].each do |field| %>
<li><%= field[:field] %></li>
<% if field[:vernacular] %>
<li><%= field[:vernacular] %></li>
<% end %>
<% end if uniform_title[:fields].present? %>
<% uniform_title[:unmatched_vernacular].each do |field| %>
<li><%= field %></li>
<% end if uniform_title[:unmatched_vernacular].present? %>
<% end %>
<% uniform_title = get_uniform_title(document) %>
<% unless uniform_title.nil? %>
<% uniform_title[:fields].each do |field| %>
<li><%= field[:field] %></li>
<% if field[:vernacular] %>
<li><%= field[:vernacular] %></li>
<% end %>
<% end if uniform_title[:fields].present? %>
<% uniform_title[:unmatched_vernacular].each do |field| %>
<li><%= field %></li>
<% end if uniform_title[:unmatched_vernacular].present? %>
<% end %>
<% %i[creator corporate_author meeting].each do |target| %>
<%= render 'marc_fields/linked_author_index', linked_author: document.linked_author(target) %>
<% end %>
<% %i[creator corporate_author meeting].each do |target| %>
<%= render 'marc_fields/linked_author_index', linked_author: document.linked_author(target) %>
<% end %>
<% if (imprint = results_imprint_string(document)).present? %>
<li><%= imprint %></li>
<% end %>
</ul>
<% end %>
<% if (imprint = results_imprint_string(document)).present? %>
<li><%= imprint %></li>
<% end %>
</ul>
6 changes: 3 additions & 3 deletions app/views/catalog/_summary_data.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if document.key?(:toc_struct) || document.respond_to?(:to_marc) %>
<% toc = document.fetch(:toc_struct, []).first || get_toc(document.to_marc) %>
<% if document.key?(:toc_struct) || document.key?(:summary_struct) || document.respond_to?(:to_marc) %>
<% toc = document.fetch(:toc_struct, []).first || ( document.respond_to?(:to_marc) && get_toc(document.to_marc)) %>
<% if toc.present? %>
<% if toc[:fields].present? %>
<% toc[:fields].each do |toc_field| %>
Expand Down Expand Up @@ -30,7 +30,7 @@
<% end %>
<% end %>
<% summary = document.fetch(:summary_struct, []).first || get_data_with_label_from_marc(document.to_marc, "Summary", '520') %>
<% summary = document.fetch(:summary_struct, []).first || (document.respond_to?(:to_marc) && get_data_with_label_from_marc(document.to_marc, "Summary", '520')) %>
<% if summary.present? %>
<% if summary[:fields].present? %>
<% summary[:fields].each do |field| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/record/_record_metadata_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="record-sections col-md-8">
<% if document.respond_to?(:to_marc) %>
<%= render "catalog/record/marc_metadata_sections" %>
<% elsif document.respond_to?(:mods) %>
<% elsif document.respond_to?(:mods?) && document.mods? %>
<%= render 'catalog/record/mods_metadata_sections' %>
<% end %>
</div>
Expand Down
1 change: 0 additions & 1 deletion config/solr_configs/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@
isbn_display,
item_display,
lccn,
marcbib_xml,
mhld_display,
modsxml,
oclc,
Expand Down
6 changes: 4 additions & 2 deletions spec/features/article_display_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

describe 'Subjects' do
let(:document) do
SolrDocument.new(id: '123', eds_subjects_person: '<searchLink fieldCode="SU" term="Person1">Person1</searchLink><br/><searchLink fieldCode="SU" term="Person2">Person2</searchLink>')
SolrDocument.new(id: '123', eds_title: 'TITLE', eds_subjects_person: '<searchLink fieldCode="SU" term="Person1">Person1</searchLink><br/><searchLink fieldCode="SU" term="Person2">Person2</searchLink>')
end

it 'are linked' do
Expand All @@ -20,7 +20,7 @@

describe 'Fulltext', js: true do
let(:document) do
SolrDocument.new(id: '123', eds_html_fulltext_available: true, eds_html_fulltext: '<anid>09dfa;</anid><p>This Journal</p>, 10(1)')
SolrDocument.new(id: '123', eds_title: 'TITLE', eds_html_fulltext_available: true, eds_html_fulltext: '<anid>09dfa;</anid><p>This Journal</p>, 10(1)')
end

context 'when a user has access' do
Expand Down Expand Up @@ -65,6 +65,7 @@
let(:document) do
SolrDocument.new(
id: '123',
eds_title: 'The title of the document',
eds_abstract: 'The Abstract',
eds_subjects_person: '<searchLink fieldCode="SU" term="Person1">Person1</searchLink><br/><searchLink fieldCode="SU" term="Person2">Person2</searchLink>',
eds_volume: 'The Volumne'
Expand All @@ -88,6 +89,7 @@
let(:document) do
SolrDocument.new(
id: 'abc123',
eds_title: 'TITLE',
eds_fulltext_links: [{ 'label' => 'Check SFX for full text', 'url' => 'http://example.com?param=abc&sid=xyz', 'type' => 'customlink-fulltext' }]
)
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/article_searching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
long_data = Array.new(100) { |_| 'Lorem ipsum dolor sit amet' }.join(', ')
document = SolrDocument.new(
id: '1234',
eds_title: 'Some title',
eds_authors: long_data,
eds_abstract: long_data,
eds_subjects: "<searchLink fieldCode=\"SU\" term=\"#{long_data}\">#{long_data}</searchLink>"
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:format_main_ssim: Book
:language: English
:marcxml: <%= simple_856 %>
:marcbib_xml: <%= simple_856 %>
:display_type:
- sirsi
:pub_date: 2014
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:access_facet: At the Library
:building_facet: Green
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:genre_ssim:
- Thesis/Dissertation
:display_type:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:display_type:
- sirsi
:marcxml: <%= simple_856 %>
:marcbib_xml: <%= simple_856 %>
:format_main_ssim: Newspaper
:access_facet: Online
:building_facet: SAL3 (off-campus storage)
2 changes: 1 addition & 1 deletion spec/fixtures/solr_documents/14.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:format: Book
:display_type:
- sirsi
:marcbib_xml: <%= metadata1 %>
:marcxml: <%= metadata1 %>
:format_main_ssim: Book
:imprint_display: 1788
:access_facet: At the Library
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/solr_documents/15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- sirsi
:author_corp_display:
- Scientific Council for Africa South of the Sahara.
:marcbib_xml: <%= metadata1 %>
:marcxml: <%= metadata1 %>
:format_main_ssim: Image
:access_facet: At the Library
:building_facet: Special Collections
2 changes: 1 addition & 1 deletion spec/fixtures/solr_documents/16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- sirsi
:author_meeting_display:
- Most Excellent Meeting
:marcbib_xml: <%= metadata1 %>
:marcxml: <%= metadata1 %>
:format_main_ssim: Newspaper
:access_facet: At the Library
:building_facet: Special Collections
2 changes: 1 addition & 1 deletion spec/fixtures/solr_documents/18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:format_main_ssim: Image
:display_type:
- sirsi
:marcbib_xml: <%= uniform_title_fixture %>
:marcxml: <%= uniform_title_fixture %>
:imprint_display: 1933
:access_facet: Online
:building_facet: "Math & Statistics"
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
:access_facet: Online
:building_facet: Law (Crown)
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
:language: Spanish
:format: Database
:marcxml: <%= stanford_only_856 %>
:marcbib_xml: <%= stanford_only_856 %>
:format_main_ssim: Database
:display_type:
- sirsi
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/28.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
:title_display: Some intersting papers, 1979-2010.
:language: English
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:format: Book
:format_main_ssim: Book
:display_type:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/34.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:format: Image
:format_main_ssim: Image
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:pub_date: 2008
:beginning_year_isi: 2007
:imprint_display: 2008
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:building_facet:
- "Stanford Digital Repository"
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:pub_date: 2004
:beginning_year_isi: 2004
:imprint_display: 2012
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
:format: File
:format_main_ssim: Dataset
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:pub_date: 2010
:beginning_year_isi: 2010
:imprint_display: 2010
2 changes: 1 addition & 1 deletion spec/fixtures/solr_documents/4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:display_type:
- sirsi
:physical: The physical statement
:marcbib_xml: <%= marc_characteristics_fixture %>
:marcxml: <%= marc_characteristics_fixture %>
:access_facet: At the Library
:building_facet: Hoover Library
:item_display:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/48.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
:title_display: A Virtual Object
:format_main_ssim: Map
:marcxml: <%= metadata2 %>
:marcbib_xml: <%= metadata2 %>
:display_type:
- image
:file_id:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/49.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
:title_display: Another Virtual Object
:format_main_ssim: Map
:marcxml: <%= contributed_works_fixture %>
:marcbib_xml: <%= contributed_works_fixture %>
:display_type:
- image
:file_id:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/51.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
:title_display: Another item in a virtual object
:format_main_ssim: Map
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:display_type:
- image
:file_id:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/52.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
:title_display: An item in a another virtual object
:format_main_ssim: Map
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:display_type:
- image
:file_id:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/53.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
:title_display: Another item in a another virtual object
:format_main_ssim: Map
:marcxml: <%= marc_382_instrumentation %>
:marcbib_xml: <%= marc_382_instrumentation %>
:display_type:
- image
:file_id:
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/55.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
:title_display: Collection in process
:format_main_ssim: Map
:marcxml: <%= marc_382_instrumentation %>
:marcbib_xml: <%= marc_382_instrumentation %>
:item_display:
- "123 -|- SPEC-COLL -|- GUNST -|- SPEC-INPRO -|- -|- -|- -|- -|- ABC 123"
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/56.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
:title_display: Hoover Item
:format_main_ssim: Map
:marcxml: <%= hoover_request_fixture %>
:marcbib_xml: <%= hoover_request_fixture %>
:item_display:
- "123 -|- HOOVER -|- STACKS -|- -|- -|- -|- -|- -|- ABC 123"
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/57.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
:title_display: SFX Catalog Item
:format_main_ssim: Journal/Periodical
:marcxml: <%= metadata1 %>
:marcbib_xml: <%= metadata1 %>
:url_sfx: http://sfx.example.com/
6 changes: 3 additions & 3 deletions spec/helpers/blacklight_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
describe "#document_partial_name" do
let(:marc) { SolrDocument.new(marcxml: '<xml />') }
let(:mods) { SolrDocument.new(modsxml: '<xml />') }
let(:no_display_type) { SolrDocument.new }
let(:eds) { SolrDocument.new(eds_title: 'Some title') }
let(:blacklight_config) { Blacklight::Configuration.new }
it "should use the #display_type when available" do
expect(document_partial_name(marc)).to eq "marc"
expect(document_partial_name(mods)).to eq "mods"
end
it "should fall back on the default when their is no display type" do
expect(document_partial_name(no_display_type)).to eq "default"
it "should fall back on the default for EDS records" do
expect(document_partial_name(eds)).to eq "default"
end
end
end
Loading

0 comments on commit 54cbc49

Please sign in to comment.