Class: MARCModel
- Inherits:
-
ASpaceExport::ExportModel
- Object
- ASpaceExport::ExportModel
- MARCModel
- Defined in:
- backend/app/exporters/models/marc21.rb
Constant Summary collapse
- ISO_3166_TO_MARC =
ANW-1416: Maps ISO-3166 country code to MARC country code
{"AE" => "ts", "AF" => "af", "AG" => "aq", "AI" => "ag", "AL" => "aa", "AM" => "ai", "AO" => "ao", "AQ" => "ay", "AR" => "ag", "AS" => "as", "AT" => "au", "AU" => "at", "AW" => "aw", "AX" => "xx", "AZ" => "aj", "BA" => "bn", "BB" => "bb", "BD" => "bg", "BE" => "be", "BF" => "xx", "BG" => "bu", "BH" => "ba", "BI" => "bd", "BJ" => "dm", "BL" => "sc", "BM" => "bm", "BN" => "bx", "BO" => "bo", "BQ" => "xx", "BR" => "bl", "BS" => "bf", "BT" => "bt", "BV" => "bv", "BW" => "bs", "BY" => "bw", "BZ" => "bh", "CA" => "xxc", "CC" => "xb", "CD" => "cg", "CF" => "cx", "CG" => "cf", "CH" => "sz", "CI" => "iv", "CK" => "cw", "CL" => "cl", "CM" => "cm", "CN" => "cc", "CO" => "ck", "CR" => "cr", "CU" => "cu", "CV" => "cv", "CW" => "co", "CX" => "xa", "CY" => "cy", "CZ" => "xr", "DE" => "gw", "DJ" => "ft", "DK" => "dk", "DM" => "dq", "DO" => "dr", "DZ" => "ae", "EC" => "ec", "EE" => "er", "EG" => "ua", "EH" => "ss", "ER" => "ea", "ES" => "sp", "ET" => "et", "FI" => "fi", "FJ" => "fj", "FK" => "fk", "FM" => "fm", "FO" => "fa", "FR" => "fr", "GA" => "go", "GB" => "xxk", "GD" => "gd", "GE" => "gs", "GF" => "gv", "GG" => "gg", "GH" => "gh", "GI" => "gi", "GL" => "gl", "GM" => "gm", "GN" => "gv", "GP" => "gp", "GQ" => "eg", "GR" => "gr", "GS" => "xs", "GT" => "gt", "GU" => "gu", "GW" => "pg", "GY" => "gy", "HK" => "xx", "HM" => "hm", "HN" => "ho", "HR" => "ci", "HT" => "ht", "HU" => "hu", "ID" => "io", "IE" => "ie", "IL" => "is", "IM" => "im", "IN" => "ii", "IO" => "bi", "IQ" => "iq", "IR" => "ir", "IS" => "ic", "IT" => "it", "JE" => "je", "JM" => "jm", "JO" => "jo", "JP" => "ja", "KE" => "ke", "KG" => "kg", "KH" => "cb", "KI" => "gb", "KM" => "cq", "KN" => "xd", "KP" => "kn", "KR" => "ko", "KW" => "ku", "KY" => "cj", "KZ" => "kz", "LA" => "xx", "LB" => "le", "LC" => "xk", "LI" => "lh", "LK" => "ce", "LR" => "lb", "LS" => "lo", "LT" => "li", "LU" => "lu", "LV" => "lv", "LY" => "ly", "MA" => "mr", "MC" => "mc", "MD" => "mv", "ME" => "mo", "MF" => "st", "MG" => "mg", "MH" => "xe", "MK" => "xn", "ML" => "ml", "MM" => "br", "MN" => "mp", "MO" => "xx", "MP" => "nw", "MQ" => "mq", "MR" => "mu", "MS" => "mj", "MT" => "mm", "MU" => "mf", "MV" => "xc", "MW" => "mw", "MX" => "mx", "MY" => "my", "MZ" => "mz", "NA" => "sx", "NC" => "nl", "NE" => "ng", "NF" => "nx", "NG" => "nr", "NI" => "nq", "NL" => "ne", "NO" => "no", "NP" => "np", "NR" => "nu", "NU" => "xh", "NZ" => "nz", "OM" => "mk", "PA" => "pn", "PE" => "pe", "PF" => "fp", "PG" => "pp", "PH" => "ph", "PK" => "pk", "PL" => "pl", "PM" => "xl", "PN" => "pc", "PR" => "pr", "PS" => "xx", "PT" => "po", "PW" => "pw", "PY" => "py", "QA" => "qa", "RE" => "re", "RO" => "rm", "RS" => "rb", "RU" => "ru", "RW" => "rw", "SA" => "su", "SB" => "bp", "SC" => "se", "SD" => "sj", "SE" => "sw", "SG" => "si", "SH" => "xj", "SI" => "xv", "SJ" => "xx", "SK" => "xo", "SL" => "si", "SM" => "sm", "SN" => "sg", "SO" => "so", "SR" => "sr", "SS" => "sd", "ST" => "sf", "SV" => "es", "SX" => "sn", "SY" => "sy", "SZ" => "xx", "TC" => "tc", "TD" => "cd", "TF" => "xx", "TG" => "tg", "TH" => "th", "TJ" => "ta", "TK" => "tl", "TL" => "em", "TM" => "tk", "TN" => "ti", "TO" => "to", "TR" => "tu", "TT" => "tr", "TV" => "tv", "TW" => "xx", "TZ" => "tz", "UA" => "un", "UG" => "ug", "UM" => "xxu", "US" => "xxu", "UY" => "uy", "UZ" => "uz", "VA" => "vc", "VC" => "xm", "VE" => "ve", "VG" => "vb", "VI" => "vi", "VN" => "vm", "VU" => "nn", "WF" => "wf", "WS" => "ws", "YE" => "ye", "YT" => "ot", "ZA" => "sa", "ZM" => "za", "ZW" => "rh"}
- @@datafield =
Class.new do
- @@subfield =
Class.new do
Instance Attribute Summary collapse
-
#controlfield_string ⇒ Object
Returns the value of attribute controlfield_string.
-
#leader_string ⇒ Object
Returns the value of attribute leader_string.
Class Method Summary collapse
-
.assemble_controlfield_string(obj) ⇒ Object
-
.df_handler(name, tag, ind1, ind2, code) ⇒ Object
-
.from_archival_object(obj, opts = {}) ⇒ Object
‘archival object’s in the abstract.
-
.from_aspace_object(obj, opts = {}) ⇒ Object
-
.from_resource(obj, opts = {}) ⇒ Object
subtypes of ‘archival object’:.
Instance Method Summary collapse
-
#datafields ⇒ Object
-
#df(*args) ⇒ Object
-
#df!(*args) ⇒ Object
-
#handle_agent_terms(terms) ⇒ Object
-
#handle_agents(linked_agents) ⇒ Object
-
#handle_ark(ark_name) ⇒ Object
-
#handle_dates(dates) ⇒ Object
-
#handle_ead_loc(ead_loc, publish, uri, slug) ⇒ Object
3/28/18: Updated: ANW-318 4/7/22: Updated: ANW-1071.
-
#handle_extents(extents) ⇒ Object
-
#handle_id(*ids) ⇒ Object
-
#handle_languages(lang_materials) ⇒ Object
-
#handle_notes(notes) ⇒ Object
-
#handle_other_creators(linked_agents) ⇒ Object
TODO: DRY this up this method is very similair to handle_primary_creator and handle_agents.
-
#handle_primary_creator(linked_agents) ⇒ Object
-
#handle_relators(relator_sfs, link) ⇒ Object
-
#handle_repo_code(repository, *finding_aid_language) ⇒ Object
-
#handle_subjects(subjects) ⇒ Object
-
#handle_title(title, linked_agents, dates) ⇒ Object
-
#include_unpublished? ⇒ Boolean
-
#initialize(include_unpublished = false) ⇒ MARCModel
constructor
A new instance of MARCModel.
-
#source_to_code(source) ⇒ Object
Methods inherited from ASpaceExport::ExportModel
#apply_map, inherited, model_for, model_for?
Constructor Details
#initialize(include_unpublished = false) ⇒ MARCModel
Returns a new instance of MARCModel.
79 80 81 82 |
# File 'backend/app/exporters/models/marc21.rb', line 79 def initialize(include_unpublished = false) @datafields = {} @include_unpublished = include_unpublished end |
Instance Attribute Details
#controlfield_string ⇒ Object
Returns the value of attribute controlfield_string
35 36 37 |
# File 'backend/app/exporters/models/marc21.rb', line 35 def controlfield_string @controlfield_string end |
#leader_string ⇒ Object
Returns the value of attribute leader_string
34 35 36 |
# File 'backend/app/exporters/models/marc21.rb', line 34 def leader_string @leader_string end |
Class Method Details
.assemble_controlfield_string(obj) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'backend/app/exporters/models/marc21.rb', line 119 def self.assemble_controlfield_string(obj) date = obj.dates[0] || {} string = obj['system_mtime'].scan(/\d{2}/)[1..3].join('') string += date['date_type'] == 'single' ? 's' : 'i' string += date['begin'] ? date['begin'][0..3] : " " string += date['end'] ? date['end'][0..3] : " " repo = obj['repository']['_resolved'] if repo.has_key?('country') && !repo['country'].empty? string += (ISO_3166_TO_MARC[repo['country']] || "xx") else string += "xx" end # If only one Language and Script subrecord its code value should be exported in the MARC 008 field position 35-37; If more than one Language and Script subrecord is recorded, a value of "mul" should be exported in the MARC 008 field position 35-37. lang_materials = obj.lang_materials languages = lang_materials.map {|l| l['language_and_script']}.compact langcode = languages.count == 1 ? languages[0]['language'] : 'mul' # variable number of spaces needed since country code could have 2 or 3 chars (35-(string.length)).times { string += ' ' } string += (langcode || '|||') string += ' d' string end |
.df_handler(name, tag, ind1, ind2, code) ⇒ Object
7 8 9 10 11 12 |
# File 'backend/app/exporters/models/marc21.rb', line 7 def self.df_handler(name, tag, ind1, ind2, code) define_method(name) do |val| df(tag, ind1, ind2).with_sfs([code, val]) end name.to_sym end |
.from_archival_object(obj, opts = {}) ⇒ Object
‘archival object’s in the abstract
98 99 100 101 102 103 |
# File 'backend/app/exporters/models/marc21.rb', line 98 def self.from_archival_object(obj, opts = {}) marc = self.from_aspace_object(obj, opts) marc.apply_map(obj, @archival_object_map) marc end |
.from_aspace_object(obj, opts = {}) ⇒ Object
93 94 95 |
# File 'backend/app/exporters/models/marc21.rb', line 93 def self.from_aspace_object(obj, opts = {}) self.new(opts[:include_unpublished]) end |
.from_resource(obj, opts = {}) ⇒ Object
subtypes of ‘archival object’:
107 108 109 110 111 112 113 114 115 116 |
# File 'backend/app/exporters/models/marc21.rb', line 107 def self.from_resource(obj, opts = {}) marc = self.from_archival_object(obj, opts) marc.apply_map(obj, @resource_map) marc.leader_string = "00000np$aa2200000 u 4500" marc.leader_string[7] = obj.level == 'item' ? 'm' : 'c' marc.controlfield_string = assemble_controlfield_string(obj) marc end |
Instance Method Details
#datafields ⇒ Object
84 85 86 |
# File 'backend/app/exporters/models/marc21.rb', line 84 def datafields @datafields.map {|k, v| v} end |
#df(*args) ⇒ Object
156 157 158 159 160 161 162 163 |
# File 'backend/app/exporters/models/marc21.rb', line 156 def df(*args) if @datafields.has_key?(args.to_s) @datafields[args.to_s] else @datafields[args.to_s] = @@datafield.new(*args) @datafields[args.to_s] end end |
#df!(*args) ⇒ Object
148 149 150 151 152 153 |
# File 'backend/app/exporters/models/marc21.rb', line 148 def df!(*args) @sequence ||= 0 @sequence += 1 @datafields[@sequence] = @@datafield.new(*args) @datafields[@sequence] end |
#handle_agent_terms(terms) ⇒ Object
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'backend/app/exporters/models/marc21.rb', line 513 def handle_agent_terms(terms) sfs = [] terms.each do |t| tag = case t['term_type'] when 'uniform_title'; 't' when 'genre_form', 'style_period'; 'v' when 'topical', 'cultural_context'; 'x' when 'temporal'; 'y' when 'geographic'; 'z' end next if tag.nil? sfs << [(tag), t['term']] end sfs end |
#handle_agents(linked_agents) ⇒ Object
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'backend/app/exporters/models/marc21.rb', line 447 def handle_agents(linked_agents) handle_primary_creator(linked_agents) handle_other_creators(linked_agents) subjects = linked_agents.select {|a| a['role'] == 'subject'} subjects.each_with_index do |link, i| next unless link["_resolved"]["publish"] || @include_unpublished subject = link['_resolved'] name = subject['display_name'] terms = link['terms'] ind2 = source_to_code(name['source']) relator_sfs = [] if link['relator'] handle_relators(relator_sfs, link['relator']) end case subject['agent_type'] when 'agent_corporate_entity' code = '610' ind1 = '2' sfs = gather_agent_corporate_subfield_mappings(name, relator_sfs, subject, terms) when 'agent_person' ind1 = name['name_order'] == 'direct' ? '0' : '1' code = '600' sfs = gather_agent_person_subfield_mappings(name, relator_sfs, subject, terms) when 'agent_family' code = '600' ind1 = '3' sfs = gather_agent_family_subfield_mappings(name, relator_sfs, subject, terms) when 'agent_software' code = '653' ind1 = ' ' sfs = [['a', name['software_name']]] end # ANW-825: Don't export $0 if $v, $x, $y, or $z are present sfs.reject! {|k| k[0] == 0 } if (['v', 'x', 'y', 'z'] - sfs.map { |k| k[0] }).length < 4 if ind2 == '7' sfs << ['2', subject['names'].first['source']] end df(code, ind1, ind2, i).with_sfs(*sfs) end end |
#handle_ark(ark_name) ⇒ Object
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'backend/app/exporters/models/marc21.rb', line 671 def handle_ark(ark_name) return if ark_name.nil? return unless [:arks_enabled] # If ARKs are enabled, add an 856 #<datafield tag="856" ind1="4" ind2="2"> # <subfield code="z">Archival Resource Key:</subfield> # <subfield code="u">ARK URL</subfield> #</datafield> if ark_url = ark_name['current'] df('856', '4', '2').with_sfs( ['z', "Archival Resource Key:"], ['u', ark_url] ) unless ark_url.nil? || ark_url.empty? end end |
#handle_dates(dates) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'backend/app/exporters/models/marc21.rb', line 230 def handle_dates(dates) return false if dates.empty? dates = [["single", "inclusive", "range"], ["bulk"]].map {|types| dates.find {|date| types.include? date['date_type'] } }.compact dates.each do |date| code = date['date_type'] == 'bulk' ? 'g' : 'f' val = nil if date['expression'] && date['date_type'] != 'bulk' val = date['expression'] elsif date['date_type'] == 'single' val = date['begin'] else val = "#{date['begin']} - #{date['end']}" end df('245', '1', '0').with_sfs([code, val]) end end |
#handle_ead_loc(ead_loc, publish, uri, slug) ⇒ Object
3/28/18: Updated: ANW-318 4/7/22: Updated: ANW-1071
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
# File 'backend/app/exporters/models/marc21.rb', line 631 def handle_ead_loc(ead_loc, publish, uri, slug) # If there is EADlocation #<datafield tag="856" ind1="4" ind2="2"> # <subfield code="z">Finding aid online:</subfield> # <subfield code="u">EADlocation</subfield> #</datafield> # if config option is set, output a second 856 with slugged (or not) PUI URL as long as it's not the same as the EADLocation #<datafield tag="856" ind1="4" ind2="2"> # <subfield code="z">Finding aid online:</subfield> # <subfield code="u">slugged URL</subfield> #</datafield> if ead_loc && !ead_loc.empty? df('856', '4', '2').with_sfs( ['z', "Finding aid online:"], ['u', ead_loc] ) end if AppConfig[:enable_public] && AppConfig[:include_pui_finding_aid_urls_in_marc_exports] && publish if AppConfig[:use_human_readable_urls] && AppConfig[:use_slug_finding_aid_urls_in_marc_exports] rec_type = uri.split('/')[3] link = AppConfig[:public_proxy_url] + "/#{rec_type}/#{slug}" else link = AppConfig[:public_proxy_url] + uri end unless link == ead_loc df!('856', '4', '2').with_sfs( ['z', "Finding aid online:"], ['u', link] ) end end end |
#handle_extents(extents) ⇒ Object
616 617 618 619 620 621 622 623 624 625 626 627 |
# File 'backend/app/exporters/models/marc21.rb', line 616 def handle_extents(extents) extents.each do |ext| e = ext['number'] t = "#{I18n.t('enumerations.extent_extent_type.'+ext['extent_type'], :default => ext['extent_type'])}" if ext['container_summary'] t << " (#{ext['container_summary']})" end df!('300').with_sfs(['a', e], ['f', t]) end end |
#handle_id(*ids) ⇒ Object
166 167 168 169 |
# File 'backend/app/exporters/models/marc21.rb', line 166 def handle_id(*ids) ids.reject! {|i| i.nil? || i.empty?} df('099', ' ', ' ').with_sfs(['a', ids.join('.')]) end |
#handle_languages(lang_materials) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'backend/app/exporters/models/marc21.rb', line 207 def handle_languages(lang_materials) # ANW-697: The Language subrecord code values should be exported in repeating subfield $a entries in the MARC 041 field. languages = lang_materials.map {|l| l['language_and_script']}.compact languages.each do |language| df('041', ' ', ' ').with_sfs(['a', language['language']]) end # ANW-697: Language Text subrecords should be exported in the MARC 546 subfield $a language_notes = lang_materials.map {|l| l['notes']}.compact.reject {|e| e == [] } if language_notes language_notes.each do |note| handle_notes(note) end end end |
#handle_notes(notes) ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'backend/app/exporters/models/marc21.rb', line 531 def handle_notes(notes) notes.each do |note| prefix = case note['type'] when 'dimensions'; "Dimensions" when 'physdesc'; "Physical Description note" when 'materialspec'; "Material Specific Details" when 'physloc'; "Location of resource" when 'phystech'; "Physical Characteristics / Technical Requirements" when 'physfacet'; "Physical Facet" when 'processinfo'; "Processing Information" when 'separatedmaterial'; "Materials Separated from the Resource" else; nil end marc_args = case note['type'] when 'arrangement', 'fileplan' ['351', 'a'] when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'processinfo', 'separatedmaterial' ['500', 'a'] when 'accessrestrict' ['506', 'a'] when 'scopecontent' ['520', '2', ' ', 'a'] when 'abstract' ['520', '3', ' ', 'a'] when 'prefercite' ['524', ' ', ' ', 'a'] when 'acqinfo' ind1 = note['publish'] ? '1' : '0' ['541', ind1, ' ', 'a'] when 'relatedmaterial' ['544', 'd'] when 'bioghist' ['545', 'a'] when 'custodhist' ind1 = note['publish'] ? '1' : '0' ['561', ind1, ' ', 'a'] when 'appraisal' ind1 = note['publish'] ? '1' : '0' ['583', ind1, ' ', 'a'] when 'accruals' ['584', 'a'] when 'altformavail' ['535', '2', ' ', 'a'] when 'originalsloc' ['535', '1', ' ', 'a'] when 'userestrict', 'legalstatus' ['540', 'a'] when 'langmaterial' ['546', 'a'] when 'otherfindaid' ['555', '0', ' ', 'a'] else nil end unless marc_args.nil? text = prefix ? "#{prefix}: " : "" text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished, true) # only create a tag if there is text to show (e.g., marked published or exporting unpublished) if text.length > 0 df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)]) end end # ANW-1350: Export bibliography notes to 581 # Bibliography notes have a different structure than the notes handled above, so they are processed separately if note['jsonmodel_type'] == "note_bibliography" if note['publish'] || @include_unpublished note['content'].each do |c| df!('581', ' ', ' ').with_sfs(['a', c]) end note['items'].each do |i| df!('581', ' ', ' ').with_sfs(['a', i]) end end end end end |
#handle_other_creators(linked_agents) ⇒ Object
TODO: DRY this up this method is very similair to handle_primary_creator and handle_agents
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'backend/app/exporters/models/marc21.rb', line 390 def handle_other_creators(linked_agents) primary_creator = linked_agents.find {|a| a['is_primary'] && a['role'] == 'creator'} # if there is NOT a primary creator, automatically exclude the first in the list # of creators to get 7xx tags since it was chosen as primary in #handle_primary_creator above if primary_creator creators = linked_agents.select {|a| a['role'] == 'creator'} || [] else creators = linked_agents.select {|a| a['role'] == 'creator'}[1..-1] || [] end creators = creators + linked_agents.select {|a| a['role'] == 'source'} creators.each_with_index do |link, i| next unless link["_resolved"]["publish"] || @include_unpublished next if link['is_primary'] creator = link['_resolved'] name = creator['display_name'] role = link['role'] relator_sfs = [] if link['relator'] handle_relators(relator_sfs, link['relator']) elsif role == 'source' relator_sfs << ['e', 'former owner'] else relator_sfs << ['e', 'creator'] end ind2 = ' ' case creator['agent_type'] when 'agent_corporate_entity' code = '710' ind1 = '2' sfs = gather_agent_corporate_subfield_mappings(name, relator_sfs, creator) when 'agent_person' ind1 = name['name_order'] == 'direct' ? '0' : '1' code = '700' sfs = gather_agent_person_subfield_mappings(name, relator_sfs, creator) when 'agent_family' ind1 = '3' code = '700' sfs = gather_agent_family_subfield_mappings(name, relator_sfs, creator) end df(code, ind1, ind2, i).with_sfs(*sfs) end end |
#handle_primary_creator(linked_agents) ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'backend/app/exporters/models/marc21.rb', line 337 def handle_primary_creator(linked_agents) # ANW-504: get look for primary flag and creator role to find primary agent primary_creator = linked_agents.find {|a| a['is_primary'] && a['role'] == 'creator'} # use primary creator as 1xx agent, if present link = nil if primary_creator link = primary_creator else # otherwise, use first found with role = creator link = linked_agents.find {|a| a['role'] == 'creator'} end return nil unless link return nil unless link["_resolved"]["publish"] || @include_unpublished creator = link['_resolved'] name = creator['display_name'] ind2 = ' ' relator_sfs = [] if link['relator'] handle_relators(relator_sfs, link['relator']) else relator_sfs << ['e', 'creator'] end case creator['agent_type'] when 'agent_corporate_entity' code = '110' ind1 = '2' sfs = gather_agent_corporate_subfield_mappings(name, relator_sfs, creator) when 'agent_person' ind1 = name['name_order'] == 'direct' ? '0' : '1' code = '100' sfs = gather_agent_person_subfield_mappings(name, relator_sfs, creator) when 'agent_family' code = '100' ind1 = '3' sfs = gather_agent_family_subfield_mappings(name, relator_sfs, creator) end df(code, ind1, ind2).with_sfs(*sfs) end |
#handle_relators(relator_sfs, link) ⇒ Object
502 503 504 505 506 507 508 509 510 |
# File 'backend/app/exporters/models/marc21.rb', line 502 def handle_relators(relator_sfs, link) relator = I18n.t("enumerations.linked_agent_archival_record_relators.#{link}") relator_sfs << ['4', link] unless relator.to_s.include?('translation missing') relator_sfs << ['e', relator] end return relator_sfs end |
#handle_repo_code(repository, *finding_aid_language) ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'backend/app/exporters/models/marc21.rb', line 252 def handle_repo_code(repository, *finding_aid_language) repo = repository['_resolved'] return false unless repo sfa = repo['org_code'] ? repo['org_code'] : "Repository: #{repo['repo_code']}" # ANW-529: options for 852 datafield: # 1.) $a => org_code || repo_name # 2.) $a => $parent_institution_name && $b => repo_name if repo['parent_institution_name'] subfields_852 = [ ['a', repo['parent_institution_name']], ['b', repo['name']] ] elsif repo['org_code'] subfields_852 = [ ['a', repo['org_code']], ] else subfields_852 = [ ['a', repo['name']] ] end df('852', ' ', ' ').with_sfs(*subfields_852) df('040', ' ', ' ').with_sfs(['a', repo['org_code']], ['b', finding_aid_language[0]], ['c', repo['org_code']]) if repo['org_code'] df('049', ' ', ' ').with_sfs(['a', repo['org_code']]) end end |
#handle_subjects(subjects) ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'backend/app/exporters/models/marc21.rb', line 290 def handle_subjects(subjects) subjects.each do |link| subject = link['_resolved'] term, *terms = subject['terms'] code, ind2 = case term['term_type'] when 'uniform_title' ['630', source_to_code(subject['source'])] when 'temporal' ['648', source_to_code(subject['source'])] when 'topical' ['650', source_to_code(subject['source'])] when 'geographic', 'cultural_context' ['651', source_to_code(subject['source'])] when 'genre_form', 'style_period' ['655', source_to_code(subject['source'])] when 'occupation' ['656', '7'] when 'function' ['656', '7'] else ['650', source_to_code(subject['source'])] end sfs = [['a', term['term']]] terms.each do |t| tag = case t['term_type'] when 'uniform_title'; 't' when 'genre_form', 'style_period'; 'v' when 'topical', 'cultural_context'; 'x' when 'temporal'; 'y' when 'geographic'; 'z' end sfs << [tag, t['term']] end if ind2 == '7' sfs << ['2', subject['source']] end sfs << ['0', subject['authority_id']] ind1 = code == '630' ? "0" : " " df!(code, ind1, ind2).with_sfs(*sfs) end end |
#handle_title(title, linked_agents, dates) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'backend/app/exporters/models/marc21.rb', line 172 def handle_title(title, linked_agents, dates) creator = linked_agents.find {|a| a['role'] == 'creator'} date_codes = [] # process dates first, if defined. unless dates.empty? dates = [["single", "inclusive", "range"], ["bulk"]].map {|types| dates.find {|date| types.include? date['date_type'] } }.compact dates.each do |date| code, val = nil code = date['date_type'] == 'bulk' ? 'g' : 'f' if date['expression'] val = date['expression'] elsif date['end'] val = "#{date['begin']} - #{date['end']}" else val = "#{date['begin']}" end date_codes.push([code, val]) end end ind1 = creator.nil? ? "0" : "1" if date_codes.length > 0 # we want to pass in all our date codes as separate subfield tags # e.g., with_sfs(['a', title], [code1, val1], [code2, val2]... [coden, valn]) df('245', ind1, '0').with_sfs(['a', title + ","], *date_codes) else df('245', ind1, '0').with_sfs(['a', title]) end end |
#include_unpublished? ⇒ Boolean
88 89 90 |
# File 'backend/app/exporters/models/marc21.rb', line 88 def include_unpublished? @include_unpublished end |
#source_to_code(source) ⇒ Object
286 287 288 |
# File 'backend/app/exporters/models/marc21.rb', line 286 def source_to_code(source) ASpaceMappings::MARC21.get_marc_source_code(source) end |