- Timestamp:
- 2018-10-25T20:12:42+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm
r32538 r32541 39 39 40 40 # TODO: 41 # - Run TODOs here and in plugout by Dr Bainbridge. Ask about docsql naming convention adopted42 # 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. 44 44 # - Startup parameters 45 45 # - incremental building: where do we need to add code to delete rows from our sql table after … … 48 48 # - Have not yet tested writing out just meta or just fulltxt to sql db and reading just that 49 49 # 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 51 52 52 53 # GreenstoneSQLPlugin inherits from GreenstoneXMLPlugin so that it if meta or fulltext … … 55 56 # is written out by GreenstoneSQLPlugout into the SQL db). 56 57 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 57 64 58 65 sub BEGIN { … … 83 90 'deft' => &get_default_process_exp(), 84 91 '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"} 91 123 ]; 92 124 … … 200 232 #$sid =~ s@^root@@; 201 233 $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" 203 235 if $self->{'verbosity'} > 1; 204 236 … … 229 261 $self->SUPER::init(@_); # super (GreenstoneXMLPlugin) will not yet be trying to read from doc.xml (docsql .xml) files in init(). 230 262 231 # TODO: how do we know what site we're dealing with unless this is passed in, by buildcol? 232 ########### 263 #################### 233 264 # print "@@@ SITE NAME: ". $self->{'site_name'} . "\n" if defined $self->{'site_name'}; 234 265 # 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 #################### 244 273 245 274 my $gs_sql = new gssql({ 246 275 'collection_name' => $ENV{'GSDLCOLLECTION'}, 247 276 'db_encoding' => $self->{'db_encoding'} 248 #'db_name' => $self->{'site_name'},249 #'build_mode' => $self->{'build_mode'},250 277 } 251 278 ); … … 265 292 } 266 293 267 my $db_name = $self->{'site_name'} || " localsite"; # one database per GS3 site294 my $db_name = $self->{'site_name'} || "greenstone2"; # one database per GS3 site, for GS2 the db is called greenstone2 268 295 #my $build_mode = $self->{'build_mode'} || "removeold"; 269 296 … … 274 301 # PrintError would already have displayed the warning message on load fail 275 302 $gs_sql->disconnect_from_db() 276 || warn("Unable to disconnect from database " . $self->{'site_name'} . "\n");303 || warn("Unable to disconnect from database.\n"); 277 304 die("Could not use db $db_name. Can't proceed.\n"); 278 305 }
Note:
See TracChangeset
for help on using the changeset viewer.