Module: MarcXMLAuthAgentBaseMap
- Defined in:
- backend/app/converters/lib/marcxml_auth_agent_base_map.rb
Instance Method Summary collapse
-
#agent_corporate_entity_base(import_events, import_subjects) ⇒ Object
-
#agent_corporate_entity_name_components_map ⇒ Object
-
#agent_corporate_entity_name_map(obj, rel) ⇒ Object
-
#agent_family_base(import_events, import_subjects) ⇒ Object
-
#agent_family_name_components_map ⇒ Object
-
#agent_family_name_map(obj, rel) ⇒ Object
-
#agent_function_map ⇒ Object
-
#agent_gender_map ⇒ Object
-
#agent_occupation_map ⇒ Object
-
#agent_person_base(import_events, import_subjects) ⇒ Object
-
#agent_person_name_components_map ⇒ Object
-
#agent_person_name_map(obj, rel) ⇒ Object
-
#agent_record_control_map ⇒ Object
-
#agent_record_identifiers_base_map(xpath) ⇒ Object
-
#agent_sources_map ⇒ Object
-
#agent_topic_map ⇒ Object
-
#associated_country_map ⇒ Object
-
#BASE_RECORD_MAP(opts = {:import_events => false, :import_subjects => false}) ⇒ Object
import_events determines whether maintenance events are imported import_subjects determines whether subjects are imported.
-
#bioghist_note_map ⇒ Object
-
#convention_declaration_map ⇒ Object
-
#dates_map(rel = :dates_of_existence) ⇒ Object
-
#expression_date_for(node, subfields) ⇒ Object
-
#find_relationship(node, type) ⇒ Object
-
#maintenance_history_map ⇒ Object
-
#other_associated_place_map ⇒ Object
-
#place_of_birth_map ⇒ Object
-
#place_of_death_map ⇒ Object
-
#place_of_residence_map ⇒ Object
-
#related_agent_map(type) ⇒ Object
-
#set_auth_id(node) ⇒ Object
Sometimes we need to create more than one subject from a MARC field with a subfield 0, but the subject creation will fail if you try to create subjects with duplicate authority ids.
-
#set_maintenance_status(pos_5) ⇒ Object
-
#set_primary_identifier(node) ⇒ Object
-
#set_record_language ⇒ Object
-
#shared_subrecord_map(import_events, import_subjects) ⇒ Object
-
#structured_date_for(node, subfields) ⇒ Object
-
#subject_map(terms, rel = :subjects) ⇒ Object
usually, rel will be :subjects, but in some cases it will be :places.
-
#subject_terms_map(term_type, _subfield) ⇒ Object
-
#trim(property, trailing_char = ',', remove_chars = []) ⇒ Object
-
#used_language_map ⇒ Object
Instance Method Details
#agent_corporate_entity_base(import_events, import_subjects) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 43 def agent_corporate_entity_base(import_events, import_subjects) c = { 'self::datafield' => agent_corporate_entity_name_map(:name_corporate_entity, :names), "parent::record/datafield[@tag='410' or @tag='411']" => agent_corporate_entity_name_map(:name_corporate_entity, :names) }.merge(shared_subrecord_map(import_events, import_subjects)) if import_subjects c.merge!({ "parent::record/datafield[@tag='372']/subfield[@code='a']" => agent_function_map }) end c end |
#agent_corporate_entity_name_components_map ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 199 def agent_corporate_entity_name_components_map { "self::datafield[@ind1='1']" => proc { |name, _node| name[:jurisdiction] = true }, "descendant::subfield[@code='a']" => proc { |name, node| val = node.inner_text if node.parent.attr('tag') == '110' || node.parent.attr('tag') == '410' || node.parent.attr('tag') == '510' name[:conference_meeting] = false elsif node.parent.attr('tag') == '111' || node.parent.attr('tag') == '411' || node.parent.attr('tag') == '511' name[:conference_meeting] = true end name[:authorized] = if node.parent.attr('tag') == '110' || node.parent.attr('tag') == '111' true else false end name[:primary_name] = val.chomp('.') }, "self::datafield[@tag='110' or @tag='410' or @tag='510']" => proc { |name, node| subordinate_names = [] sf_bs = node.search("./subfield[@code='b']") sf_bs.each do |b| subordinate_names << b.inner_text end name[:subordinate_name_1] = subordinate_names.shift name[:subordinate_name_2] = subordinate_names.join('. ') }, "descendant::subfield[@code='c']" => proc { |name, node| val = node.inner_text name[:location] = val }, "descendant::subfield[@code='d']" => proc { |name, node| val = node.inner_text name[:dates] = val }, "descendant::subfield[@code='n']" => trim('number', '.', ['(', ')', ':']), "descendant::subfield[@code='g']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, "descendant::subfield[@code='e']" => proc { |name, node| val = node.inner_text name[:subordinate_name_1] = val if node.parent.attr('tag') == '111' || node.parent.attr('tag') == '411' || node.parent.attr('tag') == '511' }, "descendant::subfield[@code='q']" => proc { |name, node| val = node.inner_text name[:subordinate_name_2] = val if node.parent.attr('tag') == '411' || node.parent.attr('tag') == '511' name[:qualifier] = "Name of meeting following jurisdiction name entry element: " + val if node.parent.attr('tag') == '111' } } end |
#agent_corporate_entity_name_map(obj, rel) ⇒ Object
139 140 141 142 143 144 145 146 147 148 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 139 def agent_corporate_entity_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_corporate_entity_name_components_map, :defaults => { :name_order => 'direct' } } end |
#agent_family_base(import_events, import_subjects) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 58 def agent_family_base(import_events, import_subjects) f = { 'self::datafield' => agent_family_name_map(:name_family, :names), "parent::record/datafield[@tag='400' and @ind1='3']" => agent_family_name_map(:name_family, :names) }.merge(shared_subrecord_map(import_events, import_subjects)) if import_subjects f.merge!({ "parent::record/datafield[@tag='372']/subfield[@code='a']" => agent_function_map }) end f end |
#agent_family_name_components_map ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 258 def agent_family_name_components_map { "descendant::subfield[@code='a']" => proc { |name, node| name[:authorized] = node.parent.attr('tag') == '100' val = node.inner_text name[:family_name] = val }, "descendant::subfield[@code='b']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, "descendant::subfield[@code='c']" => trim('qualifier', ',', ['(', ')']), "descendant::subfield[@code='d']" => trim('dates', ':'), "descendant::subfield[@code='g']" => proc { |name, node| val = node.inner_text name[:qualifier] = val } } end |
#agent_family_name_map(obj, rel) ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 150 def agent_family_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_family_name_components_map, :defaults => { :name_order => 'direct' } } end |
#agent_function_map ⇒ Object
724 725 726 727 728 729 730 731 732 733 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 724 def agent_function_map { :obj => :agent_function, :rel => :agent_functions, :map => { 'self::subfield' => subject_map(subject_terms_map('function', 'a')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) } } end |
#agent_gender_map ⇒ Object
735 736 737 738 739 740 741 742 743 744 745 746 747 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 735 def agent_gender_map { :obj => :agent_gender, :rel => :agent_genders, :map => { 'self::subfield' => proc { |gender, node| val = node.inner_text gender['gender'] = val }, "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) } } end |
#agent_occupation_map ⇒ Object
702 703 704 705 706 707 708 709 710 711 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 702 def agent_occupation_map { :obj => :agent_occupation, :rel => :agent_occupations, :map => { 'self::subfield' => subject_map(subject_terms_map('occupation', 'a')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) } } end |
#agent_person_base(import_events, import_subjects) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 27 def agent_person_base(import_events, import_subjects) p = { 'self::datafield' => agent_person_name_map(:name_person, :names), "parent::record/datafield[@tag='400' and (@ind1='1' or @ind1='0')]" => agent_person_name_map(:name_person, :names), "parent::record/datafield[@tag='375']/subfield[@code='a']" => agent_gender_map }.merge(shared_subrecord_map(import_events, import_subjects)) if import_subjects p.merge!({ "parent::record/datafield[@tag='372']/subfield[@code='a']" => agent_topic_map }) end p end |
#agent_person_name_components_map ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 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 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 161 def agent_person_name_components_map { "descendant::subfield[@code='a']" => proc { |name, node| val = node.inner_text if node.parent.attr('ind1') == '0' delim = ' ' name[:name_order] = 'direct' elsif node.parent.attr('ind1') == '1' delim = ', ' name[:name_order] = 'inverted' end name[:authorized] = node.parent.attr('tag') == '100' nom_parts = val.split(delim, 2) name[:primary_name] = nom_parts[0].chomp(',') name[:rest_of_name] = nom_parts[1].chomp(',') if nom_parts[1] }, "descendant::subfield[@code='b']" => trim('number'), "descendant::subfield[@code='c']" => trim('title'), "descendant::subfield[@code='d']" => trim('dates'), "descendant::subfield[@code='g']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, "descendant::subfield[@code='q']" => trim('fuller_form', ',', ['(', ')']), "parent::record/datafield[@tag='378']/subfield[@code='q']" => proc { |name, node| if name[:authorized] val = node.inner_text name[:fuller_form] = val if name[:fuller_form].nil? end } } end |
#agent_person_name_map(obj, rel) ⇒ Object
128 129 130 131 132 133 134 135 136 137 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 128 def agent_person_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_person_name_components_map, :defaults => { :name_order => 'direct' } } end |
#agent_record_control_map ⇒ Object
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 335 336 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 387 388 389 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 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 309 def agent_record_control_map { :obj => :agent_record_control, :rel => :agent_record_controls, :map => { 'self::leader' => proc { |arc, node| leader_text = node.inner_text arc['maintenance_status'] = set_maintenance_status(leader_text[5]) }, "parent::record/datafield[@tag='040']/subfield[@code='a']" => proc { |arc, node| arc['maintenance_agency'] = node.inner_text }, "parent::record/controlfield[@tag='003']" => proc { |arc, node| unless arc['maintenance_agency'] arc['maintenance_agency'] = node.inner_text end }, "parent::record/datafield[@tag='040']" => set_record_language(), "parent::record/controlfield[@tag='008']" => proc { |arc, node| tag8_content = node.inner_text unless arc['language'] arc['language'] = case String(node&.inner_text)[8] when 'b' 'mul' when 'e' 'eng' when 'f' 'fre' end end case tag8_content[7] when 'a' romanization = 'int_std' when 'b' romanization = 'nat_std' when 'c' romanization = 'nl_assoc_std' when 'd' romanization = 'nl_bib_agency_std' when 'e' romanization = 'local_std' when 'f' romanization = 'unknown_std' when 'g' romanization = 'conv_rom_cat_agency' when 'n' romanization = 'not_applicable' when '|' romanization = '' end case tag8_content[28] when '#' gov_agency = 'ngo' when 'a' gov_agency = 'sac' when 'c' gov_agency = 'multilocal' when 'f' gov_agency = 'fed' when 'I' gov_agency = 'int_gov' when 'l' gov_agency = 'local' when 'm' gov_agency = 'multistate' when 'o' gov_agency = 'undetermined' when 's' gov_agency = 'provincial' when 'u' gov_agency = 'unknown' when 'z' gov_agency = 'other' when '|' gov_agency = 'unknown' end case tag8_content[29] when 'a' ref_eval = 'tr_consistent' when 'b' ref_eval = 'tr_inconsistent' when 'n' ref_eval = 'not_applicable' when '|' ref_eval = 'natc' end case tag8_content[32] when 'a' name_type = 'differentiated' when 'b' name_type = 'undifferentiated' when 'n' name_type = 'not_applicable' when '|' name_type = 'natc' end case tag8_content[33] when 'a' lod = 'fully_established' when 'b' lod = 'memorandum' when 'c' lod = 'provisional' when 'd' lod = 'preliminary' when 'n' lod = 'not_applicable' when '|' lod = 'natc' end case tag8_content[38] when '#' mod_record = 'not_modified' when 's' mod_record = 'shortened' when 'x' mod_record = 'missing_characters' when '|' mod_record = 'natc' end case tag8_content[39] when '#' catalog_source = 'nat_bib_agency' when 'c' catalog_source = 'ccp' when 'd' catalog_source = 'other' when 'u' catalog_source = 'unknown' when '|' catalog_source = 'natc' end arc['romanization'] = romanization arc['government_agency_type'] = gov_agency arc['reference_evaluation'] = ref_eval arc['name_type'] = name_type arc['level_of_detail'] = lod arc['modified_record'] = mod_record arc['cataloging_source'] = catalog_source } } } end |
#agent_record_identifiers_base_map(xpath) ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 482 def agent_record_identifiers_base_map(xpath) { :obj => :agent_record_identifier, :rel => :agent_record_identifiers, :map => { xpath => proc { |ari, node| val = node.inner_text ari['record_identifier'] = val ari['primary_identifier'] = set_primary_identifier(node) if node.parent.attr('tag') == '010' ari['source'] = 'naf' ari['identifier_type'] = 'loc' elsif node.parent.attr('tag') == '016' ari['source'] = 'lac' if node.parent.attr('ind1') == '#' end if node.parent.attr('tag') == '035' && val.start_with?('(DLC)') ari['source'] = 'naf' ari['identifier_type'] = 'loc' end if node.parent.attr('ind1') == '7' sf_2 = (node.parent).at_xpath("subfield[@code='2']") ari['source'] = sf_2.inner_text if sf_2 ari['identifier_type'] = 'local' end } }, :defaults => { :source => 'local', :primary_identifier => false } } end |
#agent_sources_map ⇒ Object
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 766 def agent_sources_map { :obj => :agent_sources, :rel => :agent_sources, :map => { "descendant::subfield[@code='b']" => proc { |as, node| val = node.inner_text as['descriptive_note'] = val }, "descendant::subfield[@code='a']" => proc { |as, node| val = node.inner_text as['source_entry'] = val }, "descendant::subfield[@code='u']" => proc { |as, node| val = node.inner_text as['file_uri'] = val } } } end |
#agent_topic_map ⇒ Object
713 714 715 716 717 718 719 720 721 722 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 713 def agent_topic_map { :obj => :agent_topic, :rel => :agent_topics, :map => { 'self::subfield' => subject_map(subject_terms_map('topical', 'a')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) } } end |
#associated_country_map ⇒ Object
660 661 662 663 664 665 666 667 668 669 670 671 672 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 660 def associated_country_map { :obj => :agent_place, :rel => :agent_places, :map => { 'self::subfield' => subject_map(subject_terms_map('geographic', 'c')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) }, :defaults => { :place_role => 'assoc_country' } } end |
#BASE_RECORD_MAP(opts = {:import_events => false, :import_subjects => false}) ⇒ Object
import_events determines whether maintenance events are imported import_subjects determines whether subjects are imported
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 4 def BASE_RECORD_MAP(opts = {:import_events => false, :import_subjects => false}) import_events = opts[:import_events] import_subjects = opts[:import_subjects] { # AGENT PERSON "//datafield[@tag='100' and (@ind1='1' or @ind1='0')]" => { :obj => :agent_person, :map => agent_person_base(import_events, import_subjects) }, # AGENT CORPORATE ENTITY "//datafield[@tag='110' or @tag='111']" => { :obj => :agent_corporate_entity, :map => agent_corporate_entity_base(import_events, import_subjects) }, # AGENT FAMILY "//datafield[@tag='100' and @ind1='3']" => { :obj => :agent_family, :map => agent_family_base(import_events, import_subjects) } } end |
#bioghist_note_map ⇒ Object
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 787 def bioghist_note_map { :obj => :note_bioghist, :rel => :notes, :map => { 'self::datafield' => proc { |note, node| if node.attr('ind1') == '0' note['label'] = 'Biographical note' elsif node.attr('ind1') == '1' note['label'] = 'Administrative history' end }, "descendant::subfield[@code='a']" => proc { |note, node| val = node.inner_text sn = ASpaceImport::JSONModel(:note_abstract).new({ :content => [val] }) note['subnotes'] << sn }, "descendant::subfield[@code='b']" => proc { |note, node| val = node.inner_text sn = ASpaceImport::JSONModel(:note_text).new({ :content => val }) note['subnotes'] << sn } } } end |
#convention_declaration_map ⇒ Object
549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 549 def convention_declaration_map { :obj => :agent_conventions_declaration, :rel => :agent_conventions_declarations, :map => { 'self::subfield' => proc { |acd, node| val = node.inner_text acd['name_rule'] = val } } } end |
#dates_map(rel = :dates_of_existence) ⇒ Object
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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 588 def dates_map(rel = :dates_of_existence) { :obj => :structured_date_label, :rel => rel, :map => { 'self::datafield' => proc { |sdl, node| date_begin = structured_date_for(node, ['f', 'q', 's']) date_end = structured_date_for(node, ['g', 'r', 't']) date_begin_expression = expression_date_for(node, ['f', 'q', 's']) date_end_expression = expression_date_for(node, ['g', 'r', 't']) date_type = if ((date_begin && date_end) && (date_end.to_i > date_begin.to_i)) || (date_begin_expression && date_end_expression) 'range' else 'single' end if date_type == 'single' sd = ASpaceImport::JSONModel(:structured_date_single).new( { :date_standardized => date_begin || date_end, :date_expression => date_begin_expression || date_end_expression, :date_role => date_begin ? 'begin' : 'end' } ) elsif date_type == 'range' sd = ASpaceImport::JSONModel(:structured_date_range).new( { :begin_date_standardized => date_begin, :end_date_standardized => date_end, :begin_date_expression => date_begin_expression, :end_date_expression => date_end_expression } ) end sdl[:date_label] = 'existence' sdl[:date_type_structured] = date_type sdl[:"structured_date_#{date_type}"] = sd } } } end |
#expression_date_for(node, subfields) ⇒ Object
579 580 581 582 583 584 585 586 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 579 def expression_date_for(node, subfields) date = nil subfields.each do |sc| date_node = node.at_xpath("subfield[@code='#{sc}']") date = date_node.inner_text unless date_node.nil? end date end |
#find_relationship(node, type) ⇒ Object
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 858 def find_relationship(node, type) case node.inner_text[0] when 'a' relator = 'is_earlier_form_of' relationship_type = 'agent_relationship_earlierlater' when 'b' relator = 'is_later_form_of' relationship_type = 'agent_relationship_earlierlater' when 'd' relator = 'is_identified_with' specific_relator = 'Acronym' relationship_type = 'agent_relationship_identity' when 'f' relator = 'is_associative_with' specific_relator = 'Musical composition' relationship_type = 'agent_relationship_associative' when 'g' relator = 'is_associative_with' specific_relator = 'Broader term' relationship_type = 'agent_relationship_associative' when 'h' relator = 'is_associative_with' specific_relator = 'Narrower term' relationship_type = 'agent_relationship_associative' when 't' # Have to ensure both the base record and related record are corp entities if type == 'corporate_entity' && !node.search("parent::record/datafield[@tag='110']").empty? relator = 'is_superior_of' specific_relator = 'Immediate parent body' relationship_type = 'agent_relationship_subordinatesuperior' end else relator = 'is_associative_with' relationship_type = 'agent_relationship_associative' end [relator, specific_relator, relationship_type] end |
#maintenance_history_map ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 518 def maintenance_history_map { :obj => :agent_maintenance_history, :rel => :agent_maintenance_histories, :map => { 'self::controlfield' => proc { |amh, node| tag5_content = node.inner_text amh['event_date'] = tag5_content[0..7] amh['maintenance_event_type'] = 'created' amh['maintenance_agent_type'] = 'machine' }, "parent::record/controlfield[@tag='008']" => proc { |amh, node| tag8_content = node.inner_text amh['event_date'] = '19' + tag8_content[0..5] amh['maintenance_event_type'] = 'created' amh['maintenance_agent_type'] = 'machine' }, "parent::record/datafield[@tag='040']/subfield[@code='d']" => proc { |amh, node| val = node.inner_text val.empty? ? 'Missing in File' : val amh['agent'] = val } }, :defaults => { :agent => 'Missing in File' } } end |
#other_associated_place_map ⇒ Object
688 689 690 691 692 693 694 695 696 697 698 699 700 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 688 def other_associated_place_map { :obj => :agent_place, :rel => :agent_places, :map => { 'self::subfield' => subject_map(subject_terms_map('geographic', 'f')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) }, :defaults => { :place_role => 'other_assoc' } } end |
#place_of_birth_map ⇒ Object
632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 632 def place_of_birth_map { :obj => :agent_place, :rel => :agent_places, :map => { 'self::subfield' => subject_map(subject_terms_map('geographic', 'a')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) }, :defaults => { :place_role => 'place_of_birth' } } end |
#place_of_death_map ⇒ Object
646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 646 def place_of_death_map { :obj => :agent_place, :rel => :agent_places, :map => { 'self::subfield' => subject_map(subject_terms_map('geographic', 'b')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) }, :defaults => { :place_role => 'place_of_death' } } end |
#place_of_residence_map ⇒ Object
674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 674 def place_of_residence_map { :obj => :agent_place, :rel => :agent_places, :map => { 'self::subfield' => subject_map(subject_terms_map('geographic', 'e')), "parent::datafield[descendant::subfield[@code='s' or @code='t']]" => dates_map(:dates) }, :defaults => { :place_role => 'residence' } } end |
#related_agent_map(type) ⇒ Object
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 819 def (type) { :obj => :"agent_#{type}", :rel => proc { |agent, rel_agent| agent[:related_agents] << { :relator => rel_agent['_relator'] || 'is_associative_with', :jsonmodel_type => rel_agent['_jsonmodel_type'] || 'agent_relationship_associative', :specific_relator => rel_agent['_specific_relator'], :relationship_uri => rel_agent['_relationship_uri'], :description => rel_agent['_description'], :ref => rel_agent.uri } }, :map => { "descendant::subfield[@code='w']" => proc { |agent, node| relator, specific_relator, relationship_type = find_relationship(node, type) agent['_relator'] = relator agent['_specific_relator'] = specific_relator agent['_jsonmodel_type'] = relationship_type }, "descendant::subfield[@code='4']" => proc { |agent, node| agent['_relationship_uri'] = node.inner_text }, "descendant::subfield[@code='i']" => proc { |agent, node| agent['_description'] = node.inner_text }, 'self::datafield' => { :obj => :"name_#{type}", :rel => :names, :map => send("agent_#{type}_name_components_map"), :defaults => { :name_order => 'direct', :source => 'ingest' } } } } end |
#set_auth_id(node) ⇒ Object
Sometimes we need to create more than one subject from a MARC field with a subfield 0, but the subject creation will fail if you try to create subjects with duplicate authority ids. Only create an authority id for the first subject created, and leaves authority id blank
909 910 911 912 913 914 915 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 909 def set_auth_id(node) siblings = node.search("./preceding-sibling::*[not(@code='0' or @code='2')]") auth_id = node.parent.at_xpath("subfield[@code='0']").inner_text if siblings.empty? auth_id end |
#set_maintenance_status(pos_5) ⇒ Object
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 280 def set_maintenance_status(pos_5) case pos_5 when 'n' status = 'new' when 'a' status = 'upgraded' when 'c' status = 'revised_corrected' when 'd' status = 'deleted' when 'o' status = 'cancelled_obsolete' when 's' status = 'deleted_split' when 'x' status = 'deleted_replaced' end status end |
#set_primary_identifier(node) ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 462 def set_primary_identifier(node) # Kind of hacky, but we're not bringing in 001s in situations where the # 003=DLC and there is an 010 since these would presumably be near duplicates. # Therefore, we don't want to falsely set an unimported 001 as the primary id. node003 = node.at_xpath("ancestor::record/controlfield[@tag='003']")&.inner_text node010 = node.at_xpath("ancestor::record/datafield[@tag='010']")&.attr('tag') node001 = node.at_xpath("ancestor::record/controlfield[@tag='001']")&.attr('tag') unless node003 == 'DLC' && node010 this_node = node.attr('tag') || node.parent.attr('tag') ids = [] ids << node001 if node001 ids << node010 ids << node.at_xpath("ancestor::record/datafield[@tag='016']")&.attr('tag') ids << node.at_xpath("ancestor::record/datafield[@tag='024']")&.attr('tag') ids << node.at_xpath("ancestor::record/datafield[@tag='035']")&.attr('tag') first_node = ids.compact.first.to_s this_node == first_node end |
#set_record_language ⇒ Object
301 302 303 304 305 306 307 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 301 def set_record_language() -> obj, node { obj['language'] = nil lang_040 = node.at_xpath("subfield[@code='b']")&.inner_text obj['language'] = lang_040 if lang_040 } end |
#shared_subrecord_map(import_events, import_subjects) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 73 def shared_subrecord_map(import_events, import_subjects) h = { 'parent::record/leader' => agent_record_control_map, "parent::record/controlfield[@tag='001'][not(following-sibling::controlfield[@tag='003']/text()='DLC' and following-sibling::datafield[@tag='010'])]" => agent_record_identifiers_base_map("//record/controlfield[@tag='001']"), "parent::record/datafield[@tag='010']" => agent_record_identifiers_base_map("parent::record/datafield[@tag='010']/subfield[@code='a']"), "parent::record/datafield[@tag='016']" => agent_record_identifiers_base_map("parent::record/datafield[@tag='016']/subfield[@code='a']"), "parent::record/datafield[@tag='024']" => agent_record_identifiers_base_map("parent::record/datafield[@tag='024']/subfield[@code='a' or @code='0' or @code='1'][1]"), "parent::record/datafield[@tag='035']" => agent_record_identifiers_base_map("parent::record/datafield[@tag='035']/subfield[@code='a']"), "parent::record/datafield[@tag='040']/subfield[@code='e']" => convention_declaration_map, "parent::record/datafield[@tag='046']" => dates_map, "parent::record/datafield[@tag='377']" => used_language_map, "parent::record/datafield[@tag='500'][not(@ind1='3')]" => ('person'), "parent::record/datafield[@tag='500'][@ind1='3']" => ('family'), "parent::record/datafield[@tag='510']" => ('corporate_entity'), "parent::record/datafield[@tag='511']" => ('corporate_entity'), "parent::record/datafield[@tag='670']" => agent_sources_map, "parent::record/datafield[@tag='678']" => bioghist_note_map, "parent::record/datafield[@tag='040']/subfield[@code='d']" => { :obj => :agent_other_agency_codes, :rel => :agent_other_agency_codes, :map => { "self::subfield" => proc { |aoac, node| aoac['maintenance_agency'] = node.inner_text } } }, "parent::record" => proc { |record, node| # apply the more complicated inter-leaf logic record['agent_other_agency_codes'].reject! { |subrecord| subrecord['maintenance_agency'] == record['agent_record_controls'][0]['maintenance_agency'] } } } if import_events h.merge!({ "parent::record/controlfield[@tag='005']" => maintenance_history_map }) end if import_subjects h.merge!({ "parent::record/datafield[@tag='374']/subfield[@code='a']" => agent_occupation_map, "parent::record/datafield[@tag='370']/subfield[@code='a']" => place_of_birth_map, "parent::record/datafield[@tag='370']/subfield[@code='b']" => place_of_death_map, "parent::record/datafield[@tag='370']/subfield[@code='c']" => associated_country_map, "parent::record/datafield[@tag='370']/subfield[@code='e']" => place_of_residence_map, "parent::record/datafield[@tag='370']/subfield[@code='f']" => other_associated_place_map }) end h end |
#structured_date_for(node, subfields) ⇒ Object
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 562 def structured_date_for(node, subfields) date = nil subfields.each do |sc| date_node = node.at_xpath("subfield[@code='#{sc}']") next if date_node.nil? begin date = DateTime.parse(date_node) date = date.strftime('%F') # Invalid date will just get an expression rescue StandardError date = nil end end date end |
#subject_map(terms, rel = :subjects) ⇒ Object
usually, rel will be :subjects, but in some cases it will be :places
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 918 def subject_map(terms, rel = :subjects) { :obj => :subject, :rel => rel, :map => { 'self::subfield' => proc { |subject, node| subject.publish = true subject.terms = terms.call(node) subject.source = node.parent.at_xpath("subfield[@code='2']").inner_text unless node.parent.at_xpath("subfield[@code='2']").nil? subject.vocabulary = '/vocabularies/1' subject. = set_auth_id(node) unless node.parent.at_xpath("subfield[@code='0']").nil? } }, :defaults => { :source => 'Source not specified' } } end |
#subject_terms_map(term_type, _subfield) ⇒ Object
897 898 899 900 901 902 903 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 897 def subject_terms_map(term_type, _subfield) proc { |node| [{ :term_type => term_type, :term => node.inner_text, :vocabulary => '/vocabularies/1' }] } end |
#trim(property, trailing_char = ',', remove_chars = []) ⇒ Object
937 938 939 940 941 942 943 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 937 def trim(property, trailing_char = ',', remove_chars = []) -> name, node { val = node.inner_text remove_chars.each { |char| val = val.gsub(/#{Regexp.escape(char)}/, '') } name[property] = val.chomp(trailing_char) } end |
#used_language_map ⇒ Object
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'backend/app/converters/lib/marcxml_auth_agent_base_map.rb', line 749 def used_language_map { :obj => :used_language, :rel => :used_languages, :map => { "descendant::subfield[@code='l']" => proc { |lang, node| val = node.inner_text lang['language'] = val }, "descendant::subfield[@code='a']" => proc { |lang, node| val = node.inner_text lang['language'] = val if val } } } end |