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

Diff of /Sprout/ERDBGenerate.pm

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

revision 1.2, Thu Oct 9 17:23:54 2008 UTC revision 1.3, Mon Jan 19 21:46:21 2009 UTC
# Line 192  Line 192 
192      my ($self, %putFields) = @_;      my ($self, %putFields) = @_;
193      # We return the number of characters output.      # We return the number of characters output.
194      my $retVal = 0;      my $retVal = 0;
195        # Get the database object.
196        my $erdb = $self->{erdb};
197      # Get the descriptor for this relation.      # Get the descriptor for this relation.
198      my $relationTable = $self->{relation};      my $relationTable = $self->{relation};
199      # Insure we have an output file to which we can write.      # Insure we have an output file to which we can write.
# Line 212  Line 214 
214          my @values;          my @values;
215          # Loop through the relation's fields.          # Loop through the relation's fields.
216          for my $field (@{$relationTable->{Fields}}) {          for my $field (@{$relationTable->{Fields}}) {
217              # Get this field's value.              # Get this field's value. We need to consider the possibility the
218              my $value = $putFields{$field->{name}};              # use used underscores instead of hyphens for convenience, so we
219                # have to check twice.
220                my $name = $field->{name};
221                my $value = $putFields{$name};
222                if (! defined $value) {
223                    my $altName = $name;
224                    $altName =~ tr/-/_/;
225                    $value = $putFields{$altName};
226                }
227                # Did we find a value?
228              if (! defined $value) {              if (! defined $value) {
229                  # The field has no value, so check for a default.                  # The field has no value, so check for a default.
230                  $value = $field->{default};                  $value = $field->{default};
# Line 223  Line 234 
234              }              }
235              # Push the value into the result list.              # Push the value into the result list.
236              push @values, $value;              push @values, $value;
237              Trace("Field $field->{name} in $self->{table} has value \"$value\".") if T(4);              Trace("Field $name in $self->{table} has value \"$value\".") if T(4);
238              # Record its length.              # Record its length.
239              $retVal += length("$value");              $retVal += length("$value");
240          }          }
241          # Fix and verify the field values.          # Verify and fix the field values.
242          my $truncates = $self->{erdb}->VerifyFields($self->{table}, \@values);          $erdb->VerifyFields($self->{table}, \@values);
243          # Record any field truncation events.          $erdb->DigestFields($self->{table}, \@values);
         $self->{stats}->Add(truncations => $truncates) if $truncates;  
244          # Write the record.          # Write the record.
245          Tracer::PutLine($oh, \@values);          Tracer::PutLine($oh, \@values);
246      }      }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3