7 =head1 NAME $RCSfile: convertList.pl,v $
9 This script allows you to convert a Clearquest Dynamic List to a stateless
10 table. You must specify what the dynamic list name is, the stateless table name
11 you wish to convert it to and the field name that serves as the key.
13 This script will note duplicate and skip them. It will not remove the dynamic
22 Andrew DeFaria <Andrew@ClearSCM.com>
30 Mon Oct 24 16:19:15 PDT 2011
34 $Date: 2012/12/18 19:44:10 $
40 Usage: convertList.pl -list <list> -table <table> -field <field>
41 [-u|sage] [-v|erbose] [-d|ebug]
42 [-username <username>] [-password <password>]
43 [-database <database>] [-dbset <dbset>]
44 [-module] [-server <server>] [-port <port>]
47 -l|ist: Dynamic list name to convert
48 -t|able: Name of the stateless table to convert the dynamic
50 -field: Name of the field to fill in with the values from
53 -usa|ge: Displays usage
55 -de|bug: Output debug messages
57 -use|rname: Username to open database with (Default: from config file)
58 -p|assword: Password to open database with (Default: from config file)
59 -da|tabase: Database to open (Default: from config file)
60 -db|set: Database Set to use (Default: from config file)
61 -m|odule: Type of Clearquest module to use. Must be one of 'api',
62 'client', or 'rest'. The 'api' module can only be used if
63 Clearquest is installed locally. The 'client' module can
64 only be successful if a corresponding server is running. And
65 the 'rest' module can only be used if a CQ Web server has
66 been set up and configured (Default: rest)
67 -s|erver: For module = client or rest this is the name of the server
68 that will be providing the service
69 -p|ort: For module = client, this is the point on the server to talk
74 Options are keep in the cq.conf file in etc. They specify the default options
75 listed below. Or you can export the option name to the env(1) to override the
76 defaults in cq.conf. Finally you can programmatically set the options when you
77 call new by passing in a %parms hash. To specify the %parms hash key remove the
78 CQ_ portion and lc the rest.
80 =for html <blockquote>
86 The web host to contact with leading http://
90 Name of database to connect to (Default: from config file)
94 User name to connect as (Default: from config file)
98 Password for CQ_USERNAME
102 Database Set name (Default: from config file)
106 Clearquest::Server name to connect to (Default: from config file)
110 Clearquest::Server port to connect to (Default: from config file)
119 use lib "$FindBin::Bin/../lib";
127 my $VERSION = '$Revision: 2.2 $';
128 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
130 my (%opts, $cq, $log, %totals);
135 my $startTime = time;
139 usage => sub { Usage },
140 verbose => sub { set_verbose },
141 debug => sub { set_debug },
156 $log->msg ("$FindBin::Script v$VERSION");
158 Usage 'Must specify -list' unless $opts{list};
159 Usage 'Must specify -table' unless $opts{table};
160 Usage 'Must specify -field' unless $opts{field};
162 # Translate any options to ones that the lib understands
163 $opts{CQ_USERNAME} = delete $opts{username};
164 $opts{CQ_PASSWORD} = delete $opts{password};
165 $opts{CQ_DATABASE} = delete $opts{database};
166 $opts{CQ_DBSET} = delete $opts{dbset};
167 $opts{CQ_SERVER} = delete $opts{server};
168 $opts{CQ_PORT} = delete $opts{port};
169 $opts{CQ_MODULE} = delete $opts{module};
171 $cq = Clearquest->new (%opts);
173 my $connection = $cq->username . '@' . $cq->database . '/' . $cq->dbset;
174 $connection .= ' (Server: ' . $cq->host . ':' . $cq->port . ')'
175 if ref $cq eq 'Clearquest::Client';
177 $log->msg ("Connecting to $connection...", 1);
181 $log->msg (' connected');
183 foreach ($cq->getDynamicList ($opts{list})) {
186 $totals{Processed}++;
188 my $errmsg = $cq->add ($opts{table}, ($opts{field} => $_));
191 if ($errmsg =~ /duplicate entries in the database/ or
192 $errmsg =~ /Record with same displayname exists/) {
193 $totals{Duplicates}++;
202 $totals{Errors} = $log->errors;
204 error 'Errors occured - check ' . $log->fullname . ' for more info'
207 Stats \%totals, $log;
209 display_duration $startTime, $log;