Changeset 32079 for main/trunk


Ignore:
Timestamp:
11/23/17 13:50:51 (3 years ago)
Author:
kjdon
Message:

removed some print statements. Added some more explanations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/modmetadataaction.pm

    r32077 r32079  
    205205sub set_index_metadata_entry
    206206{
    207     print STDERR "1\n";
    208207    my $self = shift @_;
    209208    my ($collect_dir,$collect,$infodbtype,$docid,$metaname,$metapos,$metavalue,$metamode,$prevmetavalue) = @_;
     
    216215    my $infodb_file_path = &dbutil::get_infodb_file_path($infodbtype, $collect_tail, $index_text_directory);
    217216   
    218     print STDERR "2\n";
    219217#   print STDERR "**** infodb file path = $infodb_file_path\n";
    220218#   print STDERR "***** infodb type = $infodbtype\n";
     
    225223    # Set the metadata value
    226224    if (defined $metapos) {
    227     print STDERR "3\n";
    228225    # if metamode=accumulate AND metapos, warn user and then use metapos
    229226    if (defined $metamode && $metamode eq "accumulate") {
     
    234231    }
    235232    elsif (defined $prevmetavalue) {
    236     print STDERR "4\n";
    237         my $array = $doc_rec->{$metaname};
     233    my $array = $doc_rec->{$metaname};
    238234        my $length = @$array;
    239235
    240         my $found = 0;
     236    my $found = 0;
    241237        for (my $i = 0; $i < $length; $i++){
    242238            if(defined $doc_rec->{$metaname}->[$i] && $doc_rec->{$metaname}->[$i] eq $prevmetavalue){
     
    252248    }
    253249    elsif (defined $metamode && $metamode eq "override") {
    254     print STDERR "5\n";
    255250    $doc_rec->{$metaname} = [ $metavalue ];
    256251    }
    257252    else { # default for index was to override, but because accumulate is less destructive,
    258253    # and because accumulate is the default for archives and import, that's the new default for index too
    259     print STDERR "6\n";
    260254    if(defined $doc_rec->{$metaname}) {
    261255        push(@{$doc_rec->{$metaname}}, $metavalue); # accumulate the value for that metaname
     
    264258    }
    265259    }
    266     print STDERR "6\n";
    267260 
    268261    my $status = &dbutil::set_infodb_entry($infodbtype, $infodb_file_path,$docid,$doc_rec);
     
    861854
    862855                if ($parser->{'parameters'}->{'poscount'} == $parser->{'parameters'}->{'metapos'}) {
    863                 print STDERR "#### got pos match!!\n";
     856                ###print STDERR "#### got pos match!!\n";
    864857                # Get the value and override the current value
    865858                my $metavalue = $parser->{'parameters'}->{'metavalue'};
     
    872865            elsif (defined $parser->{'parameters'}->{'prevmetavalue'}) { # if no pos defined but prevmeta defined, then wait for prevmeta match
    873866                if ($parser->{'parameters'}->{'prevmetavalue'} eq $attrHash->{'_content'}) {
    874                 print STDERR "### prev meta value matches\n";
     867                ###print STDERR "### prev meta value matches\n";
    875868                my $metavalue = $parser->{'parameters'}->{'metavalue'};
    876869                $attrHash->{'_content'} = $metavalue;
     
    879872                }
    880873            }
    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.         
    896879        }
    897880    }
     
    913896    my $opt_doc_secnum = $parser->{'parameters'}->{'secnum'};
    914897   
    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";
    916899   
    917900    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";
    919902
    920903    my $metaname = $parser->{'parameters'}->{'metaname'};
     
    941924   
    942925###!!!  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";
    944927   
    945928    # Accumulate the metadata
     
    963946    if ($curr_secnum eq $opt_doc_secnum
    964947        && ($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.
    965950        if ($metamode eq "override") {
    966951        print "Got to end of <Description> block. No metadata value to override.  Switching 'metamode' to accumulate\n";
     
    982967        my $append_metadata = [ "Metadata" => $metadata_attr ];
    983968        my $description_content = $attrHash->{'_content'};
    984        
    985969        print "Appending metadata to doc.xml\n";
    986970       
     
    1000984##      print STDERR "**** NOT ACCUMULATE?!? \n";
    1001985    }
    1002 
    1003986    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!!
    1004987    return [$tagname => $attrHash];
     
    11391122    # Thereafter, we will finally be setting the overriding metavalue for this metaname
    11401123    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";
    11411125    # remove all values of $metaname metadata
    11421126    $self->remove_from_doc_xml($gsdl_cgi, &util::filename_cat($archive_dir, $doc_xml_file), $metaname, undef, undef, $docid_secnum, $metamode);
     1127    $metamode = "accumulate";
    11431128    }
    11441129    # Edit the doc.xml file with the specified metadata name, value and position.
Note: See TracChangeset for help on using the changeset viewer.