Ignore:
Timestamp:
2018-10-18T20:41:40+13:00 (6 years ago)
Author:
ak19
Message:

UNDOING PART OF RECENT COMMIT: Calling superclass GreenstoneXMLPlugout's begin(), end(), close_group_output(), pre_saveas() and post_saveas() only if MySQLPlugout's process mode is not set to output ALL (meta and text) to sql db. But they should be called at all times even when process mode is set to output all, because assoc files must be written out and breadcrumbs must be written to doc.xml.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugouts/MySQLPlugout.pm

    r32522 r32523  
    136136    # won't bother preparing GreenstoneXMLPlugout by calling superclass' begin()
    137137    # finally, can call begin on super - important as doc.xml is opened as a group etc
    138 
    139     if($proc_mode ne "all") { # TODO Q
    140     $self->GreenstoneXMLPlugout::begin(@_);
    141     }
     138   
     139    $self->GreenstoneXMLPlugout::begin(@_);
    142140}
    143141
     
    148146
    149147    # do the superclass stuff first, as any sql db failures should not prevent superclass cleanup
    150    
    151     if($self->{'process_mode'} ne "all") {# TODO Q
    152     $self->GreenstoneXMLPlugout::end(@_);
    153     }
     148    $self->GreenstoneXMLPlugout::end(@_);   
    154149   
    155150    $self->disconnect_from_db() || warn("Unable to disconnect from database " . $self->{'site_name'} . "\n"); # disconnect_from_db() will also issue a warning, but this may be clearer
    156151}
    157152 
    158 sub close_group_output {
    159     my $self = shift (@_);
    160    
    161     if($self->{'process_mode'} ne "all") { # TODO Q
    162     $self->GreenstoneXMLPlugout::close_group_output();
    163     }
    164 }
    165153   
    166154# TODO: check arc-inf.db for whether each entry is to be deleted/indexed/reindexed/been indexed
     
    172160   
    173161    # 1. pre save out and saving debug handle
    174     my ($docxml_outhandler, $output_file);
    175     if($proc_mode ne "all") { # TODO Q
    176     ($docxml_outhandler, $output_file) = $self->GreenstoneXMLPlugout::pre_saveas(@_);
    177 
    178     $self->{'debug_outhandle'} = $docxml_outhandler if ($self->{'debug'}); # STDOUT if debug
    179     }
    180     elsif ($self->{'debug'}) { # if we didn't call superclass::pre_saveas, then set debug handle
    181     $self->{'debug_outhandle'} = STDOUT; # superclass also debugs to STDOUT
    182     # TODO: also set debugging in begin()? Then stmts creating db and tables also sent to debug out and not executed
    183     }
     162
     163    # must call superclass (pre/post) saveas methods, as they handle assoc_files too
     164    my ($docxml_outhandler, $output_file) = $self->GreenstoneXMLPlugout::pre_saveas(@_);
     165
     166    $self->{'debug_outhandle'} = $docxml_outhandler if ($self->{'debug'}); # STDOUT if debug
     167
     168    # TODO: also set debugging in begin()? Then stmts creating db and tables also sent to debug out and not executed
     169
     170    # TODO: remove unused old_unused_saveas from GreenstoneXMLPlugout
    184171   
    185172   
    186173    # 2. overriding saving behaviour to do what the superclass does PLUS saving to sql db   
    187174
    188     if($proc_mode ne "all" ) { # if all, then nothing to go into doc.xml, otherwise:
     175    #NOTE: if proc_mode == all, then "breadcrumbs" go into both meta and txt elements of doc.xml:
     176    # statements pointing viewer to the sql db for contents
    189177   
    190     # write the INVERSE into doc.xml as to what is written to the db
    191    
    192     my $docxml_output_options = { 'output' => docprint::OUTPUT_NONE }; # TODO Q
    193    
    194     if($proc_mode eq "meta_only" ) { # since only meta to go into MySQL db, text will go into docxml
    195         $docxml_output_options->{'output'} = docprint::OUTPUT_TEXT_ONLY;
    196     } elsif($proc_mode eq "text_only" ) { # since only full text to go into MySQL db, meta will go into docxml
    197         $docxml_output_options->{'output'} = docprint::OUTPUT_META_ONLY;
    198     }
    199 
    200     # now we've prepared to write out whatever is meant to go into docxml
    201     # and can do actual the steps superclass GreenstoneXMLPlugout carries out to write out docxml
    202     # So: write out the doc xml file for the current document
    203     my $section_text = &docprint::get_section_xml($doc_obj, $docxml_output_options);
    204     print $docxml_outhandler $section_text;   
    205     }
     178    # write the INVERSE into doc.xml as to what is written to the db   
     179    my $docxml_output_options = { 'output' => docprint::OUTPUT_NONE };
     180    if($proc_mode eq "meta_only" ) { # since only meta to go into MySQL db, text will go into docxml
     181    $docxml_output_options->{'output'} = docprint::OUTPUT_TEXT_ONLY;
     182    } elsif($proc_mode eq "text_only" ) { # since only full text to go into MySQL db, meta will go into docxml
     183    $docxml_output_options->{'output'} = docprint::OUTPUT_META_ONLY;
     184    }
     185   
     186    # now we've prepared to write out whatever is meant to go into docxml
     187    # and can do actual the steps superclass GreenstoneXMLPlugout carries out to write out docxml
     188    # So: write out the doc xml file for the current document
     189    my $section_text = &docprint::get_section_xml($doc_obj, $docxml_output_options);
     190    print $docxml_outhandler $section_text;   
     191   
    206192   
    207193    # We also write out whatever needs to go into the MySQL database
     
    210196   
    211197    # 3. post save out
    212     if($proc_mode ne "all" ) { # TODO Q
    213     #$self->GreenstoneXMLPlugout::post_saveas(@_);
    214     $self->GreenstoneXMLPlugout::post_saveas($doc_obj, $doc_dir, $docxml_outhandler, $output_file);
    215     }
     198    #$self->GreenstoneXMLPlugout::post_saveas(@_);
     199    $self->GreenstoneXMLPlugout::post_saveas($doc_obj, $doc_dir, $docxml_outhandler, $output_file);
     200   
    216201   
    217202    # database connection is closed in end() method
Note: See TracChangeset for help on using the changeset viewer.