[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.1, Tue Sep 30 15:23:55 2008 UTC revision 1.2, Wed Oct 1 03:07:08 2008 UTC
# Line 479  Line 479 
479    
480  =head3 ComputeGroups  =head3 ComputeGroups
481    
482      my @groupList = ERDBLoadGroup::ComputeGroups($erdb, $options, \@groups);      my @groupList = ERDBLoadGroup::ComputeGroups($erdb, \@groups);
483    
484  Compute the actual list of groups determined by the incoming options and  Compute the actual list of groups determined by the incoming group list.
 group list. If the list is an asterisk (C<*>), this method returns a list  
 of all the groups. If the options include C<resume>, this method returns  
 the first specified group and all the groups after it in the standard  
 ordering.  
485    
486  =over 4  =over 4
487    
# Line 493  Line 489 
489    
490  [[ErdbPm]] object for the database being loaded.  [[ErdbPm]] object for the database being loaded.
491    
 =item options  
   
 Reference to a hash of command-line options for the command that started  
 this load operation.  
   
492  =item groups  =item groups
493    
494  Reference to a list of group names specified on the command line.  Reference to a list of group names specified on the command line. A plus sign
495    (C<+>) has special meaning.
496    
497  =item RETURN  =item RETURN
498    
# Line 513  Line 505 
505    
506  sub ComputeGroups {  sub ComputeGroups {
507      # Get the parameters.      # Get the parameters.
508      my ($erdb, $options, $groups) = @_;      my ($erdb, $groups) = @_;
509      # Declare the return variable.      # Get the complete group list in standard order.
510        my @allGroups = $erdb->LoadGroupList();
511        # Create a hash for validation purposes. This will map each valid group
512        # name to its position in the standard order.
513        my %allGroupHash;
514        for (my $i = 0; $i <= $#allGroups; $i++) {
515            $allGroupHash{$allGroups[$i]} = $i;
516        }
517        # This variable will be the index of the last-processed group in
518        # the standard order. We start it before the first group in the list.
519        my $lastI = -1;
520        # The listed groups will be put in here.
521      my @retVal;      my @retVal;
522      # Check the group list.      # Process the group list.
523      if ($groups->[0] eq '*') {      for my $group (@$groups) {
524          # Load all groups.          # Process this group.
525          @retVal = $erdb->LoadGroupList();          if ($group eq '+') {
526      } elsif ($options->{resume}) {              # Here we have a plus sign. Push in everything after the previous
527          # Load all groups after and including the specified one.              # group processed. Note that we'll be ending at the last position.
528          my $starter = $groups->[0];              # A second "+" after this one will generate no entries in the result
         @retVal = $erdb->LoadGroupList();  
         shift @retVal until (! @retVal) || $retVal[0] eq $starter;  
         # If we didn't find the specified group, it's an error.  
         Confess("Invalid group name \"$starter\" in parameter list.") if (! @retVal);  
     } else {  
         # Here the groups are all on the command line. Stuff them in the return  
529          # list.          # list.
530          @retVal = @{$groups};              my $firstI = $lastI + 1;
531          # Verify that they're all valid.              $lastI = $#allGroups;
532          my %checker = map { $_ => 1 } $erdb->LoadGroupList();              push @retVal, @allGroups[$firstI..$lastI];
533          for my $group (@retVal) {          } elsif (exists $allGroupHash{$group}) {
534              Confess("Invalid group name \"$group\" in parameter list.")              # Here we have a valid group name. Push it into the list.
535                  if ! $checker{$group};              push @retVal, $group;
536                # Remember its location in case there's a plus sign.
537                $lastI = $allGroupHash{$group};
538            } else {
539                # This is an error.
540                Confess("Invalid load group name $group.");
541          }          }
542      }      }
543      # Normalize the group names and return them.      # Normalize the group names and return them.
544      return map { ucfirst $_ } @retVal;      return map { ucfirst $_ } @retVal;
545  }  }
546    
547    =head3 KillFileName
548    
549        my $fileName = ERDBLoadGroup::KillFileName($erdb, $directory);
550    
551    Compute the kill file name for the specified database in the specified
552    directory. When the [[ERDBGeneratorPl]] script sees the kill file, it will
553    terminate itself at the end of the current section.
554    
555    =over 4
556    
557    =item erdb
558    
559    Database
560    
561    =item directory (optional)
562    
563    Load directory for the database.
564    
565    =item RETURN
566    
567    Returns the specified database's kill file name. If a directory is specified,
568    it is prefixed to the name with an intervening slash.
569    
570    
571    =back
572    
573    =cut
574    
575    sub KillFileName {
576        # Get the parameters.
577        my ($erdb, $directory) = @_;
578        # Compute the kill file name. We start with the database name in
579        # lower case, then prefix it with "kill_";
580        my $dbName = lc ref $erdb;
581        my $retVal = ERDBGenerate::CreateFileName("kill_$dbName", undef, 'control', $directory);
582        # Return the result.
583        return $retVal;
584    }
585    
586    
587  =head2 Virtual Methods  =head2 Virtual Methods
588    
589  =head3 Generate  =head3 Generate

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3