Changeset 36910
- Timestamp:
- 2022-11-22T11:23:20+13:00 (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/BaseImporter.pm
r34999 r36910 126 126 'list' => $file_rename_method_list, 127 127 'reqd' => "no" 128 } 129 128 } 129 130 # These options take a metadata field, and store its values as individual 131 #fields with true value. 132 #eg wmtb.TKLabel=tk.Clan,tk.Attribution =>tk.Clan=true, tk.Attribution=true. 133 #Implemented for tk lables, but then not needed as this is handled by 134 # xslt instead. Leaving this here in case useful in the future 135 # { 'name' => "store_metadata_values_as_fields_for", 136 # 'desc' => "For these (comma-separated list of) fields, take all values and store them as metadata fields in their own write, value=true ", 137 # 'type' => "metadata", 138 # 'reqd' => "no" }, 139 # { 'name' => "namespace_for_new_fields", 140 # 'desc' => "add the specified namespace to the new fields (comma separated list, corresponding to the fields above", 141 # 'type'=> "string", 142 # 'reqd' => "no", 143 # 'deft' => ""}, 144 # { 'name' => "include_section_level", 145 # 'desc' => "do we look for this metadata at subsection level too?", 146 # 'type' => "string", 147 # 'deft' => "false"} 130 148 ]; 131 149 … … 575 593 # } 576 594 } 595 577 596 578 597 # this should be called by all plugins to set the oid of the doc obj, rather … … 654 673 $self->auto_extract_metadata($doc_obj); 655 674 675 # to use tk label options commented out at top 676 #$self->convert_special_metadata($doc_obj); 677 656 678 # if we haven't found any Title so far, assign one 657 679 # this was shifted to here from inside read() … … 689 711 my $self = shift(@_); 690 712 my ($doc_obj) = @_; 713 } 714 715 # used with the tk label options commented out at the start 716 sub convert_special_metadata { 717 my $self = shift(@_); 718 my ($doc_obj) = @_; 719 print STDERR "in convert special meta\n"; 720 return unless defined $self->{'store_metadata_values_as_fields_for'}; 721 print STDERR "we have fields to convert\n"; 722 723 my @existing_meta_fields = split(',', $self->{'store_metadata_values_as_fields_for'}); 724 my @new_ns = split(',', $self->{'namespace_for_new_fields'}); 725 my $include_section_level = $self->{'include_section_level'}; 726 727 foreach my $old_meta (@existing_meta_fields) { 728 my $ns = shift(@new_ns); 729 my $ns_prefix = ""; 730 if (defined $ns && $ns =~/\S/) { 731 $ns_prefix = "$ns."; 732 } 733 734 735 my $section = $doc_obj->get_top_section(); 736 while (defined $section) { 737 my @section_meta = @{$doc_obj->get_metadata($section, $old_meta)}; 738 foreach my $meta (@section_meta) { 739 foreach my $submeta (split /,/, $meta) { 740 # add meta, ns+submeta, value = true 741 # remove whitepace 742 $submeta =~ s/\s+//g; 743 $doc_obj->add_utf8_metadata($section, "$ns_prefix$submeta", "true"); 744 } 745 } 746 747 last if (!$include_section_level); 748 $section = $doc_obj->get_next_section($section); 749 } 750 } 691 751 } 692 752
Note:
See TracChangeset
for help on using the changeset viewer.