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

Diff of /Sprout/ERDBLoadGroup.pm

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

revision 1.2, Wed Oct 1 03:07:08 2008 UTC revision 1.3, Thu Oct 2 16:32:42 2008 UTC
# Line 119  Line 119 
119    
120  =item source  =item source
121    
122  The object to be used by the subclass to access the source data.  The object to be used by the subclass to access the source data. If this parameter
123    is undefined, the source object will be retrieved from the database object as soon
124    as the client calls the L</source> method.
125    
126  =item db  =item db
127    
128  The [[ErdbPm]] object for the database being loaded.  The [[ErdbPm]] object for the database being loaded.
129    
 =item directory  
   
 Name of the directory to contain the load files.  
   
130  =item options  =item options
131    
132  Reference to a hash of options. At the current time, no options are needed  Reference to a hash of options. At the current time, no options are needed
# Line 140  Line 138 
138    
139  =back  =back
140    
 This constructor is deliberately kept lightweight in order to insure that  
 L</GetGroupHash> is high-performance. For this reason, the [[ERDBGeneratePm]]  
 objects in the loaders hash are not created until L</ProcessSection>.  
   
141  =cut  =cut
142    
143  sub new {  sub new {
144      # Get the parameters.      # Get the parameters.
145      my ($class, $source, $db, $directory, $options, @tables) = @_;      my ($class, $source, $db, $options, @tables) = @_;
146      # Create a statistics object      # Create a statistics object
147      my $stats = Stats->new();      my $stats = Stats->new();
148      # Compute the group name from the class name. It is the first word in      # Compute the group name from the class name. It is the first word in
149      # a name that is presumably capital case.      # a name that is presumably capital case.
150      my $group = ($class =~ /^([A-Z][a-z]+)/ ? $1 : $class);      my $group = ($class =~ /^([A-Z][a-z]+)/ ? $1 : $class);
151      # Validate the directory.      # Get the directory.
152        my $directory = $db->LoadDirectory();
153      Confess("Load directory \"$directory\" not found or invalid.") if ! -d $directory;      Confess("Load directory \"$directory\" not found or invalid.") if ! -d $directory;
154      # Create the ERDBLoadGroup object. Note that so far we don't have any loaders      # Create the ERDBLoadGroup object. Note that so far we don't have any loaders
155      # defined and the section has not yet been assigned. The "ProcessSection"      # defined and the section has not yet been assigned. The "ProcessSection"
# Line 324  Line 319 
319  sub source {  sub source {
320      # Get the parameters.      # Get the parameters.
321      my ($self) = @_;      my ($self) = @_;
322        # If we do not have a source object, retrieve it.
323        if (! defined $self->{source}) {
324            $self->{source} = $self->{db}->GetSourceObject();
325        }
326      # Return the result.      # Return the result.
327      return $self->{source};      return $self->{source};
328  }  }
# Line 468  Line 467 
467      my $retVal = {};      my $retVal = {};
468      # Loop through the list of load groups.      # Loop through the list of load groups.
469      for my $group ($erdb->LoadGroupList()) {      for my $group ($erdb->LoadGroupList()) {
         # Get a loader for this group.  
         my $loader = $erdb->Loader($group, {});  
470          # Stash the loader's tables in the output hash.          # Stash the loader's tables in the output hash.
471          $retVal->{$group} = $loader->{tables};          $retVal->{$group} = GetTables($erdb, $group);
472      }      }
473      # Return the result.      # Return the result.
474      return $retVal;      return $retVal;
475  }  }
476    
477    =head3 GetTables
478    
479        my @tables = ERDBLoadGroup::GetTables($group);
480    
481    Return the list of tables belonging to the specified load group.
482    
483    =over 4
484    
485    =item erdb
486    
487    Return the list of tables for the specified load group.
488    
489    =item group
490    
491    Name of relevant group.
492    
493    =item RETURN
494    
495    Returns a list of a tables loaded by the specified group.
496    
497    =back
498    
499    =cut
500    
501    sub GetTables {
502        # Get the parameters.
503        my ($erdb, $group) = @_;
504        # Create a loader for the specified group.
505        my $loader = $erdb->Loader($group, undef, {});
506        # Extract the list of tables.
507        my @retVal = @{$loader->{tables}};
508        # Return the result.
509        return @retVal;
510    }
511    
512    
513  =head3 ComputeGroups  =head3 ComputeGroups
514    
515      my @groupList = ERDBLoadGroup::ComputeGroups($erdb, \@groups);      my @groupList = ERDBLoadGroup::ComputeGroups($erdb, \@groups);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3