Skip to content

Commit

Permalink
Fixed ID resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
derrekc committed Jun 20, 2024
1 parent 230d5df commit 55ef420
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.19.7
0.5.19.9
27 changes: 18 additions & 9 deletions lib/data/duke/traject_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
#
# If we do match (and you'll see this below), the 3rd element of our
# capture will hold the old-style Aleph 'sysid'
mms_splits = id.scan(/^(DUKE)?(\d{2})(\d{9})(\d{7})/)
# mms_splits = id.scan(/^(DUKE)?(\d{2})(\d{9})(\d{7})/)

mms_splits = id.scan(/^(DUKE)?(99)(\d+)(0108501)/)

# If the split result is empty, this represents a new Alma-born record
# Otherwise, get the old Aleph id from the split string
id = mms_splits.empty? ? id[2..] : mms_splits[0][2]
# Otherwise, get the old Aleph id from the split string.
# -
# We'll maintain the entire MMS ID string
id = mms_splits.empty? ? id : mms_splits[0][2].rjust(9, '0')
id.match(/DUKE.*/) ? id : "DUKE#{id}"
end
Logging.mdc['record_id'] = acc.first
Expand All @@ -25,6 +29,7 @@
# Local ID
######

# NOTE is this where we set 'local_id' to the MMS ID?
to_field 'local_id' do |rec, acc, context|
local_id = {
value: context.output_hash.fetch('id', []).first,
Expand All @@ -51,6 +56,12 @@

to_field "oclc_number", oclc_number

################################################
# MMS ID
######

to_field "mms_id", mms_id

################################################
# Serials Solutions Number
######
Expand Down Expand Up @@ -92,19 +103,17 @@
#########
to_field 'donor', extract_marc("796z")


# ################################################
# # Items
# # Holdings
# ######

to_field 'items', extract_items

to_field 'holdings', extract_holdings

# ################################################
# # Holdings
# # Items
# ######

to_field 'holdings', extract_holdings
to_field 'items', extract_items


# ################################################
Expand Down
6 changes: 5 additions & 1 deletion lib/marc_to_argot/macros/duke/items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Items
######

def extract_items
puts "---------- [extract items] ----------"
lambda do |rec, acc, ctx|
lcc_top = Set.new
items = []
Expand Down Expand Up @@ -138,11 +139,13 @@ def online_item?(item)
######

def extract_holdings
puts "---------- [extract holdings] ----------"
lambda do |rec, acc, ctx|
# adding a 'holdings' list (dlc32)
holdings = []
Traject::MarcExtractor.cached('852', alternate_script: false)
.each_matching_line(rec) do |field, spec, extractor|
puts field.subfields
holding = {}
# puts field.subfields
field.subfields.each do |sf|
Expand All @@ -165,7 +168,8 @@ def extract_holdings
holding['notes'] ||= []
holding['notes'] << sf.value
when 'x'
# per Stewart Engart (changed 'availability' key to 'status' - dlc32
# per Stewart Engart
# (changed 'availability' key to 'status' - dlc32)
holding['status'] = sf.value
when 'E'
holding['notes'] ||= []
Expand Down
9 changes: 9 additions & 0 deletions lib/marc_to_argot/macros/duke_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def rollup_id
end
end

def mms_id
lambda do |rec, acc|
if (field001 = Traject::MarcExtractor.cached('001'))
extracted_mms_id = field001.extract(rec).first
acc << extracted_mms_id unless extracted_mms_id.nil? || extracted_mms_id.empty?
end
end
end

def primary_oclc
lambda do |rec, acc|
if field_035q = Traject::MarcExtractor.cached("035q")
Expand Down

0 comments on commit 55ef420

Please sign in to comment.