From c7818c84e4b3663067f1c2959de517b73d5821a8 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Wed, 6 Dec 2023 15:06:43 -0500 Subject: [PATCH] Only look at language code when de-duping during bib import --- app/models/mods_document.rb | 2 +- spec/fixtures/7763100.lang_text.mods | 217 +++++++++++++++++++++++++++ spec/models/media_object_spec.rb | 11 ++ 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/7763100.lang_text.mods diff --git a/app/models/mods_document.rb b/app/models/mods_document.rb index 6ae831c872..8063f0b042 100644 --- a/app/models/mods_document.rb +++ b/app/models/mods_document.rb @@ -238,7 +238,7 @@ def populate_from_catalog! bib_id, bib_id_label = nil end self.send("resource_type=", old_resource_type) # let template remove languages that aren't in the controlled vocabulary, and de-dupe - languages = self.language.collect &:strip + languages = self.language_code.collect &:strip self.language = nil languages.uniq.each { |lang| self.add_language(lang) } # add new other identifiers and restore old other identifiers and remove the old bibliographic id diff --git a/spec/fixtures/7763100.lang_text.mods b/spec/fixtures/7763100.lang_text.mods new file mode 100644 index 0000000000..0631edf628 --- /dev/null +++ b/spec/fixtures/7763100.lang_text.mods @@ -0,0 +1,217 @@ + + + + 245 A : B F G K N P S + + + 246 + + + 111 A C D E F G K L N P Q T + + Creator + + + + 700 A B C D F G K L M N O P Q R S T + + Contributor + + + + 710 A B B C D F G K L N P T + + Contributor + + + + 711 A C D E F G K L N P Q S T + + Contributor + + + 655 A + + + ilu + + + 260 A + + + 260 A + + 260 B + 260 B + 1990 + 1999 + monographic + + + eng + English + + + fre + + + ger + + + +
map
+
map
+ 300 A : 300 B ; 300 C. +
+
+ 520 + 540 + C. + 500 + 530 + + 600 (100) A B C D F G K L N P Q T + + + 600 A B C D F G K L M N O P Q R S T + + + 600 X + + + 600 Y + + + 600 Z + + + 610 (110) A B B C D F G K L N P T + + + 610 A B B C D F G K L N P T + + + 610 X + + + 610 Y + + + 610 Z + + + 611 (111) A C D E F G K L N P Q T + + + 611 A C D E F G K L N P Q S T + + + 611 X + + + 611 Y + + + 611 Z + + + 630 A D F H K L O R + + + 630 X + + + 630 Y + + + 630 Z + + + 648 + + + 648 + + + 650 A + + + 650 X + + + 650 Y + + + 650 Z + + + 651 A + + + 651 X + + + 651 Y + + + 651 Z + + + 653 A + + + 653 A + + + + 752 A + 752 B + 752 C + 752 D + + + + + F K L M O R S T + N O R + P R + + + 700 A G Q + B C + D + + + + + F K L T + G P T + P + + + 710 A + B + B + C D G N + + + + + F K L S T + G P S T + P + + + 711 A C D G N Q + + + + aacr + IEN + 150127 + 20150127160330.0 + 7763100 + Converted from MARCXML to MODS version 3.5 using MARC21slim2MODS3-5.xsl (Revision 1.106 + 2014/12/19), customized for the Avalon Media System (last revised 2014/12/26) + +
diff --git a/spec/models/media_object_spec.rb b/spec/models/media_object_spec.rb index c81022917a..9124d5b7c6 100644 --- a/spec/models/media_object_spec.rb +++ b/spec/models/media_object_spec.rb @@ -750,6 +750,17 @@ it 'should override the title' do expect { media_object.descMetadata.populate_from_catalog!(bib_id, 'local') }.to change { media_object.title }.to "245 A : B F G K N P S" end + it 'should override langauge' do + expect { media_object.descMetadata.populate_from_catalog!(bib_id, 'local') }.to change { media_object.language }.to [{:code=>"eng", :text=>"English"}, {:code=>"fre", :text=>"French"}, {:code=>"ger", :text=>"German"}] + end + + context 'with lanugage text' do + let(:mods) { File.read(File.expand_path("../../fixtures/#{bib_id}.lang_text.mods",__FILE__)) } + + it 'should override langauge' do + expect { media_object.descMetadata.populate_from_catalog!(bib_id, 'local') }.to change { media_object.language }.to [{:code=>"eng", :text=>"English"}, {:code=>"fre", :text=>"French"}, {:code=>"ger", :text=>"German"}] + end + end end describe 'should strip whitespace from bib_id parameter' do let(:sru_url) { "http://zgate.example.edu:9000/db?version=1.1&operation=searchRetrieve&maximumRecords=1&recordSchema=marcxml&query=rec.id=#{bib_id}" }