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

Diff of /Sprout/AttrDBRefresh.pl

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

revision 1.6, Fri Dec 15 03:24:41 2006 UTC revision 1.7, Fri Dec 15 08:15:24 2006 UTC
# Line 58  Line 58 
58  attribute values. All attribute keys mentioned in the file will be erased before  attribute values. All attribute keys mentioned in the file will be erased before
59  loading.  loading.
60    
61    =item loadKey
62    
63    If specified, the name of a tab-delimited file containing attribute key data. For each key,
64    there is a pair of lines. The first line contains the ID, data type, and description
65    of the key. The second line contains the marker C<#GROUPS> followed by zero or more
66    group names. The attribute will be connected to all the specified groups.
67    
68  =item backup  =item backup
69    
70  If specified, the name of a file into which all the attribute data should be  If specified, the name of a file into which all the attribute data should be
71  dumped. The output file will be tab-delimited, with the first column containing  dumped. The file itself will receive the attribute data in the format expected
72  object IDs, the second attribute key names, and the remaining columns the  by C<load>. A second file, consisting of the same file name with the suffix C<.key>,
73  attribute values.  will contain the attribute key data in the format expected by C<loadKey>.
74    
75  =item hh_copy  =item hh_copy
76    
# Line 99  Line 106 
106                                                preserve => ["", "comma-delimited list of attributes to be preserved during migration"],                                                preserve => ["", "comma-delimited list of attributes to be preserved during migration"],
107                                                phone => ["", "phone number (international format) to call when load finishes"],                                                phone => ["", "phone number (international format) to call when load finishes"],
108                                                load => ["", "file from which to load attribute data"],                                                load => ["", "file from which to load attribute data"],
109                                                  loadKey => ["", "file from which to load attribute key data"],
110                                                backup => ["", "file to which attribute data should be dumped"],                                                backup => ["", "file to which attribute data should be dumped"],
111                                                hh_copy => ["", "if specified, the attributes used by the collections system will be converted"]                                                hh_copy => ["", "if specified, the attributes used by the collections system will be converted"]
112                                             },                                             },
# Line 116  Line 124 
124      Trace("Connecting to attribute database.") if T(2);      Trace("Connecting to attribute database.") if T(2);
125      my $ca = CustomAttributes->new();      my $ca = CustomAttributes->new();
126      # Process according to the options selected.      # Process according to the options selected.
127      if ($options->{load} && $options->{backup}) {      if ($options->{backup}) {
128          # Prevent the user from screwing himself by doing a load and a backup          # Back up the attributes to the specified file.
129          # at the same time.          my $backupFileName = $options->{backup};
130          Confess("Please do not specify LOAD and BACKUP at the same time.");          Trace("Backing up attribute data.") if T(2);
131            my $stats = $ca->BackupAllAttributes($backupFileName);
132            Trace("Attribute backup statistics:\n" . $stats->Show()) if T(2);
133            Trace("Backing up key data.") if T(2);
134            $stats = $ca->BackupKeys("$backupFileName.key");
135            Trace("Key backup statistics:\n" . $stats->Show()) if T(2);
136      }      }
137      if ($options->{initializeAndClear}) {      if ($options->{initializeAndClear}) {
138          # Create the tables.          # Create the tables.
# Line 138  Line 151 
151          my $stats = MigrateCollections($ca, $fig);          my $stats = MigrateCollections($ca, $fig);
152          Trace("Collection statistics:\n" . $stats->Show()) if T(2);          Trace("Collection statistics:\n" . $stats->Show()) if T(2);
153      }      }
154        if ($options->{loadKey}) {
155            # We want to load the attribute data from the specified file, but
156            # first we need to verify that the file exists.
157            my $loadFileName = $options->{loadKey};
158            if (! -f $loadFileName) {
159                Confess("Cannot load keys: file \"$loadFileName\" is not found or not a file.");
160            } else {
161                Trace("Loading key data from $loadFileName.") if T(2);
162                my $stats = $ca->RestoreKeys($loadFileName);
163                Trace("Load statistics:\n" . $stats->Show()) if T(2);
164            }
165        }
166      if ($options->{load}) {      if ($options->{load}) {
167          # We want to load the attribute data from the specified file, but          # We want to load the attribute data from the specified file, but
168          # first we need to verify that the file exists.          # first we need to verify that the file exists.
# Line 150  Line 175 
175              Trace("Load statistics:\n" . $stats->Show()) if T(2);              Trace("Load statistics:\n" . $stats->Show()) if T(2);
176          }          }
177      }      }
     if ($options->{backup}) {  
         # Back up the attributes to the specified file.  
         my $backupFileName = $options->{backup};  
         Trace("Backing up attribute database.") if T(2);  
         my $stats = $ca->BackupAllAttributes($backupFileName);  
         Trace("Backup statistics:\n" . $stats->Show()) if T(2);  
     }  
178      Trace("Processing complete.") if T(2);      Trace("Processing complete.") if T(2);
179  };  };
180  if ($@) {  if ($@) {

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3