Ignore:
Timestamp:
2018-11-02T19:07:16+13:00 (5 years ago)
Author:
ak19
Message:
  1. Overhaul of GreenstoneSQLPlugs to handle removeold and incremental delete correctly. And now code also automatically handles 'non-incremental delete' (see mention in ArchivesInfPlugin). The new version no longer does lazy loading for getting the sql db connection in the GS SQL Plugin, as now the connection needs to be active since the start of the plugin to run SQL delete statements on remove_old. So the db connection code for the GS SQL plugin has moved back into its init() method. Lots of changes to gssql.pm (and some flow on effects to the GS SQL Plugout) as when database tables exist and need to be created have changed. 2. Undoing most of the changes of changeset 32555 since we're doing incremental delete and removeold differently and in the correct way now when using the GreenstoneSQLPlugs.
Location:
main/trunk/greenstone2/perllib/plugouts
Files:
2 edited

Legend:

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

    r32555 r32563  
    347347}
    348348
    349 # GreenstoneSQLPlugout needs to know whether we're doing removeold or not
    350 sub set_incremental_options {
    351     my $self= shift (@_);
    352     my ($removeold, $keepold, $incremental, $incremental_mode) = @_;
    353    
    354     $self->{'removeold'}        = $removeold;
    355     $self->{'keepold'}          = $keepold;
    356     $self->{'incremental'}      = $incremental;
    357     $self->{'incremental_mode'} = $incremental_mode;
    358 }
    359349
    360350# OIDtype may be "hash" or "hash_on_full_filename" or "incremental" or "filename" or "dirname" or "full_filename" or "assigned"
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm

    r32560 r32563  
    5353# It's fine: the die() stmts all take place before setting up the super class' begin
    5454
    55 # TODO Q: about build_mode: how to detect removeold
     55# TODO Q: about build_mode: how to detect removeold. Now handled by
     56#   GreenstoneSQLPlugout::remove_all(), which is inherited from a base plugin.
    5657# TODO: deal with -removeold and everything? Or type out instructions for user
    5758
     
    117118        return bless $self, $class;
    118119    }
    119     print STDERR "***** GreenstoneSQLPlugout process mode = \"", $self->{'process_mode'}, "\"\n";
     120    #print STDERR "***** GreenstoneSQLPlugout process mode = \"", $self->{'process_mode'}, "\"\n";
    120121   
    121122    return bless $self, $class;
     
    163164   
    164165    my $db_name = $self->{'site_name'} || "greenstone2"; # one database per GS3 site, for GS2 the db is called greenstone2
    165     my $build_mode = ($self->{'removeold'}) ? "removeold" : "incremental";
    166     print STDERR "@@@@@@@@@@@@ remove_old: $build_mode\n";
    167    
    168     if(!$gs_sql->load_db_and_tables($db_name, $build_mode)) {
    169    
     166    my $proc_mode = $self->{'process_mode'};
     167   
     168
     169    my $success = $gs_sql->use_db($db_name);
     170   
     171    if($success && $proc_mode ne "text_only") {
     172    ##print STDERR "@@@@ Ensuring meta table exists\n";
     173    $success = $gs_sql->ensure_meta_table_exists();
     174    }   
     175    if($success && $proc_mode ne "meta_only") {
     176    ##print STDERR "@@@@ Ensuring fulltxt table exists\n";
     177    $success = $gs_sql->ensure_fulltxt_table_exists();
     178    }
     179    #if(!$gs_sql->load_db_and_tables($db_name, $proc_mode)) {
     180    if(!$success) {
    170181    # This is fatal for the plugout, let's terminate here after disconnecting again
    171182    # PrintError would already have displayed the warning message on load fail
     
    177188    # prepare the shared/common HANDLES to SQL insert statements that contain placeholders
    178189    # and which we will reuse repeatedly when actually executing the insert statements
    179     my $proc_mode = $self->{'process_mode'};
     190   
    180191    if($proc_mode eq "all" || $proc_mode eq "meta_only" ) {
    181192    $self->{'metadata_prepared_insert_statement_handle'} = $gs_sql->prepare_insert_metadata_row_stmthandle();
     
    188199    $self->{'gs_sql'} = $gs_sql;
    189200   
    190     print STDERR "#### Meta stmt: " . $self->{'metadata_prepared_insert_statement_handle'}->{'Statement'} . "\n";
    191     print STDERR "#### Full stmt: " . $self->{'fulltxt_prepared_insert_statement_handle'}->{'Statement'} . "\n";
     201    ##print STDERR "#### Meta stmt: " . $self->{'metadata_prepared_insert_statement_handle'}->{'Statement'} . "\n";
     202    ##print STDERR "#### Full stmt: " . $self->{'fulltxt_prepared_insert_statement_handle'}->{'Statement'} . "\n";
    192203   
    193204    # if setting up to work with sql db failed, we'd have terminated and wouldn't come up to here:
Note: See TracChangeset for help on using the changeset viewer.