Ignore:
Timestamp:
2018-10-25T20:12:42+13:00 (6 years ago)
Author:
ak19
Message:

Using proper parameters to GreenstoneSQLPlugin/Plugout instead of hardcoded values for params.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm

    r32538 r32541  
    3939
    4040# TODO:
    41 # - Run TODOs here and in plugout by Dr Bainbridge. Ask about docsql naming convention adopted
    42 # to identify OID. Better way?
    43 # collection names -> table names: hyphens not allowed? Changed to underscores.
     41# - Run TODOs here, in Plugout and in gssql.pm by Dr Bainbridge.
     42# Ask about docsql naming convention adopted to identify OID. Better way?
     43# collection names -> table names: it seems hyphens not allowed. Changed to underscores.
    4444# - Startup parameters
    4545# - incremental building: where do we need to add code to delete rows from our sql table after
     
    4848# - Have not yet tested writing out just meta or just fulltxt to sql db and reading just that
    4949# back in from the sql db while the remainder is to be read back in from the docsql .xml files.
    50 
     50# - Ask if I can assume that all SQL dbs (not just MySQL) will preserve the order of inserted nodes
     51# (sections) which in this case had made it easy to reconstruct the doc_obj in memory in the correct order
    5152
    5253# GreenstoneSQLPlugin inherits from GreenstoneXMLPlugin so that it if meta or fulltext
     
    5556# is written out by GreenstoneSQLPlugout into the SQL db).
    5657
     58# TODO:
     59# no more docoid in docsql .xml filename, set OID as attribute of root element inside docsql.xml file instead
     60# and parse it out
     61
     62# TODO: deal with incremental vs removeold. If docs removed from import folder, then import step
     63# won't delete it from archives but buildcol step will. Need to implement this with this database plugin or wherever the actual flow is
    5764
    5865sub BEGIN {
     
    8390    'deft' => &get_default_process_exp(),
    8491    'reqd' => "no" },
    85        { 'name' => "process_mode",
    86      'desc' => "{GreenstoneSQLPlug.process_mode}",
    87      'type' => "enum",
    88      'list' => $process_mode_list,
    89      'deft' => "all",
    90      'reqd' => "no"}
     92      { 'name' => "process_mode",
     93    'desc' => "{GreenstoneSQLPlug.process_mode}",
     94    'type' => "enum",
     95    'list' => $process_mode_list,
     96    'deft' => "all",
     97    'reqd' => "no"},
     98      { 'name' => "db_driver",
     99    'desc' => "{GreenstoneSQLPlug.db_driver}",
     100    'type' => "string",
     101    'deft' => "mysql",
     102    'reqd' => "yes"},
     103      { 'name' => "db_client_user",
     104    'desc' => "{GreenstoneSQLPlug.db_client_user}",
     105    'type' => "string",
     106    'deft' => "root",
     107    'reqd' => "yes"},
     108      { 'name' => "db_client_pwd",
     109    'desc' => "{GreenstoneSQLPlug.db_client_pwd}",
     110    'type' => "string",
     111    'deft' => "",
     112    'reqd' => "yes"}, # pwd required?
     113      { 'name' => "db_host",
     114    'desc' => "{GreenstoneSQLPlug.db_host}",
     115    'type' => "string",
     116    'deft' => "127.0.0.1",
     117    'reqd' => "yes"},
     118      { 'name' => "db_encoding",
     119    'desc' => "{GreenstoneSQLPlug.db_encoding}",
     120    'type' => "string",
     121    'deft' => "utf8",
     122    'reqd' => "yes"}
    91123    ];
    92124
     
    200232        #$sid =~ s@^root@@;
    201233        $sid = $doc_obj->get_top_section() if ($sid eq "root");
    202         print $outhandle "### did: $did, sid: |$sid|, fulltext: <TXT NOT PRINTED>\n"
     234        print $outhandle "### did: $did, sid: |$sid|, fulltext: <TXT>\n"
    203235        if $self->{'verbosity'} > 1;
    204236
     
    229261    $self->SUPER::init(@_); # super (GreenstoneXMLPlugin) will not yet be trying to read from doc.xml (docsql .xml) files in init().
    230262
    231         # TODO: how do we know what site we're dealing with unless this is passed in, by buildcol?
    232     ###########
     263    ####################
    233264#    print "@@@ SITE NAME: ". $self->{'site_name'} . "\n" if defined $self->{'site_name'};
    234265#    print "@@@ COLL NAME: ". $ENV{'GSDLCOLLECTION'} . "\n";
    235    
    236     $self->{'db_driver'} = "mysql";
    237     $self->{'site_name'} = "localsite";   
    238     $self->{'db_client_user'} = "root";
    239     $self->{'db_client_pwd'} = "6reenstone3";
    240     $self->{'build_mode'} = "removeold";
    241     $self->{'db_host'} = "127.0.0.1";
    242     $self->{'db_encoding'} = "utf8";
    243     ###########
     266
     267#    print STDERR "@@@@ db_pwd: " . $self->{'db_client_pwd'} . "\n";
     268#    print STDERR "@@@@ user: " . $self->{'db_client_user'} . "\n";
     269#    print STDERR "@@@@ db_host: " . $self->{'db_host'} . "\n";
     270#    print STDERR "@@@@ db_enc: " . $self->{'db_encoding'} . "\n";
     271#    print STDERR "@@@@ db_driver: " . $self->{'db_driver'} . "\n";
     272    ####################
    244273   
    245274    my $gs_sql = new gssql({
    246275    'collection_name' => $ENV{'GSDLCOLLECTION'},   
    247276    'db_encoding' => $self->{'db_encoding'}
    248     #'db_name' => $self->{'site_name'},
    249     #'build_mode' => $self->{'build_mode'},
    250277               }
    251278    );
     
    265292    }
    266293   
    267     my $db_name = $self->{'site_name'} || "localsite"; # one database per GS3 site
     294    my $db_name = $self->{'site_name'} || "greenstone2"; # one database per GS3 site, for GS2 the db is called greenstone2
    268295    #my $build_mode = $self->{'build_mode'} || "removeold";
    269296
     
    274301    # PrintError would already have displayed the warning message on load fail
    275302    $gs_sql->disconnect_from_db()
    276         || warn("Unable to disconnect from database " . $self->{'site_name'} . "\n");
     303        || warn("Unable to disconnect from database.\n");
    277304    die("Could not use db $db_name. Can't proceed.\n");
    278305    }
Note: See TracChangeset for help on using the changeset viewer.