2 ################################################################################
5 # Description: Cleans destination PQA Cont database by removing all defects
6 # then Customer and Project stateless records. Useful when
7 # debugging and performing multiple runs of pqamerge.
9 # Author: Andrew@DeFaria.com
10 # Created: Fri Sep 23 17:27:58 PDT 2005
13 # (c) Copyright 2005, Andrew@DeFaria.com, all rights reserved
15 ################################################################################
21 our ($me, $SEPARATOR);
23 my ($abs_path, $lib_path);
26 # Extract relative path and basename from script name.
27 $0 =~ /(.*)[\/\\](.*)/;
29 $abs_path = (!defined $1) ? "." : File::Spec->rel2abs ($1);
30 $me = (!defined $2) ? $0 : $2;
33 # Remove .pl for Perl scripts that have that extension
36 # Define the path SEPARATOR
37 $SEPARATOR = ($^O =~ /MSWin/) ? "\\" : "/";
40 $lib_path = "$abs_path" . $SEPARATOR . ".." . $SEPARATOR . "lib";
42 # Add the appropriate path to our modules to @INC array.
43 unshift (@INC, "$abs_path");
44 unshift (@INC, "$lib_path");
52 my $from_db_connection_name = "2005.02.00";
57 display "ERROR: $msg\n" if defined $msg;
59 display "Usage: $me\t[-u] [-v] [-d] [-from <connection name>]
63 -v: Turn on verbose mod
64 -d: Turn on debug mode
65 -from <connection_name>: Specify the from connaction name
66 (Default $from_db_connection_name)";
71 my $log = Logger->new (path => ".");
74 if ($ARGV [0] eq "-v") {
77 } elsif ($ARGV [0] eq "-d") {
79 } elsif ($ARGV [0] eq "-from") {
82 Usage "Must specify <connection name> after -from";
84 $from_db_connection_name = $ARGV [0];
86 } elsif ($ARGV [0] eq "-u") {
89 Usage "Unknown argument found: " . $ARGV [0];
95 my $process_start_time = time;
96 my $controller = StartSession "Cont", $from_db_connection_name;
97 $log->msg ("Opened Controller (Cont) database from \"$from_db_connection_name\" connection");
102 DeleteRecords $log, $controller, "defect";
103 display_duration $start_time, $log;
106 DeleteRecords $log, $controller, "Customer";
107 display_duration $start_time, $log;
110 DeleteRecords $log, $controller, "Project";
111 display_duration $start_time, $log;
114 DeleteDynamicLists $log, $controller;
115 display_duration $start_time, $log;
117 EndSession $controller;
118 display_duration $process_start_time, $log;