[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.3, Thu Oct 2 16:32:42 2008 UTC revision 1.4, Thu Oct 9 17:23:54 2008 UTC
# Line 214  Line 214 
214      }      }
215  }  }
216    
217    =head3 PutE
218    
219        $edbl->PutE($table => $id, %fields);
220    
221    Place an entity-based table record in a load file. The first field
222    specified after the table name is the ID.
223    
224    =over 4
225    
226    =item table
227    
228    Name of the relevant table.
229    
230    =item id
231    
232    ID of the relevant entity.
233    
234    =item fields
235    
236    Hash mapping field names to values.
237    
238    =back
239    
240    =cut
241    
242    sub PutE {
243        # Get the parameters.
244        my ($self, $table, $id, %fields) = @_;
245        # Put the record.
246        $self->Put($table, id => $id, %fields);
247        # Record that we've done a putE.
248        $self->Add(putE => 1);
249    }
250    
251    =head3 PutR
252    
253        $edbl->PutR($table => $from, $to, %fields);
254    
255    Place a relationship record in a load file. The first two fields
256    specified after the table name are the from-link and the to-link,
257    respectively.
258    
259    =over 4
260    
261    =item table
262    
263    Name of the relevant relationship.
264    
265    =item from
266    
267    ID of the from-entity.
268    
269    =item to
270    
271    ID of the to-entity.
272    
273    =item fields
274    
275    Hash mapping field names to field values.
276    
277    =back
278    
279    =cut
280    
281    sub PutR {
282        # Get the parameters.
283        my ($self, $table, $from, $to, %fields) = @_;
284        # Put the record.
285        $self->Put($table, 'from-link' => $from, 'to-link' => $to, %fields);
286        # Record that we've done a PutR.
287        $self->Add(putR => 1);
288    }
289    
290    
291  =head3 Add  =head3 Add
292    
293      $edbl->Add($statName => $count);      $edbl->Add($statName => $count);
# Line 243  Line 317 
317      $self->{stats}->Add($statName => $count);      $self->{stats}->Add($statName => $count);
318  }  }
319    
320    =head3 AddWarning
321    
322        $edbl->AddWarning($errorType => $message);
323    
324    Record a warning. Warnings indicate possible errors in the incoming data.
325    The first warning of a specified type is added as a message to the load
326    statistic. All warnings are also traced at level 3.
327    
328    =over 4
329    
330    =item errorType
331    
332    Type of error indicated by the warning. This is used as the label when the
333    warning is counted in the statistics object.
334    
335    =item message
336    
337    Message describing the reason for the warning.
338    
339    =back
340    
341    =cut
342    
343    sub AddWarning {
344        # Get the parameters.
345        my ($self, $errorType, $message) = @_;
346        # Count the warning.
347        my $count = $self->Add($errorType);
348        # Is this the first one of this type?
349        if ($count == 1) {
350            # Yes, add it to the messages for the end.
351            $self->{stats}->AddMessage($errorType);
352        } else {
353            # No, just trace it.
354            Trace("Data warning: $message") if T(3);
355        }
356    }
357    
358  =head3 Track  =head3 Track
359    
360      $edbl->Track($statName => $key, $period);      $edbl->Track($statName => $key, $period);
# Line 388  Line 500 
500              my $loader = $loaderHash->{$table};              my $loader = $loaderHash->{$table};
501              # If it doesn't exist yet, create it.              # If it doesn't exist yet, create it.
502              if (! defined $loader) {              if (! defined $loader) {
503                  $loader = ERDBGenerate->new($db, $self->{directory}, $table);                  $loader = ERDBGenerate->new($db, $self->{directory}, $table, $self->{stats});
504                  # Save it for future use.                  # Save it for future use.
505                  $loaderHash->{$table} = $loader;                  $loaderHash->{$table} = $loader;
506                  # Count it.                  # Count it.
# Line 397  Line 509 
509              $loader->Start($section);              $loader->Start($section);
510          }          }
511          # Generate the data to put in the newly-created load files.          # Generate the data to put in the newly-created load files.
         Trace("Calling generator.") if T(3);  
512          $self->Generate();          $self->Generate();
513      };      };
514      # Did it work?      # Did it work?
# Line 468  Line 579 
579      # Loop through the list of load groups.      # Loop through the list of load groups.
580      for my $group ($erdb->LoadGroupList()) {      for my $group ($erdb->LoadGroupList()) {
581          # Stash the loader's tables in the output hash.          # Stash the loader's tables in the output hash.
582          $retVal->{$group} = GetTables($erdb, $group);          $retVal->{$group} = [ GetTables($erdb, $group) ];
583      }      }
584      # Return the result.      # Return the result.
585      return $retVal;      return $retVal;
# Line 574  Line 685 
685          }          }
686      }      }
687      # Normalize the group names and return them.      # Normalize the group names and return them.
688      return map { ucfirst $_ } @retVal;      @retVal = map { ucfirst $_ } @retVal;
689        Trace("Final group list is " . join(" ", @retVal) . ".") if T(2);
690        return @retVal;
691  }  }
692    
693  =head3 KillFileName  =head3 KillFileName

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3