[Bio] / Sprout / Sprout.pm Repository:
ViewVC logotype

Diff of /Sprout/Sprout.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.126, Thu Apr 2 01:47:00 2009 UTC revision 1.128, Tue Jun 30 19:53:01 2009 UTC
# Line 45  Line 45 
45    
46  =head3 new  =head3 new
47    
48      my $sprout = Sprout->new($dbName, \%options);      my $sprout = Sprout->new(%parms)
49    
50  This is the constructor for a sprout object. It connects to the database and loads the  This is the constructor for a sprout object. It connects to the database and loads the
51  database definition into memory. The positional first parameter specifies the name of the  database definition into memory. The incoming parameter hash has the following permissible
52  database.  members (others will be ignored without error.
53    
54  =over 4  =over 4
55    
56    =item DBD
57    
58    Name of the XML file containing the database definition (default C<SproutDBD.xml> in
59    the DBD directory).
60    
61  =item dbName  =item dbName
62    
63  Name of the database. If omitted, the default Sprout database name is used.  Name of the database. If omitted, the default Sprout database name is used.
64    
65  =item options  =item options
66    
67  Table of options.  Sub-hash of special options.
68    
69  * B<dbType> type of database (currently C<mysql> for MySQL and C<pg> for PostgreSQL) (default C<mysql>)  * B<dbType> type of database (currently C<mysql> for MySQL and C<pg> for PostgreSQL) (default C<mysql>)
70    
71  * B<dataDir> directory containing the database definition file and the flat files used to load the data (default C<Data>)  * B<dataDir> directory containing the database definition file and the flat files used to load the data (default C<Data>)
72    
 * B<xmlFileName> name of the XML file containing the database definition (default C<SproutDBD.xml>)  
   
73  * B<userData> user name and password, delimited by a slash (default same as SEED)  * B<userData> user name and password, delimited by a slash (default same as SEED)
74    
75  * B<port> connection port (default C<0>)  * B<port> connection port (default C<0>)
# Line 87  Line 90 
90  I<fig> with a password of I<admin>. The database load files are in the directory  I<fig> with a password of I<admin>. The database load files are in the directory
91  F</usr/fig/SproutData>.  F</usr/fig/SproutData>.
92    
93      my $sprout = Sprout->new('Sprout', { userData => 'fig/admin', dataDir => '/usr/fig/SproutData' });      my $sprout = Sprout->new(dbName => 'Sprout', options => { userData => 'fig/admin', dataDir => '/usr/fig/SproutData' });
   
 In order to work properly with [[ERDBGeneratorPl]], the constructor has an alternate  
 form.  
   
     my $sprout = Sprout->new(dbd => $filename);  
94    
95  Where I<$fileName> is the name of the DBD file. This enables us to specify an alternate  The odd constructor signature is a result of Sprout's status as the first ERDB database,
96  DBD for the loader, which is important when the database format changes.  and the need to make it compatible with the needs of its younger siblings.
97    
98  =cut  =cut
99    
100  sub new {  sub new {
101      # Get the parameters.      # Get the parameters.
102      my ($class, $dbName, $options) = @_;      my ($class, %parms) = @_;
103      # Check for the alternate signature, and default the database name if it is missing.      # Look for an options hash.
104      if ($dbName eq 'dbd') {      my $options = $parms{options} || {};
105          $dbName = $FIG_Config::sproutDB;      # Plug in the DBD and name parameters.
106          $options = { xmlFileName => $options };      if ($parms{DBD}) {
107      } elsif (! defined $dbName) {          $options->{xmlFileName} = $parms{DBD};
         $dbName = $FIG_Config::sproutDB;  
     } elsif (ref $dbName eq 'HASH') {  
         $options = $dbName;  
         $dbName = $FIG_Config::sproutDB;  
108      }      }
109        my $dbName = $parms{dbName} || $FIG_Config::sproutDB;
110      # Compute the DBD directory.      # Compute the DBD directory.
111      my $dbd_dir = (defined($FIG_Config::dbd_dir) ? $FIG_Config::dbd_dir :      my $dbd_dir = (defined($FIG_Config::dbd_dir) ? $FIG_Config::dbd_dir :
112                                                    $FIG_Config::fig );                                                    $FIG_Config::fig );
# Line 4132  Line 4127 
4127      my $groupLoader = $erdb->Loader($groupName, $options);      my $groupLoader = $erdb->Loader($groupName, $options);
4128    
4129  Return an [[ERDBLoadGroupPm]] object for the specified load group. This method is used  Return an [[ERDBLoadGroupPm]] object for the specified load group. This method is used
4130  by [[ERDBGeneratorPl]] to create the load group objects. If you are not using  by L<ERDBGenerator.pl> to create the load group objects. If you are not using
4131  [[ERDBGeneratorPl]], you don't need to override this method.  L<ERDBGenerator.pl>, you don't need to override this method.
4132    
4133  =over 4  =over 4
4134    
# Line 4176  Line 4171 
4171      my @groups = $erdb->LoadGroupList();      my @groups = $erdb->LoadGroupList();
4172    
4173  Returns a list of the names for this database's load groups. This method is used  Returns a list of the names for this database's load groups. This method is used
4174  by [[ERDBGeneratorPl]] when the user wishes to load all table groups. The default  by L<ERDBGenerator.pl> when the user wishes to load all table groups. The default
4175  is a single group called 'All' that loads everything.  is a single group called 'All' that loads everything.
4176    
4177  =cut  =cut

Legend:
Removed from v.1.126  
changed lines
  Added in v.1.128

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3