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

Diff of /Sprout/ERDBLoad.pm

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

revision 1.9, Thu Jan 19 09:28:33 2006 UTC revision 1.10, Mon Jan 30 21:52:04 2006 UTC
# Line 51  Line 51 
51  TRUE if the data is to be loaded from an existing file, FALSE if a file is  TRUE if the data is to be loaded from an existing file, FALSE if a file is
52  to be created.  to be created.
53    
54    =item ignore
55    
56    TRUE if the data is to be discarded. This is used to save time when only
57    a subset of the tables need to be loaded: the data for the ignored tables
58    is simply discarded.
59    
60  =back  =back
61    
62  =cut  =cut
63    
64  sub new {  sub new {
65      # Get the parameters.      # Get the parameters.
66      my ($class, $erdb, $relationName, $directory, $loadOnly) = @_;      my ($class, $erdb, $relationName, $directory, $loadOnly, $ignore) = @_;
67      # Validate the directory name.      # Validate the directory name.
68      if (! -d $directory) {      if (! -d $directory) {
69          Confess("Load directory \"$directory\" not found.");          Confess("Load directory \"$directory\" not found.");
# Line 68  Line 74 
74      my $fileHandle;      my $fileHandle;
75      # Determine whether or not this is a primary relation.      # Determine whether or not this is a primary relation.
76      my $primary = ($erdb->_IsPrimary($relationName) ? 1 : 0);      my $primary = ($erdb->_IsPrimary($relationName) ? 1 : 0);
77      # Check to see if this is a load-only or a generate-and-load.      # Check to see if this is a load-only, ignore, or a generate-and-load.
78      if ($loadOnly) {      if ($ignore) {
79            Trace("Relation $relationName will be ignored.") if T(2);
80            $fileHandle = "";
81        } elsif ($loadOnly) {
82          Trace("Relation $relationName will be loaded from $fileName.") if T(2);          Trace("Relation $relationName will be loaded from $fileName.") if T(2);
83          $fileHandle = "";          $fileHandle = "";
84      } else {      } else {
# Line 91  Line 100 
100                    fileSize => 0,                    fileSize => 0,
101                    lineCount => 0,                    lineCount => 0,
102                    stats => Stats->new(),                    stats => Stats->new(),
103                    primary => $primary                    primary => $primary,
104                      ignore => ($ignore ? 1 : 0)
105                   };                   };
106      # Bless and return it.      # Bless and return it.
107      bless $retVal, $class;      bless $retVal, $class;
108      return $retVal;      return $retVal;
109  }  }
110    
111    =head3 Ignore
112    
113    C<< my $flag = $erload->Ignore(); >>
114    
115    Return TRUE if we are ignoring this table, else FALSE.
116    
117    =cut
118    #: Return Type $;
119    sub Ignore {
120        # Get the parameters.
121        my ($self) = @_;
122        # Return the result.
123        return $self->{ignore};
124    }
125    
126  =head3 Put  =head3 Put
127    
128  C<< my  = $erload->Put($field1, $field2, ..., $fieldN); >>  C<< my  = $erload->Put($field1, $field2, ..., $fieldN); >>
# Line 120  Line 145 
145  sub Put {  sub Put {
146      # Get the ERDBLoad instance and the field list.      # Get the ERDBLoad instance and the field list.
147      my ($self, @rawFields) = @_;      my ($self, @rawFields) = @_;
148        # Only proceed if we're not ignoring.
149        if (! $self->{ignore}) {
150      # Insure the field values are okay.      # Insure the field values are okay.
151      my $truncates = $self->{dbh}->VerifyFields($self->{relName}, \@rawFields);      my $truncates = $self->{dbh}->VerifyFields($self->{relName}, \@rawFields);
152      # Run through the list of field values, escaping them.      # Run through the list of field values, escaping them.
# Line 143  Line 170 
170          $self->Add("truncated", $truncates);          $self->Add("truncated", $truncates);
171      }      }
172  }  }
173    }
174    
175  =head3 Add  =head3 Add
176    
# Line 196  Line 224 
224  sub Finish {  sub Finish {
225      # Get this object instance.      # Get this object instance.
226      my ($self) = @_;      my ($self) = @_;
227        if ($self->{fh}) {
228      # Close the load file.      # Close the load file.
229      close $self->{fh};      close $self->{fh};
230        }
231      # Return the statistics object.      # Return the statistics object.
232      return $self->{stats};      return $self->{stats};
233  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3