diff --git a/housekeeping/correct/101_cmo.rb b/housekeeping/correct/101_cmo.rb index c53abfaf..b11ecb9f 100644 --- a/housekeeping/correct/101_cmo.rb +++ b/housekeeping/correct/101_cmo.rb @@ -1,6 +1,10 @@ +@mc = MarcConfigCache.get_configuration("person") + def preprocess_cmo(marc, obj, options) #puts "Callback to process #{obj.id}" + cmo_id = marc.first_occurance("001").content + # Remove the old 001 marc.by_tags("001").each {|t2| t2.destroy_yourself} @@ -8,10 +12,28 @@ def preprocess_cmo(marc, obj, options) # Add it in position 1 since there is a 000 in the original data marc.root.add_at(MarcNode.new("person", "001", "__TEMP__", nil), 1) + n024 = MarcNode.new("person", "024", "", @mc.get_default_indicator("024")) + + n024.add_at(MarcNode.new("person", "a", cmo_id, nil), 0 ) + n024.add_at(MarcNode.new("person", "2", "cmo", nil), 0 ) + n024.sort_alphabetically + marc.root.add_at(n024, marc.get_insert_position("024") ) + marc.by_tags("670").each do |t| + #is there a $b? + b = t.fetch_first_by_tag("b") + if b && b.content + ## Move it to an note + n680 = MarcNode.new("person", "680", "", @mc.get_default_indicator("680")) + n680.add_at(MarcNode.new("person", "a", b.content, nil), 0 ) + n680.sort_alphabetically + marc.root.add_at(n680, marc.get_insert_position("680") ) + end + a = t.fetch_first_by_tag("a") - + if !a || !a.content || a.content.empty? + puts "Remove empty #{t}" t.destroy_yourself else @@ -27,6 +49,15 @@ def preprocess_cmo(marc, obj, options) end end + marc.by_tags("024").each do |t| + a = t.fetch_first_by_tag("a") + + if !a || !a.content || a.content.empty? + puts "Remove empty #{t}" + t.destroy_yourself + end + end + return marc end @@ -35,7 +66,7 @@ def preprocess_cmo(marc, obj, options) #source_file = "CMO-MARCXML/Person/cmo_person_00000001.xml" # Minimal option set -options = {first: 0, last: 1000000, versioning: false, index:false} +options = {first: 0, last: 1000000, versioning: false, index: true} options[:new_ids] = true options[:authorities] = true