Skip to content

Commit

Permalink
Changes label to archival item for PULFA record
Browse files Browse the repository at this point in the history
Co-authored-by: Jane Sandberg <[email protected]>
  • Loading branch information
ishasinha1 and sandbergja committed Dec 6, 2024
1 parent f3ace73 commit 89b65f2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
17 changes: 12 additions & 5 deletions marc_to_solr/lib/format/bib_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ def initialize(record)
ldr = record.leader
type = ldr[6]
lev = ldr[7]
check_pulfa = record['035'] && record['035']['a'].start_with?('(PULFA)')
check_dacs = record['040'] && record['040']['e'] == 'dacs'
@code = []
@code << self.determine_bib_code(type, lev)
@code << self.determine_bib_code(type, lev, check_pulfa, check_dacs)
@code << 'WM' if microform? record
@code = @code.flatten
# Removed per @tampakis recommendation to keep items with an unknown format
# value out of the format facet
# @code << 'XX' if @code.empty?
end

def determine_bib_code(type, lev)
def determine_bib_code(type, lev, check_pulfa, check_dacs)
format = []
format << "AJ" if bibformat_jn(type, lev) # journal
format << "CF" if bibformat_cf(type, lev) # data file
Expand All @@ -31,13 +33,14 @@ def determine_bib_code(type, lev)
format << "AU" if bibformat_au(type, lev) # audio
format << "MP" if bibformat_mp(type, lev) # map
format << "MW" if bibformat_mw(type, lev) # manuscript
format << "BK" if bibformat_bk(type, lev) # book
format << "BK" if bibformat_bk(type, lev, check_pulfa) # book
format << "DB" if bibformat_db(type, lev) # databases
format << "XA" if bibformat_xa(type, lev, check_pulfa, check_dacs) # archival item
format
end

def bibformat_bk(type, lev)
(type == 't') || ((type == 'a') && %w[a b c d m].include?(lev))
def bibformat_bk(type, lev, check_pulfa)
((type == 't') && !check_pulfa) || ((type == 'a') && %w[a b c d m].include?(lev))
end

def bibformat_db(type, lev)
Expand Down Expand Up @@ -76,6 +79,10 @@ def bibformat_mw(type, _lev)
%w[d f p t].include?(type)
end

def bibformat_xa(type, lev, check_pulfa, check_dacs)
(type == 't') && (lev == 'm') && check_pulfa && check_dacs
end

private

def microform?(record)
Expand Down
1 change: 1 addition & 0 deletions marc_to_solr/translation_maps/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"VL" => "Motion picture",
"VM" => "Visual material",
"VP" => "Video/Projected medium",
"XA" => "Archival Item",
"WM" => "Microform",
"XC" => "Conference",
"XS" => "Statistics",
Expand Down
33 changes: 31 additions & 2 deletions spec/marc_to_solr/lib/format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,39 @@
'Musical score' => ['c ', 'd '],
'Audio' => ['i ', 'j '],
'Map' => ['e '],
'Manuscript' => ['d ', 'f ', 't ', 'p ']
# 'Unknown' => [' ', 'zz']
'Manuscript' => ['d ', 'f ', 't ', 'p '],
'Archival Item' => ['tm']
}.each do |k, v|
it "properly determines format for #{k}" do
v.each do |c|
marc.leader[6..7] = c

if marc.leader[6] == 'a'
field = MARC::DataField.new('035','0','0',
MARC::Subfield.new('a', '(PULFA)'))
marc.append(field)
end

if c == 'tm'
field = MARC::DataField.new('035','0','0',
MARC::Subfield.new('a', '(PULFA)'))
marc.append(field)
field = MARC::DataField.new('040','0','0',
MARC::Subfield.new('e', 'dacs'))
marc.append(field)
end
fmt = Format.new(marc).bib_format
expect(Traject::TranslationMap.new("format").translate_array!(fmt)).to include k
end
end
end

let(:marc) { MARC::Record.new }

{
'Book' => ['tm']
}.each do |k, v|
it "properly determines format for 'tm' when the record is non-PULFA" do
v.each do |c|
marc.leader[6..7] = c
fmt = Format.new(marc).bib_format
Expand Down

0 comments on commit 89b65f2

Please sign in to comment.