[Bio] / Sprout / AttrDBRefresh.pl Repository:
ViewVC logotype

View of /Sprout/AttrDBRefresh.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.3 - (download) (as text) (annotate)
Thu Nov 16 19:56:49 2006 UTC (13 years, 4 months ago) by parrello
Branch: MAIN
Changes since 1.2: +2 -0 lines
Added a new FIG_Config parameter that will insure attributes are migrated from the old system to the new system instead of the new system to itself.

#!/usr/bin/perl -w

=head1 AttrDBRefresh

This script refreshes the main entity tables of the Custom Attribute database.

The currently-supported command-line options are as follows.

=over 4

=item user

Name suffix to be used for log files. If omitted, the PID is used.

=item trace

Numeric trace level. A higher trace level causes more messages to appear. The
default trace level is C<3>.

=item sql

If specified, turns on tracing of SQL activity.

=item background

Save the standard and error output to files. The files will be created
in the FIG temporary directory and will be named C<err>I<User>C<.log> and
C<out>I<User>C<.log>, respectively, where I<User> is the value of the
B<user> option above.

=item h

Display this command's parameters and options.

=item phone

Phone number to message when the script is complete.

=item migrate

If specified, then in addition to refreshing the objects, the actual attributes
will be migrated. If this option is specified on a system that is using the new
attribute system, it will have no effect, but it will take a very long time
doing it.

=item noLoad

If specified, then the attributes will be migrated but no refresh will take place.



use strict;
use Tracer;
use DocUtils;
use TestUtils;
use Cwd;
use File::Copy;
use File::Path;
use CustomAttributes;
use FIG;

# Get the command-line options and parameters.
my ($options, @parameters) = StandardSetup([qw(CustomAttributes ERDB ERDBLoad FIG) ],
                                              trace => [3, "trace level"],
                                              noLoad => ["", "if specified, the refresh will be skipped"],
                                              migrate => ["", "if specified, attribute data will be migrated along with the object IDs"],
                                              phone => ["", "phone number (international format) to call when load finishes"],
# Set a variable to contain return type information.
my $rtype;
# Insure we catch errors.
eval {
    # Insure we don't use the new attribute system for accessing the old attributes.
    $FIG_Config::attrOld = 1;
    # Get the FIG object.
    my $fig = FIG->new();
    # First we refresh the IDs. Since this is done inside a block, the custom
    # attributes object we create will be released before we start migrating,
    # which is important.
    if (! $options->{noLoad}) {
        Trace("Connecting to attribute database.") if T(2);
        my $ca = CustomAttributes->new();
        Trace("Refreshing object IDs.") if T(2);
    if ($options->{migrate}) {
        Trace("Migrating attribute data.") if T(2);
    Trace("Processing complete.") if T(2);
if ($@) {
    Trace("Script failed with error: $@") if T(0);
    $rtype = "error";
} else {
    Trace("Script complete.") if T(2);
    $rtype = "no error";
if ($options->{phone}) {
    my $msgID = Tracer::SendSMS($options->{phone}, "RefreshAttrDB terminated with $rtype.");
    if ($msgID) {
        Trace("Phone message sent with ID $msgID.") if T(2);
    } else {
        Trace("Phone message not sent.") if T(2);


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3