Index: /main/trunk/greenstone2/bin/script/import.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/import.pl	(revision 32540)
+++ /main/trunk/greenstone2/bin/script/import.pl	(revision 32541)
@@ -89,9 +89,5 @@
         'desc' => "{export.saveas.GreenstoneMETS}"},
       { 'name' => "GreenstoneSQL",
-        'desc' => "{export.saveas.GreenstoneSQL}"},
-      { 'name' => "GreenstoneSQL_metadata_only",
-        'desc' => "{export.saveas.GreenstoneSQL.meta_only}"},
-      { 'name' => "GreenstoneSQL_fulltext_only",
-        'desc' => "{export.saveas.GreenstoneSQL.text_only}"},
+        'desc' => "{export.saveas.GreenstoneSQL}"}
       ];
 
Index: /main/trunk/greenstone2/perllib/gssql.pm
===================================================================
--- /main/trunk/greenstone2/perllib/gssql.pm	(revision 32540)
+++ /main/trunk/greenstone2/perllib/gssql.pm	(revision 32541)
@@ -106,4 +106,5 @@
 # TODO: Consider AutoCommit status (and Autocommit off allowing commit or rollback for GS coll build cancel) later
 
+# TODO: where should the defaults for these params be, here or in GS-SQLPlugin/Plugout?
 sub connect_to_db {
     my $self= shift (@_);
@@ -210,4 +211,7 @@
 # This will terminate if the db does not exist. Unlike load_db_and_tables() above, used by
 # GreenstoneSQLPlugout, this method will not attempt to create the requested db (nor its tables)
+# TODO: GS SQLPlugin is called before GS SQLPlugout and attempts to use_db() - called in plugin's
+# init() method. This will fail if the db does not exist. Ideally want our plugin only called
+# during buildcol.pl
 sub use_db {
     my $self= shift (@_);
@@ -294,5 +298,5 @@
 
 # Don't call this: it will delete the meta and full text tables for ALL collections in $db_name (localsite by default)!
-# this is just for debugging
+# This method is just here for debugging (for testing creating a database when there is none)
 sub _delete_database {
     my $self= shift (@_);
@@ -428,5 +432,5 @@
 # see https://www.perlmonks.org/bare/?node=DBI%20Recipes
 #    The page further has a table_exists function that could work with proper comparison
-# Couldn't get the first solution at https://www.perlmonks.org/bare/?node_id=500050 to work though
+# TODO: Couldn't get the first solution at https://www.perlmonks.org/bare/?node_id=500050 to work though
 sub table_exists {
     my $self = shift (@_);
Index: /main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm	(revision 32540)
+++ /main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm	(revision 32541)
@@ -39,7 +39,7 @@
 
 # TODO:
-# - Run TODOs here and in plugout by Dr Bainbridge. Ask about docsql naming convention adopted
-# to identify OID. Better way?
-# collection names -> table names: hyphens not allowed? Changed to underscores.
+# - Run TODOs here, in Plugout and in gssql.pm by Dr Bainbridge.
+# Ask about docsql naming convention adopted to identify OID. Better way?
+# collection names -> table names: it seems hyphens not allowed. Changed to underscores.
 # - Startup parameters
 # - incremental building: where do we need to add code to delete rows from our sql table after
@@ -48,5 +48,6 @@
 # - Have not yet tested writing out just meta or just fulltxt to sql db and reading just that 
 # back in from the sql db while the remainder is to be read back in from the docsql .xml files.
-
+# - Ask if I can assume that all SQL dbs (not just MySQL) will preserve the order of inserted nodes
+# (sections) which in this case had made it easy to reconstruct the doc_obj in memory in the correct order
 
 # GreenstoneSQLPlugin inherits from GreenstoneXMLPlugin so that it if meta or fulltext
@@ -55,4 +56,10 @@
 # is written out by GreenstoneSQLPlugout into the SQL db).
 
+# TODO:
+# no more docoid in docsql .xml filename, set OID as attribute of root element inside docsql.xml file instead
+# and parse it out
+
+# TODO: deal with incremental vs removeold. If docs removed from import folder, then import step
+# won't delete it from archives but buildcol step will. Need to implement this with this database plugin or wherever the actual flow is
 
 sub BEGIN {
@@ -83,10 +90,35 @@
 	'deft' => &get_default_process_exp(),
 	'reqd' => "no" },
-       { 'name' => "process_mode", 
-	 'desc' => "{GreenstoneSQLPlug.process_mode}",
-	 'type' => "enum",
-	 'list' => $process_mode_list,
-	 'deft' => "all",
-	 'reqd' => "no"}
+      { 'name' => "process_mode", 
+	'desc' => "{GreenstoneSQLPlug.process_mode}",
+	'type' => "enum",
+	'list' => $process_mode_list,
+	'deft' => "all",
+	'reqd' => "no"},
+      { 'name' => "db_driver", 
+	'desc' => "{GreenstoneSQLPlug.db_driver}",
+	'type' => "string",	
+	'deft' => "mysql",
+	'reqd' => "yes"},
+      { 'name' => "db_client_user", 
+	'desc' => "{GreenstoneSQLPlug.db_client_user}",
+	'type' => "string",	
+	'deft' => "root",
+	'reqd' => "yes"},
+      { 'name' => "db_client_pwd", 
+	'desc' => "{GreenstoneSQLPlug.db_client_pwd}",
+	'type' => "string",
+	'deft' => "",
+	'reqd' => "yes"}, # pwd required?
+      { 'name' => "db_host", 
+	'desc' => "{GreenstoneSQLPlug.db_host}",
+	'type' => "string",
+	'deft' => "127.0.0.1",
+	'reqd' => "yes"},
+      { 'name' => "db_encoding", 
+	'desc' => "{GreenstoneSQLPlug.db_encoding}",
+	'type' => "string",
+	'deft' => "utf8",
+	'reqd' => "yes"}
     ];
 
@@ -200,5 +232,5 @@
 	    #$sid =~ s@^root@@;
 	    $sid = $doc_obj->get_top_section() if ($sid eq "root");
-	    print $outhandle "### did: $did, sid: |$sid|, fulltext: <TXT NOT PRINTED>\n"
+	    print $outhandle "### did: $did, sid: |$sid|, fulltext: <TXT>\n"
 		if $self->{'verbosity'} > 1;
 
@@ -229,23 +261,18 @@
     $self->SUPER::init(@_); # super (GreenstoneXMLPlugin) will not yet be trying to read from doc.xml (docsql .xml) files in init().
 
-        # TODO: how do we know what site we're dealing with unless this is passed in, by buildcol?
-    ###########
+    ####################
 #    print "@@@ SITE NAME: ". $self->{'site_name'} . "\n" if defined $self->{'site_name'};
 #    print "@@@ COLL NAME: ". $ENV{'GSDLCOLLECTION'} . "\n";
-    
-    $self->{'db_driver'} = "mysql";
-    $self->{'site_name'} = "localsite";    
-    $self->{'db_client_user'} = "root";
-    $self->{'db_client_pwd'} = "6reenstone3";
-    $self->{'build_mode'} = "removeold";
-    $self->{'db_host'} = "127.0.0.1";
-    $self->{'db_encoding'} = "utf8";
-    ###########
+
+#    print STDERR "@@@@ db_pwd: " . $self->{'db_client_pwd'} . "\n";
+#    print STDERR "@@@@ user: " . $self->{'db_client_user'} . "\n";
+#    print STDERR "@@@@ db_host: " . $self->{'db_host'} . "\n";
+#    print STDERR "@@@@ db_enc: " . $self->{'db_encoding'} . "\n";
+#    print STDERR "@@@@ db_driver: " . $self->{'db_driver'} . "\n";
+    ####################
     
     my $gs_sql = new gssql({
 	'collection_name' => $ENV{'GSDLCOLLECTION'},	
 	'db_encoding' => $self->{'db_encoding'}
-	#'db_name' => $self->{'site_name'},
-	#'build_mode' => $self->{'build_mode'},
 			   }
 	);
@@ -265,5 +292,5 @@
     }
     
-    my $db_name = $self->{'site_name'} || "localsite"; # one database per GS3 site
+    my $db_name = $self->{'site_name'} || "greenstone2"; # one database per GS3 site, for GS2 the db is called greenstone2
     #my $build_mode = $self->{'build_mode'} || "removeold";
 
@@ -274,5 +301,5 @@
 	# PrintError would already have displayed the warning message on load fail
 	$gs_sql->disconnect_from_db()
-	    || warn("Unable to disconnect from database " . $self->{'site_name'} . "\n");
+	    || warn("Unable to disconnect from database.\n");
 	die("Could not use db $db_name. Can't proceed.\n");
     }
Index: /main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm	(revision 32540)
+++ /main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm	(revision 32541)
@@ -41,4 +41,5 @@
 # TODO: SIGTERM rollback and disconnect?
 # TODO Q: what about verbosity for debugging
+# TODO Q: introduced site_name param to plugins and plugouts. Did I do it right? And should they have hiddengli = "yes"
 
 # this plugout does not output xml to a file, but outputs rows into a mysql table
@@ -64,12 +65,39 @@
         'desc' => "{GreenstoneSQLPlug.process_mode.all}" } ];
 
+# The following are the saveas.options:
 my $arguments = [ 
-       { 'name' => "process_mode", 
-	 'desc' => "{GreenstoneSQLPlug.process_mode}",
-	 'type' => "enum",
-	 'list' => $process_mode_list,
-	 'deft' => "all",
-	 'reqd' => "no",
-	 'hiddengli' => "no"} ];
+    { 'name' => "process_mode", 
+      'desc' => "{GreenstoneSQLPlug.process_mode}",
+      'type' => "enum",
+      'list' => $process_mode_list,
+      'deft' => "all",
+      'reqd' => "no",
+      'hiddengli' => "no"},
+    { 'name' => "db_driver", 
+      'desc' => "{GreenstoneSQLPlug.db_driver}",
+      'type' => "string",	
+      'deft' => "mysql",
+      'reqd' => "yes"},
+    { 'name' => "db_client_user", 
+      'desc' => "{GreenstoneSQLPlug.db_client_user}",
+      'type' => "string",	
+      'deft' => "root",
+      'reqd' => "yes"},
+    { 'name' => "db_client_pwd", 
+      'desc' => "{GreenstoneSQLPlug.db_client_pwd}",
+      'type' => "string",
+      'deft' => "",
+      'reqd' => "yes"}, # pwd required?
+    { 'name' => "db_host", 
+      'desc' => "{GreenstoneSQLPlug.db_host}",
+      'type' => "string",
+      'deft' => "127.0.0.1",
+      'reqd' => "yes"},
+    { 'name' => "db_encoding", 
+      'desc' => "{GreenstoneSQLPlug.db_encoding}",
+	'type' => "string",
+      'deft' => "utf8",
+      'reqd' => "yes"}
+    ];
 
 my $options = { 'name'     => "GreenstoneSQLPlugout",
@@ -103,17 +131,20 @@
     my $self= shift (@_);
 
+    # The saveas.options
+    #print STDERR "@@@@ PLUGOUT db_pwd: " . $self->{'db_client_pwd'} . "\n";
+    #print STDERR "@@@@ user: " . $self->{'db_client_user'} . "\n";
+    #print STDERR "@@@@ db_host: " . $self->{'db_host'} . "\n";
+    #print STDERR "@@@@ db_enc: " . $self->{'db_encoding'} . "\n";
+    #print STDERR "@@@@ db_driver: " . $self->{'db_driver'} . "\n";
+    #print STDERR "@@@@ proc_mode: " . $self->{'process_mode'} . "\n";
+    
     ########### TODO: these should be set from cmdline/GLI options to plugout #########
-    $self->{'db_driver'} = "mysql";
-    $self->{'site_name'} = "localsite";    
-    $self->{'db_client_user'} = "root";
-    $self->{'db_client_pwd'} = "6reenstone3";
+
     $self->{'build_mode'} = "removeold";
-    #$self->{'db_host'} = "127.0.0.1";
-    #$self->{'db_encoding'} = "utf8";
-    #TODO: proc_mode is also a saveas option    
-    
+
     ############ LOAD NECESSARY OPTIONS ###########
-    print STDERR "########## COLLECTION: ". $ENV{'GSDLCOLLECTION'}."\n";
-    #$self->{'collection_name'} = $ENV{'GSDLCOLLECTION'};
+    #print "@@@ plugout SITE NAME: ". $self->{'site_name'} . "\n" if defined $self->{'site_name'};
+    #print STDERR "########## COLLECTION: ". $ENV{'GSDLCOLLECTION'}."\n";
+
     print STDERR "***** GreenstoneSQLPlugout process mode = \"", $self->{'process_mode'}, "\"\n";
 
@@ -121,6 +152,4 @@
 	'collection_name' => $ENV{'GSDLCOLLECTION'},	
 	'db_encoding' => $self->{'db_encoding'}
-	#'db_name' => $self->{'site_name'},
-	#'build_mode' => $self->{'build_mode'},
     };
 
@@ -142,5 +171,5 @@
     }
     
-    my $db_name = $self->{'site_name'} || "localsite"; # one database per GS3 site
+    my $db_name = $self->{'site_name'} || "greenstone2"; # one database per GS3 site, for GS2 the db is called greenstone2
     my $build_mode = $self->{'build_mode'} || "removeold";
     if(!$gs_sql->load_db_and_tables($db_name, $build_mode)) {
@@ -149,5 +178,5 @@
 	# PrintError would already have displayed the warning message on load fail
 	$gs_sql->disconnect_from_db()
-	    || warn("Unable to disconnect from database " . $self->{'site_name'} . "\n");
+	    || warn("Unable to disconnect from database.\n");
 	die("Could not use db $db_name and/or prepare its tables. Can't proceed.\n");
     }
Index: /main/trunk/greenstone2/perllib/strings.properties
===================================================================
--- /main/trunk/greenstone2/perllib/strings.properties	(revision 32540)
+++ /main/trunk/greenstone2/perllib/strings.properties	(revision 32541)
@@ -417,7 +417,5 @@
 
 export.saveas.GreenstoneXML:Greenstone XML Archive format
-export.saveas.GreenstoneSQL:Save metadata and text in MySQL database
-export.saveas.GreenstoneSQL.meta_only:Store metadata in a MySQL database (and full text in Greenstone XML Archive format)
-export.saveas.GreenstoneSQL.text_only:Store full text in a MySQL database (and metadata in Greenstone XML Archive format)
+export.saveas.GreenstoneSQL:Store the metadata and/or full text in a MySQL database, and the converse in the Greenstone XML Archive format.
 
 export.saveas.MARCXML:MARC XML format (an XML version of MARC 21)
@@ -1448,10 +1446,10 @@
 METSPlugout.xslt_mets:Transform a mets's docmets.xml with the XSLT in the named file.  
 
-GreenstoneSQLPlugout.desc:Output metadata and/or full text to a MySQL database (named after GS3 site name for GS3 or named greenstone2 for GS2) instead of doc.xml. For Greenstone 3, the database name is the GS3 site name. For Greenstone 2, the database name is greenstone2.
+GreenstoneSQLPlugout.desc:Output metadata and/or full text to a MySQL database (named after GS3 site name for GS3 or named greenstone2 for GS2) instead of doc.xml. For Greenstone 3, the database name is the GS3 site name. For Greenstone 2, the database name is greenstone2. The basic saveas.options for this Plugout are the same as the basic options for the matching GreenstoneSQLPlugin.
 
 # 
 # GreenstoneSQLPlug strings are shared by both GreenstoneSQLPlugout and GreenstoneSQLPlugin
 #
-GreenstoneSQLPlug.process_mode:Setting determines whether full text and/or metadata will be output to a MySQL database instead of to doc.xml during import.
+GreenstoneSQLPlug.process_mode:Setting determines whether full text and/or metadata will be output to a MySQL database instead of to doc.xml during import. Choose one of meta_only, text_only, or all (default).
 GreenstoneSQLPlug.process_mode.all:Import stage outputs the full text and metadata to a MySQL database instead of to doc.xml.
 GreenstoneSQLPlug.process_mode.meta_only:Import stage outputs the metadata to a MySQL database and any text to doc.xml.
