Module: EACBaseMap
- Defined in:
- backend/app/converters/lib/eac_base_map.rb
Instance Method Summary collapse
-
#agent_bioghist_note_map ⇒ Object
-
#agent_citation_note_map(xpath, rel = :notes) ⇒ Object
-
#agent_conventions_declaration_map ⇒ Object
-
#agent_corporate_entity_base(import_events) ⇒ Object
agent corporate name attrs, followed by agent subrecs common to all types.
-
#agent_corporate_entity_name_components_map ⇒ Object
-
#agent_corporate_entity_name_map(obj, rel) ⇒ Object
-
#agent_corporate_entity_name_with_parallel_map(obj, rel) ⇒ Object
-
#agent_date_range_map(label = nil, rel = :dates) ⇒ Object
-
#agent_date_single_map(label = nil, rel = :dates) ⇒ Object
-
#agent_family_base(import_events) ⇒ Object
agent family name attrs, followed by agent subrecs common to all types.
-
#agent_family_name_components_map ⇒ Object
-
#agent_family_name_map(obj, rel) ⇒ Object
-
#agent_family_name_with_parallel_map(obj, rel) ⇒ Object
-
#agent_function_map ⇒ Object
-
#agent_general_context_note_map ⇒ Object
-
#agent_identifier_map ⇒ Object
-
#agent_languages_map ⇒ Object
-
#agent_legal_status_note_map ⇒ Object
-
#agent_maintenance_history_map ⇒ Object
-
#agent_mandate_note_map ⇒ Object
-
#agent_occupation_map ⇒ Object
-
#agent_other_record_identifiers_map ⇒ Object
-
#agent_person_base(import_events) ⇒ Object
agent person name attrs, followed by agent subrecs common to all types.
-
#agent_person_gender_map ⇒ Object
-
#agent_person_name_components_map ⇒ Object
-
#agent_person_name_map(obj, rel) ⇒ Object
-
#agent_person_name_with_parallel_map(obj, rel) ⇒ Object
-
#agent_place_map ⇒ Object
-
#agent_record_control_map ⇒ Object
-
#agent_record_identifiers_map ⇒ Object
-
#agent_set_component_map ⇒ Object
-
#agent_sources_map ⇒ Object
-
#agent_structure_note_map ⇒ Object
-
#agent_text_note_map(xpath, rel = :notes) ⇒ Object
-
#agent_topic_map ⇒ Object
-
#base_map_subfields(import_events) ⇒ Object
These fields are common to all agent types and imported the same way.
-
#citation_subnote_map(xpath, rel = :subnotes) ⇒ Object
-
#corp_match?(node, type) ⇒ Boolean
-
#create_chron_item(node) ⇒ Object
-
#cv_maint_status(node) ⇒ Object
-
#cv_pub_status(node) ⇒ Object
-
#EAC_BASE_MAP(opts = {:import_events => false}) ⇒ Object
-
#fam_match?(node, type) ⇒ Boolean
-
#find_description_note(node) ⇒ Object
-
#find_relationship(node, type) ⇒ Object
-
#format_content(content) ⇒ Object
A lot of nodes need tweaking to format the content.
-
#hierarchical_relationship(hierarchy, node, type) ⇒ Object
-
#name_map(type) ⇒ Object
-
#pers_match?(node, type) ⇒ Boolean
-
#related_agent_map(type) ⇒ Object
-
#related_resource_map ⇒ Object
“creatorOf” or “subjectOf” or “other”.
-
#specific_relationship(node) ⇒ Object
-
#subject_map(xpath, terms, rel = :subjects) ⇒ Object
usually, rel will be :subjects, but in some cases it will be :places.
-
#subject_terms_map(term_type) ⇒ Object
Instance Method Details
#agent_bioghist_note_map ⇒ Object
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 882 def agent_bioghist_note_map { :obj => :note_bioghist, :rel => :notes, :map => { 'descendant::abstract' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_abstract', 'content' => [format_content(node.inner_text)] } }, 'descendant::chronList' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_chronology', 'items' => create_chron_item(node) } }, 'descendant::citation' => citation_subnote_map('self::citation'), # This will handle p's, outlines, and lists. 'self::biogHist' => proc { |note, node| %w[abstract chronList citation].each do |n| node.search(".//#{n}").remove end content = format_content(node.element_children.to_xml) note['subnotes'] << { 'jsonmodel_type' => 'note_text', 'content' => content } } }, :defaults => { } } end |
#agent_citation_note_map(xpath, rel = :notes) ⇒ Object
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1011 def agent_citation_note_map(xpath, rel = :notes) { :obj => :note_citation, :rel => rel, :map => { xpath => proc { |note, node| note.content << format_content(node.inner_html) } }, :defaults => { } } end |
#agent_conventions_declaration_map ⇒ Object
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 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 471 def agent_conventions_declaration_map { :obj => :agent_conventions_declaration, :rel => :agent_conventions_declarations, :map => { 'descendant::abbreviation' => proc { |dec, node| val = node.inner_text.downcase dec[:name_rule] = val }, 'descendant::citation' => proc { |dec, node| dec[:citation] = format_content(node.inner_html) dec[:file_uri] = node.attr('href') dec[:file_version_xlink_actuate_attribute] = node.attr('actuate') dec[:file_version_xlink_show_attribute] = node.attr('show') dec[:xlink_title_attribute] = node.attr('title') dec[:xlink_role_attribute] = node.attr('role') dec[:xlink_arcrole_attribute] = node.attr('arcrole') dec[:last_verified_date] = node.attr('lastDateTimeVerified') }, 'descendant::descriptiveNote' => proc { |dec, node| dec[:descriptive_note] = format_content(node.inner_html) } }, :defaults => { } } end |
#agent_corporate_entity_base(import_events) ⇒ Object
agent corporate name attrs, followed by agent subrecs common to all types
34 35 36 37 38 39 40 41 42 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 34 def agent_corporate_entity_base(import_events) { '//identity/nameEntry' => agent_corporate_entity_name_map(:name_corporate_entity, :names), '//identity/nameEntryParallel/nameEntry[1]' => agent_corporate_entity_name_with_parallel_map(:name_corporate_entity, :names), '//eac-cpf//mandates/mandate' => agent_mandate_note_map, '//eac-cpf//legalStatuses/legalStatus' => agent_legal_status_note_map, '//eac-cpf//structureOrGenealogy' => agent_structure_note_map }.merge(base_map_subfields(import_events)) end |
#agent_corporate_entity_name_components_map ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 240 def agent_corporate_entity_name_components_map { 'self::nameEntry[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'descendant::part[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'self::nameEntry[@scriptCode]' => proc { |name, node| name[:script] = node.attr('scriptCode') }, 'self::nameEntry[@transliteration]' => proc { |name, node| name[:transliteration] = node.attr('transliteration') }, "descendant::part[@localType='primary_name']" => proc { |name, node| val = node.inner_text name[:primary_name] = val }, "descendant::part[@localType='subordinate_name_1']" => proc { |name, node| val = node.inner_text name[:subordinate_name_1] = val }, "descendant::part[@localType='subordinate_name_2']" => proc { |name, node| val = node.inner_text name[:subordinate_name_2] = val }, "descendant::part[@localType='numeration']" => proc { |name, node| val = node.inner_text name[:number] = val }, "descendant::part[@localType='location']" => proc { |name, node| val = node.inner_text name[:location] = val }, "descendant::part[@localType='dates']" => proc { |name, node| val = node.inner_text name[:dates] = val }, "descendant::part[@localType='qualifier']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, 'descendant::authorizedForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = true }, 'descendant::alternativeForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = false }, 'descendant::part[not(@localType)]' => proc { |name, node| val = node.inner_text name[:primary_name] = val }, # if localType attr is not defined, assume primary_name "descendant::part[not(@localType='primary_name') and not(@localType='subordinate_name_1') and not(@localType='subordinate_name_2') and not(@localType='numeration') and not(@localType='location') and not(@localType='dates') and not(@localType='qualifier')]" => proc { |name, node| val = node.inner_text name[:primary_name] = val }, # if localType attr is something else 'descendant::useDates//date' => agent_date_single_map('usage', :use_dates), 'descendant::useDates//dateRange' => agent_date_range_map('usage', :use_dates) } end |
#agent_corporate_entity_name_map(obj, rel) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 115 def agent_corporate_entity_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_corporate_entity_name_components_map, :defaults => { :source => 'local', :rules => 'local' } } end |
#agent_corporate_entity_name_with_parallel_map(obj, rel) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 127 def agent_corporate_entity_name_with_parallel_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_corporate_entity_name_components_map.merge({ 'following-sibling::nameEntry' => agent_corporate_entity_name_map(:parallel_name_corporate_entity, :parallel_names) }), :defaults => { :source => 'local', :rules => 'local' } } end |
#agent_date_range_map(label = nil, rel = :dates) ⇒ Object
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 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 645 def agent_date_range_map(label = nil, rel = :dates) { :obj => :structured_date_label, :rel => rel, :map => { 'self::dateRange' => proc { |date, node| label = node.attr('localType') if label.nil? label = 'other' if label.nil? type = 'range' begin_node = node.search('./fromDate') end_node = node.search('./toDate') begin_exp = begin_node.inner_text end_exp = end_node.inner_text begin_std = begin_node.attr('standardDate') ? begin_node.attr('standardDate').value : nil end_std = end_node.attr('standardDate') ? end_node.attr('standardDate').value : nil begin_std_type = if begin_std if begin_node.attr('notBefore') begin_node.attr('notBefore').value elsif begin_node.attr('notAfter') begin_node.attr('notAfter').value end end end_std_type = if end_std if end_node.attr('notBefore') end_node.attr('notBefore').value elsif end_node.attr('notAfter') end_node.attr('notAfter').value end end sdr = ASpaceImport::JSONModel(:structured_date_range).new({ :begin_date_expression => begin_exp, :begin_date_standardized => begin_std, :begin_date_standardized_type => begin_std_type, :end_date_expression => end_exp, :end_date_standardized => end_std, :end_date_standardized_type => end_std_type }) date[:date_label] = label date[:date_type_structured] = type date[:structured_date_range] = sdr } }, :defaults => { } } end |
#agent_date_single_map(label = nil, rel = :dates) ⇒ Object
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 631 632 633 634 635 636 637 638 639 640 641 642 643 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 602 def agent_date_single_map(label = nil, rel = :dates) { :obj => :structured_date_label, :rel => rel, :map => { 'self::date' => proc { |date, node| exp = node.inner_text role = 'begin' type = 'single' label = node.attr('localType') if label.nil? label = 'other' if label.nil? if node.attr('standardDate') std = node.attr('standardDate') std_type = if node.attr('notBefore') node.attr('notBefore') elsif node.attr('notAfter') node.attr('notAfter') end else std = nil std_type = nil end sds = ASpaceImport::JSONModel(:structured_date_single).new({ :date_role => role, :date_expression => exp, :date_standardized => std, :date_standardized_type => std_type }) date[:date_label] = label date[:date_type_structured] = type date[:structured_date_single] = sds } }, :defaults => { } } end |
#agent_family_base(import_events) ⇒ Object
agent family name attrs, followed by agent subrecs common to all types
45 46 47 48 49 50 51 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 45 def agent_family_base(import_events) { '//identity/nameEntry' => agent_family_name_map(:name_family, :names), '//identity/nameEntryParallel/nameEntry[1]' => agent_family_name_with_parallel_map(:name_family, :names), '//eac-cpf//structureOrGenealogy' => agent_structure_note_map }.merge(base_map_subfields(import_events)) end |
#agent_family_name_components_map ⇒ Object
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 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 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 305 def agent_family_name_components_map { 'self::nameEntry[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'descendant::part[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'self::nameEntry[@scriptCode]' => proc { |name, node| name[:script] = node.attr('scriptCode') }, 'self::nameEntry[@transliteration]' => proc { |name, node| name[:transliteration] = node.attr('transliteration') }, "descendant::part[@localType='prefix']" => proc { |name, node| val = node.inner_text name[:prefix] = val }, "descendant::part[@localType='surname']" => proc { |name, node| val = node.inner_text name[:family_name] = val }, "descendant::part[@localType='family_type']" => proc { |name, node| val = node.inner_text name[:family_type] = val }, "descendant::part[@localType='location']" => proc { |name, node| val = node.inner_text name[:location] = val }, "descendant::part[@localType='dates']" => proc { |name, node| val = node.inner_text name[:dates] = val }, "descendant::part[@localType='qualifier']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, 'descendant::authorizedForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = true }, 'descendant::alternativeForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = false }, 'descendant::part[not(@localType)]' => proc { |name, node| val = node.inner_text name[:family_name] = val }, # if localType attr is not defined, assume primary_name "descendant::part[not(@localType='prefix') and not(@localType='surname') and not(@localType='family_type') and not(@localType='location') and not(@localType='dates') and not(@localType='qualifier')]" => proc { |name, node| val = node.inner_text name[:family_name] = val }, # if localType attr is something else, assume primary_name 'descendant::useDates//date' => agent_date_single_map('usage', :use_dates), 'descendant::useDates//dateRange' => agent_date_range_map('usage', :use_dates) } end |
#agent_family_name_map(obj, rel) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 141 def agent_family_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_family_name_components_map, :defaults => { :source => 'local', :rules => 'local' } } end |
#agent_family_name_with_parallel_map(obj, rel) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 153 def agent_family_name_with_parallel_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_family_name_components_map.merge({ 'following-sibling::nameEntry' => agent_family_name_map(:parallel_name_family, :parallel_names) }), :defaults => { :source => 'local', :rules => 'local' } } end |
#agent_function_map ⇒ Object
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 762 def agent_function_map { :obj => :agent_function, :rel => :agent_functions, :map => { 'descendant::term' => subject_map('self::term', subject_terms_map('function')), 'descendant::date' => agent_date_single_map, 'descendant::dateRange' => agent_date_range_map, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote'), 'descendant::citation' => agent_citation_note_map('self::citation') } } end |
#agent_general_context_note_map ⇒ Object
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 917 def agent_general_context_note_map { :obj => :note_general_context, :rel => :notes, :map => { 'self::generalContext' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_text', 'content' => format_content(node.inner_html) } } }, :defaults => { } } end |
#agent_identifier_map ⇒ Object
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 586 def agent_identifier_map { :obj => :agent_identifier, :rel => :agent_identifiers, :map => { 'self::entityId' => proc { |id, node| val = node.inner_text id[:entity_identifier] = val id[:identifier_type] = node.attr('localType') } }, :defaults => { } } end |
#agent_languages_map ⇒ Object
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 802 def agent_languages_map { :obj => :used_language, :rel => :used_languages, :map => { 'descendant::language' => proc { |lang, node| lang[:language] = node.attr('languageCode') }, 'descendant::script' => proc { |lang, node| lang[:script] = node.attr('scriptCode') }, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote') } } end |
#agent_legal_status_note_map ⇒ Object
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 951 def agent_legal_status_note_map { :obj => :note_legal_status, :rel => :notes, :map => { 'descendant::citation' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_citation', 'content' => [format_content(node.inner_html)] } }, 'descendant::descriptiveNote' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_text', 'content' => format_content(node.inner_html) } } }, :defaults => { } } end |
#agent_maintenance_history_map ⇒ Object
526 527 528 529 530 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 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 526 def agent_maintenance_history_map { :obj => :agent_maintenance_history, :rel => :agent_maintenance_histories, :map => { 'descendant::eventType' => proc { |me, node| val = node.inner_text.downcase me[:maintenance_event_type] = val }, 'descendant::agentType' => proc { |me, node| val = node.inner_text me[:maintenance_agent_type] = val }, 'descendant::agent' => proc { |me, node| val = node.inner_text me[:agent] = val }, 'descendant::eventDateTime' => proc { |me, node| val = node.attr('standardDateTime') val2 = node.inner_text me[:event_date] = val me[:event_date] = val2 if val.nil? }, 'descendant::eventDescription' => proc { |me, node| me[:descriptive_note] = format_content(node.inner_html) } }, :defaults => { } } end |
#agent_mandate_note_map ⇒ Object
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 974 def agent_mandate_note_map { :obj => :note_mandate, :rel => :notes, :map => { 'descendant::citation' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_citation', 'content' => [format_content(node.inner_html)] } }, 'descendant::descriptiveNote' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_text', 'content' => format_content(node.inner_html) } } }, :defaults => { } } end |
#agent_occupation_map ⇒ Object
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 742 def agent_occupation_map { :obj => :agent_occupation, :rel => :agent_occupations, :map => { 'descendant::term' => subject_map('self::term', subject_terms_map('occupation')), 'descendant::date' => agent_date_single_map, 'descendant::dateRange' => agent_date_range_map, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote'), 'descendant::citation' => agent_citation_note_map('self::citation') } } end |
#agent_other_record_identifiers_map ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 384 def agent_other_record_identifiers_map { :obj => :agent_record_identifier, :rel => :agent_record_identifiers, :map => { 'self::otherRecordId' => proc { |id, node| val = node.inner_text id[:record_identifier] = val id[:primary_identifier] = false id[:identifier_type] = node.attr('localType') } }, :defaults => { :primary_identifier => false, :source => 'local' } } end |
#agent_person_base(import_events) ⇒ Object
agent person name attrs, followed by agent subrecs common to all types
25 26 27 28 29 30 31 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 25 def agent_person_base(import_events) { '//identity/nameEntry' => agent_person_name_map(:name_person, :names), '//identity/nameEntryParallel/nameEntry[1]' => agent_person_name_with_parallel_map(:name_person, :names), "//localDescription[@localType='gender']" => agent_person_gender_map }.merge(base_map_subfields(import_events)) end |
#agent_person_gender_map ⇒ Object
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 700 def agent_person_gender_map { :obj => :agent_gender, :rel => :agent_genders, :map => { 'descendant::term' => proc { |gender, node| val = node.inner_text gender[:gender] = val }, 'descendant::date' => agent_date_single_map, 'descendant::dateRange' => agent_date_range_map, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote') }, :defaults => { } } end |
#agent_person_name_components_map ⇒ Object
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 198 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 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 167 def agent_person_name_components_map { 'self::nameEntry[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'descendant::part[@lang]' => proc { |name, node| name[:language] = node.attr('lang') }, 'self::nameEntry[@scriptCode]' => proc { |name, node| name[:script] = node.attr('scriptCode') }, 'self::nameEntry[@transliteration]' => proc { |name, node| name[:transliteration] = node.attr('transliteration') }, "descendant::part[@localType='prefix']" => proc { |name, node| val = node.inner_text name[:prefix] = val }, "descendant::part[@localType='suffix']" => proc { |name, node| val = node.inner_text name[:suffix] = val }, "descendant::part[@localType='title']" => proc { |name, node| val = node.inner_text name[:title] = val }, "descendant::part[@localType='surname']" => proc { |name, node| val = node.inner_text name[:primary_name] = val }, "descendant::part[@localType='forename']" => proc { |name, node| val = node.inner_text name[:rest_of_name] = val }, "descendant::part[@localType='numeration']" => proc { |name, node| val = node.inner_text name[:number] = val }, "descendant::part[@localType='fuller_form']" => proc { |name, node| val = node.inner_text name[:fuller_form] = val }, "descendant::part[@localType='dates']" => proc { |name, node| val = node.inner_text name[:dates] = val }, "descendant::part[@localType='qualifier']" => proc { |name, node| val = node.inner_text name[:qualifier] = val }, 'descendant::authorizedForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = true }, 'descendant::alternativeForm' => proc { |name, node| val = node.inner_text name[:source] = val name[:authorized] = false }, 'descendant::part[not(@localType)]' => proc { |name, node| val = node.inner_text name[:primary_name] = val }, # if localType attr is not defined, assume primary_name "descendant::part[not(@localType='prefix') and not(@localType='prefix') and not(@localType='suffix') and not(@localType='title') and not(@localType='surname') and not(@localType='forename') and not(@localType='numeration') and not(@localType='fuller_form') and not(@localType='dates') and not(@localType='qualifier')]" => proc { |name, node| val = node.inner_text name[:primary_name] = val }, # if localType attr is something else 'descendant::useDates//date' => agent_date_single_map('usage', :use_dates), 'descendant::useDates//dateRange' => agent_date_range_map('usage', :use_dates) } end |
#agent_person_name_map(obj, rel) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 87 def agent_person_name_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_person_name_components_map, :defaults => { :source => 'local', :rules => 'local', :name_order => 'inverted' } } end |
#agent_person_name_with_parallel_map(obj, rel) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 100 def agent_person_name_with_parallel_map(obj, rel) { :obj => obj, :rel => rel, :map => agent_person_name_components_map.merge({ 'following-sibling::nameEntry' => agent_person_name_map(:parallel_name_person, :parallel_names) }), :defaults => { :source => 'local', :rules => 'local', :name_order => 'inverted' } } end |
#agent_place_map ⇒ Object
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 718 def agent_place_map { :obj => :agent_place, :rel => :agent_places, :map => { 'descendant::placeRole' => proc { |apl, node| val = node.inner_text apl[:place_role] = val }, 'descendant::placeEntry' => subject_map('self::placeEntry', subject_terms_map('geographic')), 'descendant::date' => agent_date_single_map, 'descendant::dateRange' => agent_date_range_map, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote'), 'descendant::citation' => agent_citation_note_map('self::citation') } } end |
#agent_record_control_map ⇒ Object
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 461 462 463 464 465 466 467 468 469 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 431 def agent_record_control_map { :obj => :agent_record_control, :rel => :agent_record_controls, :map => { 'descendant::maintenanceStatus' => proc { |arc, node| arc[:maintenance_status] = cv_maint_status(node) }, 'descendant::maintenanceAgency/agencyCode' => proc { |arc, node| val = node.inner_text arc[:maintenance_agency] = val }, 'descendant::maintenanceAgency/agencyName' => proc { |arc, node| val = node.inner_text arc[:agency_name] = val }, 'descendant::maintenanceAgency/descriptiveNote' => proc { |arc, node| val = node.inner_text arc[:maintenance_agency_note] = val }, 'descendant::publicationStatus' => proc { |arc, node| arc[:publication_status] = cv_pub_status(node) }, 'descendant::languageDeclaration/language' => proc { |arc, node| arc[:language] = node.attr('languageCode') }, 'descendant::languageDeclaration/script' => proc { |arc, node| arc[:script] = node.attr('scriptCode') }, 'descendant::languageDeclaration/descriptiveNote' => proc { |arc, node| val = node.inner_text arc[:language_note] = val } }, :defaults => { :maintenance_status => 'new' } } end |
#agent_record_identifiers_map ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 366 def agent_record_identifiers_map { :obj => :agent_record_identifier, :rel => :agent_record_identifiers, :map => { 'self::recordId' => proc { |id, node| val = node.inner_text id[:record_identifier] = val id[:primary_identifier] = true } }, :defaults => { :primary_identifier => true, :source => 'local' } } end |
#agent_set_component_map ⇒ Object
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 499 def agent_set_component_map { :obj => :agent_alternate_set, :rel => :agent_alternate_sets, :map => { 'self::setComponent' => proc { |as, node| as[:file_uri] = node.attr('href') as[:file_version_xlink_actuate_attribute] = node.attr('actuate') as[:file_version_xlink_show_attribute] = node.attr('show') as[:xlink_title_attribute] = node.attr('title') as[:xlink_role_attribute] = node.attr('role') as[:xlink_arcrole_attribute] = node.attr('arcrole') as[:last_verified_date] = node.attr('lastDateTimeVerified') }, 'descendant::descriptiveNote' => proc { |as, node| as[:descriptive_note] = format_content(node.inner_html) }, 'descendant::componentEntry' => proc { |as, node| val = node.inner_text as[:set_component] = val } }, :defaults => { } } end |
#agent_sources_map ⇒ Object
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 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 559 def agent_sources_map { :obj => :agent_sources, :rel => :agent_sources, :map => { 'self::source' => proc { |s, node| s[:file_uri] = node.attr('href') s[:file_version_xlink_actuate_attribute] = node.attr('actuate') s[:file_version_xlink_show_attribute] = node.attr('show') s[:xlink_title_attribute] = node.attr('title') s[:xlink_role_attribute] = node.attr('role') s[:xlink_arcrole_attribute] = node.attr('arcrole') s[:last_verified_date] = node.attr('lastDateTimeVerified') }, 'descendant::sourceEntry' => proc { |s, node| val = node.inner_text s[:source_entry] = val }, 'descendant::descriptiveNote' => proc { |s, node| s[:descriptive_note] = format_content(node.inner_html) } }, :defaults => { } } end |
#agent_structure_note_map ⇒ Object
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 934 def agent_structure_note_map { :obj => :note_structure_or_genealogy, :rel => :notes, :map => { 'self::structureOrGenealogy' => proc { |note, node| note['subnotes'] << { 'jsonmodel_type' => 'note_text', 'content' => format_content(node.inner_html) } } }, :defaults => { } } end |
#agent_text_note_map(xpath, rel = :notes) ⇒ Object
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 997 def agent_text_note_map(xpath, rel = :notes) { :obj => :note_text, :rel => rel, :map => { xpath => proc { |note, node| note.content = format_content(node.inner_html) } }, :defaults => { } } end |
#agent_topic_map ⇒ Object
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 782 def agent_topic_map { :obj => :agent_topic, :rel => :agent_topics, :map => { 'descendant::term' => subject_map('self::term', subject_terms_map('topical')), 'descendant::date' => agent_date_single_map, 'descendant::dateRange' => agent_date_range_map, 'descendant::descriptiveNote' => agent_text_note_map('self::descriptiveNote'), 'descendant::citation' => agent_citation_note_map('self::citation') } } end |
#base_map_subfields(import_events) ⇒ Object
These fields are common to all agent types and imported the same way
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 54 def base_map_subfields(import_events) h = { '//eac-cpf//control/recordId' => agent_record_identifiers_map, '//eac-cpf//control/otherRecordId' => agent_other_record_identifiers_map, '//eac-cpf//control' => agent_record_control_map, '//eac-cpf/control/conventionDeclaration' => agent_conventions_declaration_map, '//eac-cpf/control/sources/source' => agent_sources_map, '//eac-cpf/cpfDescription/identity/entityId' => agent_identifier_map, '//eac-cpf/cpfDescription/description/existDates//date' => agent_date_single_map('existence', :dates_of_existence), '//eac-cpf/cpfDescription/description/existDates//dateRange' => agent_date_range_map('existence', :dates_of_existence), '//place' => agent_place_map, '//occupation' => agent_occupation_map, '//function' => agent_function_map, "//localDescription[contains(translate(@localType,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'subject')]" => agent_topic_map, '//eac-cpf//biogHist' => agent_bioghist_note_map, '//eac-cpf//generalContext' => agent_general_context_note_map, '//eac-cpf/cpfDescription/alternativeSet/setComponent' => agent_set_component_map, '//languageUsed' => agent_languages_map, "//relations/cpfRelation[contains(translate(@role,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'person')]/relationEntry[string-length(text()) > 0]" => ('person'), "//relations/cpfRelation[contains(translate(@role,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'corporatebody')]/relationEntry[string-length(text()) > 0]" => ('corporate_entity'), "//relations/cpfRelation[contains(translate(@role,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'family')]/relationEntry[string-length(text()) > 0]" => ('family'), '//relations/resourceRelation/relationEntry[string-length(text()) > 0]' => } if import_events h.merge!({ '//eac-cpf/control/maintenanceHistory/maintenanceEvent' => agent_maintenance_history_map }) end h end |
#citation_subnote_map(xpath, rel = :subnotes) ⇒ Object
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1025 def citation_subnote_map(xpath, rel = :subnotes) { :obj => :note_citation, :rel => rel, :map => { xpath => proc { |note, node| note.content << format_content(node.inner_html) note.xlink = { 'href' => node.attr('href'), 'actuate' => node.attr('xlink:actuate'), 'show' => node.attr('xlink:show'), 'title' => node.attr('xlink:title'), 'role' => node.attr('xlink:role'), 'arcrole' => node.attr('xlink:arcrole') } } }, :defaults => { } } end |
#corp_match?(node, type) ⇒ Boolean
1207 1208 1209 1210 1211 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1207 def corp_match?(node, type) parent = node.search("//eac-cpf//cpfDescription[child::identity/child::entityType='corporateBody']") type == 'corporate_entity' && !parent.empty? end |
#create_chron_item(node) ⇒ Object
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 859 def create_chron_item(node) items = [] node.search('./chronItem').each do |n| if (d = n.at_xpath('dateRange')) date = format_content(d.at_xpath('fromDate').inner_text) date += '-' date += format_content(d.at_xpath('toDate').inner_text) elsif n.at_xpath('date') date = format_content(n.at_xpath('date').inner_text) end event = n.at_xpath('event') place = n.at_xpath('placeEntry') items << { 'event_date' => date || nil, 'events' => [event ? format_content(event.inner_text) : nil], 'place' => place ? format_content(place.inner_text) : nil } end items end |
#cv_maint_status(node) ⇒ Object
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 403 def cv_maint_status(node) case node.inner_text when 'cancelled' 'cancelled_obsolete' when 'deleted', 'deletedMerged' 'deleted' when 'deletedReplaced' 'deleted_replaced' when 'deletedSplit' 'deleted_split' when 'derived' 'derived' when 'new' 'new' when 'revised' 'revised_corrected' end end |
#cv_pub_status(node) ⇒ Object
422 423 424 425 426 427 428 429 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 422 def cv_pub_status(node) case node.inner_text when 'inProcess' 'in_process' when 'approved', 'published' 'approved' end end |
#EAC_BASE_MAP(opts = {:import_events => false}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 2 def EAC_BASE_MAP(opts = {:import_events => false}) import_events = opts[:import_events] { # AGENT PERSON "//eac-cpf//cpfDescription[child::identity/child::entityType='person']" => { :obj => :agent_person, :map => agent_person_base(import_events) }, # AGENT CORPORATE ENTITY "//eac-cpf//cpfDescription[child::identity/child::entityType='corporateBody']" => { :obj => :agent_corporate_entity, :map => agent_corporate_entity_base(import_events) }, # AGENT FAMILY "//eac-cpf//cpfDescription[child::identity/child::entityType='family']" => { :obj => :agent_family, :map => agent_family_base(import_events) } } end |
#fam_match?(node, type) ⇒ Boolean
1201 1202 1203 1204 1205 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1201 def fam_match?(node, type) parent = node.search("//eac-cpf//cpfDescription[child::identity/child::entityType='family']") type == 'family' && !parent.empty? end |
#find_description_note(node) ⇒ Object
1227 1228 1229 1230 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1227 def find_description_note(node) note = node.search('./descriptiveNote') format_content(note.inner_html) if note end |
#find_relationship(node, type) ⇒ Object
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1134 def find_relationship(node, type) relationship = node.attr('cpfRelationType') case relationship when 'identity' relator = 'is_identified_with' relationship_type = 'agent_relationship_identity' when 'hierarchical' relator = 'is_hierarchical_with' relationship_type = 'agent_relationship_hierarchical' when 'hierarchical-parent' relator, relationship_type = hierarchical_relationship('parent', node, type) when 'hierarchical-child' relator, relationship_type = hierarchical_relationship('child', node, type) when 'temporal' relator = 'is_temporal_with' relationship_type = 'agent_relationship_temporal' when 'temporal-earlier' relator = 'is_earlier_form_of' relationship_type = 'agent_relationship_earlierlater' when 'temporal-later' relator = 'is_later_form_of' relationship_type = 'agent_relationship_earlierlater' when 'family' relator = 'is_related_with' relationship_type = 'agent_relationship_family' else relator = 'is_associative_with' relationship_type = 'agent_relationship_associative' end [relator, relationship_type] end |
#format_content(content) ⇒ Object
A lot of nodes need tweaking to format the content. Like, people love their p’s but they don’t actually want to ever see them.
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1234 def format_content(content) return content if content.nil? content.tr!("\n", ' ') # literal linebreaks are assumed to not be part of data content.gsub(%r{(</p>|<p(?:\s+[^>]*)?/>)\s*(<p(?: [^>/]*)?>)}, "\n\n") .gsub(%r{<p(?: [^>/]*)?>}, '') .gsub(%r{</p>|<p(?:\s+[^>]*)?/>}, "\n\n") .gsub('<lb/>', "\n\n") .gsub('<lb>', "\n\n") .gsub('</lb>', '') .strip .squeeze(' ') end |
#hierarchical_relationship(hierarchy, node, type) ⇒ Object
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1168 def hierarchical_relationship(hierarchy, node, type) if pers_match?(node, type) || fam_match?(node, type) case hierarchy when 'parent' relator = 'is_parent_of' relationship_type = 'agent_relationship_parentchild' when 'child' relator = 'is_child_of' relationship_type = 'agent_relationship_parentchild' end elsif corp_match?(node, type) case hierarchy when 'parent' relator = 'is_superior_of' relationship_type = 'agent_relationship_subordinatesuperior' when 'child' relator = 'is_subordinate_to' relationship_type = 'agent_relationship_subordinatesuperior' end else relator = 'is_associative_with' relationship_type = 'agent_relationship_associative' end [relator, relationship_type] end |
#name_map(type) ⇒ Object
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1111 def name_map(type) { 'self::relationEntry' => proc { |name, node| val = node.inner_text case type when 'person' nom_parts = val.split(/,\s*/, 2) name['primary_name'] = nom_parts[0] name['rest_of_name'] = nom_parts[1] when 'family' name['family_name'] = val else name['primary_name'] = val end name['name_order'] = 'inverted' if name['rest_of_name'] name['authorized'] = true name['is_display_name'] = true } } end |
#pers_match?(node, type) ⇒ Boolean
1195 1196 1197 1198 1199 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1195 def pers_match?(node, type) parent = node.search("//eac-cpf//cpfDescription[child::identity/child::entityType='person']") type == 'person' && !parent.empty? end |
#related_agent_map(type) ⇒ Object
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1074 def (type) { :obj => :"agent_#{type}", :rel => proc { |agent, rel_agent| agent[:related_agents] << { :relator => rel_agent['_relator'], :jsonmodel_type => rel_agent['_jsonmodel_type'], :specific_relator => rel_agent['_specific_relator'], :relationship_uri => rel_agent['_relationship_uri'], :description => rel_agent['_description'], :ref => rel_agent.uri } }, :map => { 'parent::cpfRelation' => proc { |agent, node| relator, relationship_type = find_relationship(node, type) specific_relator, relationship_uri = specific_relationship(node) agent['_relator'] = relator agent['_jsonmodel_type'] = relationship_type agent['_specific_relator'] = specific_relator agent['_relationship_uri'] = relationship_uri agent['_relator'] = relator agent['_description'] = find_description_note(node) }, 'self::relationEntry' => { :obj => :"name_#{type}", :rel => :names, :map => name_map(type), :defaults => { :name_order => 'direct', :source => 'ingest' } } } } end |
#related_resource_map ⇒ Object
“creatorOf” or “subjectOf” or “other”
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 857 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 819 def { :obj => :agent_resource, :rel => :agent_resources, :map => { 'parent::resourceRelation' => proc { |rr, node| rr[:file_uri] = node.attr('href') rr[:file_version_xlink_actuate_attribute] = node.attr('actuate') rr[:file_version_xlink_show_attribute] = node.attr('show') rr[:xlink_title_attribute] = node.attr('title') rr[:xlink_role_attribute] = node.attr('role') rr[:xlink_arcrole_attribute] = node.attr('arcrole') rr[:last_verified_date] = node.attr('lastDateTimeVerified') rr[:linked_agent_role] = case node.attr('resourceRelationType') when 'creatorOf' 'creator' when 'subjectOf' 'subject' else 'source' end }, 'self::relationEntry' => proc { |rr, node| rr[:linked_resource] = node.inner_text }, 'parent::resourceRelation/descriptiveNote' => proc { |rr, node| rr[:linked_resource_description] = format_content(node.inner_html) }, 'parent::resourceRelation/placeEntry' => subject_map('self::placeEntry', subject_terms_map('geographic'), :places), 'parent::resourceRelation/descendant::date' => agent_date_single_map, 'parent::resourceRelation/descendant::dateRange' => agent_date_range_map }, :defaults => { } } end |
#specific_relationship(node) ⇒ Object
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1213 def specific_relationship(node) specific_relationship = node.attr('arcrole') uri = URI.parse(specific_relationship) if uri.scheme relationship_uri = specific_relationship specific_relator = uri.fragment else relationship_uri = nil specific_relator = specific_relationship end [specific_relator, relationship_uri] end |
#subject_map(xpath, terms, rel = :subjects) ⇒ Object
usually, rel will be :subjects, but in some cases it will be :places
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1056 def subject_map(xpath, terms, rel = :subjects) { :obj => :subject, :rel => rel, :map => { xpath => proc { |subject, node| subject.publish = true subject.source = node.attr('vocabularySource') subject.terms = terms.call(node) subject.vocabulary = '/vocabularies/1' } }, :defaults => { :source => 'Source not specified' } } end |
#subject_terms_map(term_type) ⇒ Object
1047 1048 1049 1050 1051 1052 1053 |
# File 'backend/app/converters/lib/eac_base_map.rb', line 1047 def subject_terms_map(term_type) proc { |node| [{ :term_type => term_type, :term => node.inner_text, :vocabulary => '/vocabularies/1' }] } end |