- Timestamp:
- 2017-11-23T13:50:51+13:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cgiactions/modmetadataaction.pm
r32077 r32079 205 205 sub set_index_metadata_entry 206 206 { 207 print STDERR "1\n";208 207 my $self = shift @_; 209 208 my ($collect_dir,$collect,$infodbtype,$docid,$metaname,$metapos,$metavalue,$metamode,$prevmetavalue) = @_; … … 216 215 my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory); 217 216 218 print STDERR "2\n";219 217 # print STDERR "**** infodb file path = $infodb_file_path\n"; 220 218 # print STDERR "***** infodb type = $infodbtype\n"; … … 225 223 # Set the metadata value 226 224 if (defined $metapos) { 227 print STDERR "3\n";228 225 # if metamode=accumulate AND metapos, warn user and then use metapos 229 226 if (defined $metamode && $metamode eq "accumulate") { … … 234 231 } 235 232 elsif (defined $prevmetavalue) { 236 print STDERR "4\n"; 237 my $array = $doc_rec->{$metaname}; 233 my $array = $doc_rec->{$metaname}; 238 234 my $length = @$array; 239 235 240 236 my $found = 0; 241 237 for (my $i = 0; $i < $length; $i++){ 242 238 if(defined $doc_rec->{$metaname}->[$i] && $doc_rec->{$metaname}->[$i] eq $prevmetavalue){ … … 252 248 } 253 249 elsif (defined $metamode && $metamode eq "override") { 254 print STDERR "5\n";255 250 $doc_rec->{$metaname} = [ $metavalue ]; 256 251 } 257 252 else { # default for index was to override, but because accumulate is less destructive, 258 253 # and because accumulate is the default for archives and import, that's the new default for index too 259 print STDERR "6\n";260 254 if(defined $doc_rec->{$metaname}) { 261 255 push(@{$doc_rec->{$metaname}}, $metavalue); # accumulate the value for that metaname … … 264 258 } 265 259 } 266 print STDERR "6\n";267 260 268 261 my $status = &dbutil::set_infodb_entry($infodbtype, $infodb_file_path,$docid,$doc_rec); … … 861 854 862 855 if ($parser->{'parameters'}->{'poscount'} == $parser->{'parameters'}->{'metapos'}) { 863 print STDERR "#### got pos match!!\n";856 ###print STDERR "#### got pos match!!\n"; 864 857 # Get the value and override the current value 865 858 my $metavalue = $parser->{'parameters'}->{'metavalue'}; … … 872 865 elsif (defined $parser->{'parameters'}->{'prevmetavalue'}) { # if no pos defined but prevmeta defined, then wait for prevmeta match 873 866 if ($parser->{'parameters'}->{'prevmetavalue'} eq $attrHash->{'_content'}) { 874 print STDERR "### prev meta value matches\n";867 ###print STDERR "### prev meta value matches\n"; 875 868 my $metavalue = $parser->{'parameters'}->{'metavalue'}; 876 869 $attrHash->{'_content'} = $metavalue; … … 879 872 } 880 873 } 881 elsif ($parser->{'parameters'}->{'poscount'} == 0) { # explicit catch all - ignored!!!! 882 # If no pos or prevmeta defined, then metavalue set for metaname becomes the ONLY instance of that metaname!!! 883 print STDERR "#### got pos match!!\n"; 884 # Get the value and override the current value 885 my $metavalue = $parser->{'parameters'}->{'metavalue'}; 886 $attrHash->{'_content'} = $metavalue; 887 888 # Don't want it to wipe out any other pieces of metadata 889 $parser->{'parameters'}->{'metamode'} = "done"; 890 891 892 } 893 894 895 874 # Note that before commit rev 32076, if neither metapos nor prevmeta defined, then code tried to set pos 0 for that metaname to the new value 875 # However that is not how the code works now (and couldn't get it to work that way yet after rev 32076). 876 # What it does now, and what Dr Bainbridge approved of is that: 877 # If no pos or prevmeta defined, then on override, the metavalue set for the specificed metaname becomes the ONLY instance of that metaname 878 # So any earlier instances of that metaname is removed and replaced by the single new instance. 896 879 } 897 880 } … … 913 896 my $opt_doc_secnum = $parser->{'parameters'}->{'secnum'}; 914 897 915 #print STDERR "@@@ $tagname Processing a closing </Archive> tag [$curr_secnum|$opt_doc_secnum]\n";898 # print STDERR "@@@ $tagname Processing a closing </Archive> tag [$curr_secnum|$opt_doc_secnum]\n"; 916 899 917 900 if ($metamode ne "done" && $curr_secnum ne $opt_doc_secnum) { 918 print STDERR "@@@ $tagname Finished processing FINAL Section.\n";901 #print STDERR "@@@ $tagname Finished processing FINAL Section.\n"; 919 902 920 903 my $metaname = $parser->{'parameters'}->{'metaname'}; … … 941 924 942 925 ###!!! print STDERR "**** Processing a closing </Description> tag \n"; 943 #print STDERR "@@@ $tagname Processing a closing </Description> tag [$curr_secnum|$opt_doc_secnum]\n";926 # print STDERR "@@@ $tagname Processing a closing </Description> tag [$curr_secnum|$opt_doc_secnum]\n"; 944 927 945 928 # Accumulate the metadata … … 963 946 if ($curr_secnum eq $opt_doc_secnum 964 947 && ($metamode eq "accumulate" || $metamode eq "override")) { 948 # note, metamode would have been set to done if a metadata operation had already succeeded. 949 # If we get here, we still have the metadata to append. 965 950 if ($metamode eq "override") { 966 951 print "Got to end of <Description> block. No metadata value to override. Switching 'metamode' to accumulate\n"; … … 982 967 my $append_metadata = [ "Metadata" => $metadata_attr ]; 983 968 my $description_content = $attrHash->{'_content'}; 984 985 969 print "Appending metadata to doc.xml\n"; 986 970 … … 1000 984 ## print STDERR "**** NOT ACCUMULATE?!? \n"; 1001 985 } 1002 1003 986 # RAW is [$tagname => $attrHash] not $tagname => $attrHash!! 1004 987 return [$tagname => $attrHash]; … … 1139 1122 # Thereafter, we will finally be setting the overriding metavalue for this metaname 1140 1123 if (!defined $prevmetavalue && !defined $metapos && $metamode eq "override") { 1124 print "override mode with no pos or prev value set. Removing all existing values for $metaname, and setting mode to accumulate for the new value.\n"; 1141 1125 # remove all values of $metaname metadata 1142 1126 $self->remove_from_doc_xml($gsdl_cgi, &util::filename_cat($archive_dir, $doc_xml_file), $metaname, undef, undef, $docid_secnum, $metamode); 1127 $metamode = "accumulate"; 1143 1128 } 1144 1129 # Edit the doc.xml file with the specified metadata name, value and position.
Note:
See TracChangeset
for help on using the changeset viewer.