• Home
  • Services
    • Consultancy
    • Custom Software Solutions
    • Systems Adminsitration
    • SCM
      • Clearcase
      • Multisite
      • Clearquest
      • Release Managment
      • CVS
    • Web Applications
    • Customers
  • Publications
    • Clearcase
      • Triggers
      • Open Source Builds
    • Clearquest
      • Clearquest Daemon
      • DB Conversions
    • Systems Admin
      • Unix/Linux
      • Windows
    • Scripting
      • Perl
      • PHP
      • ECRDig
  • About
    • Services
    • Our People
    • Our Philosophy
    • Contact Us
 

ClearSCM Inc.

You are viewing an unstyled version of this page. Either your browser does not support Cascading Style Sheets (CSS) or CSS styling has been disabled.

pqamerge

Perl Module to hold common routines

1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         PQA.pm
5 # Description:  Perl module PQA conversion routines
6 # Author:       Andrew@DeFaria.com
7 # Created:      Thu Oct  6 09:51:38 PDT 2005
8 # Language:     Perl
9 # Modifications:
10 #
11 # (c) Copyright 2005, Andrew@DeFaria.com, all rights reserved
12 #
13 ################################################################################
14 #use strict;
15 use warnings;
16 use CQPerlExt;
17
18 package PQA;
19   use File::Spec;
20
21   require (Exporter);
22   @ISA = qw (Exporter);
23
24   @EXPORT = qw (
25     @old_Prod_defect_fields
26     @old_TO_defect_fields
27     @new_Cont_defect_fields
28     @customer_fields
29     @project_fields
30     %bad_chars
31     AddToFieldChoiceList
32     AddToProject
33     CheckField
34     CheckRecord
35     DeleteDynamicLists
36     DeleteRecords
37     EndSession
38     GetAllDefectRecords
39     GetDefectRecord
40     ProjectExists
41     StartSession
42     TransferAttachments
43     TransferHistory
44     TransferRecords
45   );
46
47   # Forwards
48   sub AddToFieldChoiceList;
49   sub AddToProject;
50   sub CheckField;
51   sub CheckRecord;
52   sub DeleteDynamicLists;
53   sub DeleteRecords;
54   sub EndSession;
55   sub GetAllDefectRecords;
56   sub GetDefectRecord;
57   sub ProjectExists;
58   sub StartSession;
59   sub TransferAttachemnts;
60   sub TransferHistory;
61   sub TransferRecords;
62
63   our ($me, $verbose, $debug);
64   my $abs_path;
65
66   BEGIN {
67     # Check environment variables
68     $verbose    = $ENV {VERBOSE} ? "yes" : "no";
69     $debug      = $ENV {DEBUG}   ? "yes" : "no";
70   } # BEGIN
71
72   use Display;
73   use Logger;
74
75   ## Exported variables ##
76
77   # Field Definitions
78   our @old_Prod_defect_fields = (
79     "ActionNotes",              # SHORT_STRING
80     "AdvancedFeature",          # SHORT_STRING, CONSTANT_LIST
81     "Assigned_Date",            # DATE_TIME
82     "AttachmentBRCM",           # ATTACHMENT_LIST
83     "Audit_Log",                # MULTILINE_STRING
84     "Category",                 # SHORT_STRING, CONSTANT_LIST
85     "Close_Date",               # DATE_TIME
86     "CommitmentLevel",          # SHORT_STRING, CONSTANT_LIST
87     "CommittedDate",            # DATE_TIME
88     "CommittedToProject",       # SHORT_STRING, CONSTANT_LIST
89     "CustomerID",               # SHORT_STRING
90     "DataPendingNote",          # MULTILINE_STRING
91     "DeferredToChip",           # SHORT_STRING
92     "DeferredToProject",        # SHORT_STRING, CONSTANT_LIST
93     "Description",              # MULTILINE_STRING
94     "DoesNotVerifyNote",        # MULTILINE_STRING
95     "Entry_Type",               # SHORT_STRING, CONSTANT_LIST
96     "Est_Time_To_Fix",          # SHORT_STRING
97     "Fixed_In_HW_Version",      # SHORT_STRING
98     "Fixed_In_Project",         # SHORT_STRING, CONSTANT_LIST
99     "Fixed_In_SW_Version",      # SHORT_STRING
100     "GatingItem",               # SHORT_STRING, CONSTANT_LIST
101     "HUT",                      # SHORT_STRING, DYNAMIC_LIST
102     "HUT_Revision",             # SHORT_STRING, CONSTANT_LIST
103     "HUT_Version",              # SHORT_STRING, CONSTANT_LIST
104     "History",                  # JOURNAL
105     "Issue_Classification",     # SHORT_STRING, CONSTANT_LIST
106     "Keywords",                 # MULTILINE_STRING, CONSTANT_LIST
107     "NoteBRCMOnly",             # MULTILINE_STRING
108     "NoteBugReview",            # MULTILINE_STRING
109     "Note_Entry",               # MULTILINE_STRING
110     "Notes_Log",                # MULTILINE_STRING
111     "OEMSubmitterName",         # SHORT_STRING
112     "OS",                       # CONSTANT_LIST
113     "Open_Close_Status",        # SHORT_STRING, CONSTANT_LIST
114     "Owner",                    # REFERENCE
115     "PendingHWSWReleases",      # INT
116     "Priority",                 # SHORT_STRING, CONSTANT_LIST
117     "Project",                  # REFERENCE
118     "Project_Name",             # SHORT_STRING, CONSTANT_LIST
119     "RelatedID",                # MULTILINE_STRING
120     "ReportedBy",               # SHORT_STRING, CONSTANT_LIST
121     "Resolution",               # SHORT_STRING
122     "ResolveNote",              # MULTILINE_STRING
123     "ResolvedBy",               # REFERENCE
124     "Resolved_Date",            # DATE_TIME
125     "SQATestCase",              # SHORT_STRING, CONSTANT_LIST
126     "Service_Pack",             # SHORT_STRING
127     "Severity",                 # SHORT_STRING, CONSTANT_LIST
128     "Software",                 # SHORT_STRING, CONSTANT_LIST
129     "Software_Version",         # SHORT_STRING
130     "Submit_Date",              # DATE_TIME
131     "Submitter",                # REFERENCE
132     "Symptoms",                 # MULTILINE_STRING, CONSTANT_LIST
133     "TCProcedure",              # MULTILINE_STRING
134     "TestBlocking",             # SHORT_STRING, CONSTANT_LIST
135     "TestCaseID",               # INT
136     "TestcaseComment",          # MULTILINE_STRING
137     "TimeFromSubmitToVerify",   # SHORT_STRING
138     "TimeSubmitToResolve",      # SHORT_STRING
139     "TimeSubmitToResolve",      # SHORT_STRING
140     "TimeToVerify",             # SHORT_STRING
141     "Title",                    # SHORT_STRING
142     "VerifiedBy",               # REFERENCE
143     "VerifyNote",               # MULTILINE_STRING
144     "Verified_Date",            # DATE_TIME
145     "Verified_In_HW_Version",   # SHORT_STRING
146     "Verified_In_SW_Version",   # SHORT_STRING
147     "Visibility",               # SHORT_STRING, CONSTANT_LIST
148     "VisibleTo3com",            # INT
149     "VisibleToAltima",          # INT
150     "VisibleToCompaq",          # INT
151     "VisibleToDell",            # INT
152     "customer",                 # REFERENCE
153     "customer_severity",        # SHORT_STRING, CONSTANT_LIST
154     "old_id",                   # SHORT_STRING, CONSTANT_LIST
155   );
156
157   # This decribes the fields in the old TO defect record
158   our @old_TO_defect_fields = (
159     "ActionNotes",              # SHORT_STRING
160     "AdvancedFeature",          # SHORT_STRING, DYNAMIC_LIST
161     "Assigned_Date",            # DATE_TIME
162     "AttachmentsBRCM",          # ATTACHMENT_LIST
163     "Audit_Log",                # MULTILINE_STRING
164     "Category",                 # SHORT_STRING, CONSTANT_LIST
165     "Close_Date",               # DATE_TIME
166     "CommitmentLevel",          # SHORT_STRING, CONSTANT_LIST
167     "CommittedDate",            # DATE_TIME
168     "CommittedToProject",       # SHORT_STRING, DYNAMIC_LIST
169     "CustomerID",               # SHORT_STRING
170     "DataPendingNote",          # MULTILINE_STRING
171     "DeferredToChip",           # SHORT_STRING
172     "DeferredToProject",        # SHORT_STRING, DYNAMIC_LIST
173     "Description",              # MULTILINE_STRING
174     "DoesNotVerifyNote",        # MULTILINE_STRING
175     "Entry_Type",               # SHORT_STRING, CONSTANT_LIST
176     "Est_Time_To_Fix",          # SHORT_STRING
177     "Fixed_In_HW_Version",      # SHORT_STRING
178     "Fixed_In_Project",         # SHORT_STRING, DYNAMIC_LIST
179     "Fixed_In_SW_Version",      # SHORT_STRING
180     "Found_In_Project",         # SHORT_STRING, DYNAMIC_LIST
181     "GatingItem",               # SHORT_STRING, CONSTANT_LIST
182     "HUT",                      # SHORT_STRING, DYNAMIC_LIST
183     "HUT_Revision",             # SHORT_STRING, DYNAMIC_LIST
184     "HUT_Version",              # SHORT_STRING, DYNAMIC_LIST
185     "Headline",                 # SHORT_STRING
186     "History",                  # JOURNAL
187     "Issue_Classification",     # SHORT_STRING, CONSTANT_LIST
188     "Keywords",                 # MULTILINE_STRING, CONSTANT_LIST
189     "NoteBRCMOnly",             # MULTILINE_STRING
190     "NoteBugReview",            # MULTILINE_STRING
191     "Note_Entry",               # MULTILINE_STRING
192     "Notes_Log",                # MULTILINE_STRING
193     "OEMSubmitterName",         # SHORT_STRING
194     "OS",                       # SHORT_STRING, DYNAMIC_LIST
195     "Open_Close_Status",        # SHORT_STRING, CONSTANT_LIST
196     "Owner",                    # REFERENCE
197     "PendingHWSWReleases",      # INT
198     "Priority",                 # SHORT_STRING, CONSTANT_LIST
199     "Project",                  # REFERENCE
200     "ReportedBy",               # REFERENCE
201     "Resolution",               # SHORT_STRING, CONSTANT_LIST
202     "ResolveNote",              # MULTILINE_STRING
203     "ResolvedBy",               # REFERENCE
204     "Resolved_Date",            # DATE_TIME
205     "SQATestCase",              # SHORT_STRING, CONSTANT_LIST
206     "Service_Pack",             # SHORT_STRING, DYNAMIC_LIST
207     "Severity",                 # SHORT_STRING, CONSTANT_LIST
208     "Software",                 # SHORT_STRING, DYNAMIC_LIST
209     "Software_Version",         # SHORT_STRING
210     "Submit_Date",              # DATE_TIME
211     "Submitter",                # REFERENCE
212     "Symptoms",                 # MULTILINE_STRING, CONSTANT_LIST
213     "TCProcedure",              # MULTILINE_STRING
214     "TestBlocking",             # SHORT_STRING, CONSTANT_LIST
215     "TestCaseID",               # INT
216     "TestcaseComment",          # MULTILINE_STRING
217     "TimeFromSubmitToVerify",   # SHORT_STRING
218     "TimeSubmitToResolve",      # SHORT_STRING
219     "TimeToVerify",             # SHORT_STRING
220     "Title_2",                  # SHORT_STRING
221     "VerifiedBy",               # REFERENCE
222     "Verified_Date",            # DATE_TIME
223     "Verified_In_HW_Version",   # SHORT_STRING
224     "Verified_In_SW_Version",   # SHORT_STRING
225     "VerifyNote",               # MULTILINE_STRING
226     "Visibility",               # SHORT_STRING, DYNAMIC_LIST
227     "customer",                 # REFERENCE_LIST
228     "customer_severity",        # SHORT_STRING, CONSTANT_LIST
229     "old_id",                   # SHORT_STRING
230   );
231
232   # This describes the fields in the new Cont Defect record
233   our @new_Cont_defect_fields = (
234     "ActionNotes",              # SHORT_STRING
235 # Prod: , TO:  -> Cont: Active_Deferred_Status
236     "Active_Deferred_Status",   # SHORT_STRING, CONSTANT_LIST
237     "Advanced_Feature",         # SHORT_STRING, DYNAMIC_LIST
238     "Assigned_Date",            # DATE_TIME
239     "AttachmentsBRCM",          # ATTACHMENT_LIST
240     "Audit_Log",                # MULTILINE_STRING
241     "Board_Revision",           # SHORT_STRING, DYNAMIC_LIST
242 # Prod: NoteBRCMOnly, TO: NoteBRCMOnly -> Cont: Broadcom_Only_Note
243     "Broadcom_Only_Note",       # MULTILINE_STRING
244 # Prod: NoteBugReview, TO: NoteBugReview -> Cont: Bug_Review_Note
245     "Bug_Review_Note",          # MULTILINE_STRING
246     "Category",                 # SHORT_STRING, CONSTANT_LIST
247     "Close_Date",               # DATE_TIME
248     "CommitmentLevel",          # SHORT_STRING, CONSTANT_LIST
249     "CommittedDate",            # DATE_TIME
250     "CommittedToProject",       # SHORT_STRING, DYNAMIC_LIST
251     "CustomerID",               # SHORT_STRING
252     "DataPendingNote",          # MULTILINE_STRING
253     "DeferredToChip",           # SHORT_STRING
254     "DeferredToProject",        # SHORT_STRING, DYNAMIC_LIST
255     "Description",              # MULTILINE_STRING
256     "DoesNotVerifyNote",        # MULTILINE_STRING
257     "Entry_Type",               # SHORT_STRING, CONSTANT_LIST
258     "Est_Time_To_Fix",          # SHORT_STRING
259     "Fixed_In_HW_Version",      # SHORT_STRING
260     "Fixed_In_Project",         # SHORT_STRING, DYNAMIC_LIST
261     "Fixed_In_SW_Version",      # SHORT_STRING
262 # Prod: Project (REFERENCE), TO: Project (REFERENCE) -> Cont: Found_In_Project (REFERENCE)
263     "Found_In_Project",         # REFERENCE
264 # Prod: , TO:  -> Cont: Found_On_Gold
265     "Found_On_Gold",            # SHORT_STRING, CONSTANT_LIST
266     "Gating_Item_HW",           # SHORT_STRING, CONSTANT_LIST
267 # Prod: GatingItem, TO: GatingItem -> Cont: Gating_Item_SW, Gating_Item_HW
268     "Gating_Item_SW",           # SHORT_STRING, CONSTANT_LIST
269     "HUT",                      # SHORT_STRING, DYNAMIC_LIST
270     "HUT_Revision",             # SHORT_STRING, DYNAMIC_LIST
271 # Prod: Title, TO: Headline -> Cont: Headline
272     "Headline",                 # SHORT_STRING
273     "Issue_Classification",     # SHORT_STRING, CONSTANT_LIST
274     "Keywords",                 # MULTILINE_STRING, CONSTANT_LIST
275 # Prod: , TO:  -> Cont: Newly_Introduce
276     "Newly_Introduce",          # SHORT_STRING, CONSTANT_LIST
277     "Note_Entry",               # MULTILINE_STRING
278     "Notes_Log",                # MULTILINE_STRING
279     "OEMSubmitterName",         # SHORT_STRING
280     "OS",                       # SHORT_STRING, DYNAMIC_LIST
281 # Prod: , TO:  -> Cont: Other_HUT
282     "Other_HUT",                # MULTILINE_STRING
283     "Owner",                    # REFERENCE
284 # Prod: , TO:  -> Cont: PQATestCase
285     "PQATestCase",              # SHORT_STRING, CONSTANT_LIST
286     "Priority",                 # SHORT_STRING, CONSTANT_LIST
287 # Prod: ReportedBy, TO: ReportedBy -> Cont: Reported_By
288     "Reported_By",              # REFERENCE
289     "Resolution",               # SHORT_STRING, CONSTANT_LIST
290     "ResolveNote",              # MULTILINE_STRING
291     "ResolvedBy",               # REFERENCE
292     "Resolved_Date",            # DATE_TIME
293 # Prod: , TO:  -> Cont: Root_Caused
294     "Root_Caused",              # SHORT_STRING, CONSTANT_LIST
295 # Prod: , TO:  -> Cont: Root_Caused_Note
296     "Root_Caused_Note",         # MULTILINE_STRING
297     "Service_Pack",             # SHORT_STRING, DYNAMIC_LIST
298     "Severity",                 # SHORT_STRING, CONSTANT_LIST
299     "Software",                 # SHORT_STRING, DYNAMIC_LIST
300     "Software_Version",         # SHORT_STRING
301     "Submit_Date",              # DATE_TIME
302     "Submitter",                # REFERENCE
303     "Symptoms",                 # MULTILINE_STRING, CONSTANT_LIST
304     "TCProcedure",              # MULTILINE_STRING
305     "TestCaseID",               # INT
306     "TestcaseComment",          # MULTILINE_STRING
307     "TimeFromSubmitToVerify",   # SHORT_STRING
308     "TimeSubmitToResolve",      # SHORT_STRING
309     "TimeToVerify",             # SHORT_STRING
310 # Prod: Title_2, TO: Title_2 -> Cont: Title
311     "Title",                    # SHORT_STRING
312     "VerifiedBy",               # REFERENCE
313     "Verified_Date",            # DATE_TIME
314     "Verified_In_HW_Version",   # SHORT_STRING
315     "Verified_In_SW_Version",   # SHORT_STRING
316     "VerifyNote",               # MULTILINE_STRING
317 # Prod: , TO:  -> Cont: 
318     "Visibility",               # SHORT_STRING, DYNAMIC_LIST
319 # Prod: , TO:  -> Cont: WorkAroundNote
320     "WorkAroundNote",           # MULTILINE_STRING
321     "customer",                 # REFERENCE_LIST
322     "customer_severity",        # SHORT_STRING, CONSTANT_LIST
323     "old_id",                   # SHORT_STRING
324 # Prod: , TO: Found_In_Project -> Cont: 
325 #   "Found_In_Project",         # SHORT_STRING, DYNAMIC_LIST
326 # Deleted fields:
327 #     "HUT_Version",            # SHORT_STRING, DYNAMIC_LIST
328 #     "Open_Close_Status",      # SHORT_STRING, CONSTANT_LIST
329 #     "PendingHWSWReleases",    # INT
330 #     "SQATestCase",            # SHORT_STRING, CONSTANT_LIST
331 #     "TestBlocking",           # SHORT_STRING, CONSTANT_LIST
332   );
333
334   # Customer and Project records appear in both instances of the old
335   # databases as well as the new Cont database and have not changed.
336   our @customer_fields = (
337     "Name",                     # SHORT_STRING
338     "Phone",                    # SHORT_STRING
339     "Fax",                      # SHORT_STRING
340     "Email",                    # SHORT_STRING
341     "CallTrackingID",           # SHORT_STRING
342     "Description",              # MULTILINE_STRING
343     "Company",                  # SHORT_STRING
344     "Attachment",               # ATTACHMENT_LIST
345   );
346
347   our @project_fields = (
348     "Name",                     # SHORT_STRING
349     "Description",              # MULTILINE_STRING
350   );
351
352   # Collect bad characters
353   our %bad_chars;
354
355   ## Internal variables ##
356   my $login     = "";
357   my $password  = "";
358   my $db_name;
359
360   my $id;
361
362   my $nbr_chars = 40;
363   my $half      = $nbr_chars / 2;
364
365   # Derived from http://hotwired.lycos.com/webmonkey/reference/special_characters/
366   my %char_map = (
367     128 => "€",
368     129 => "",
369     130 => "‚",
370     131 => "ƒ",
371     132 => "„",
372     133 => "…",
373     134 => "†",
374     135 => "‡",
375     136 => "ˆ",
376     137 => "‰",
377     138 => "Š",
378     139 => "‹",
379     140 => "Œ",
380     141 => "",
381     142 => "Ž",
382     143 => "",
383     144 => "",
384     145 => "'",         # Signal "smart quote" left
385     146 => "'",         # Signal "smart quote" right
386     147 => "\"",        # Double "smart quote" left
387     148 => "\"",        # Double "smart quote" right
388     149 => "•",
389     150 => "–",   # En dash
390     151 => "—",   # Em dash
391     152 => "˜",
392     153 => "™",
393     154 => "š",
394     155 => "›",
395     156 => "œ",
396     157 => "",
397     158 => "ž",
398     159 => "Ÿ",
399     160 => " ",    # Nonbreaking space
400     161 => "¡",   # Inverted exclamation (¡)
401     162 => "¢",    # Cent sign (¢)
402     163 => "£",   # Pound sterling (£)
403     164 => "¤",  # General currency sign (¤)
404     165 => "¥",     # Yen sign (¥)
405     166 => "&brkbar;",  # Broken vertical bar (¦)
406     167 => "§",    # Section sign (§)
407     168 => "¨",     # Umlaut (¨)
408     169 => "©",    # Copyright (©)
409     170 => "ª",    # Feminine ordinal (ª)
410     171 => "«",   # Left angle quote («)
411     172 => "¬",     # Not sign (¬)
412     173 => "­",     # Soft hyphen
413     174 => "®",     # Registered trademark (®)
414     175 => "¯",    # Macron accent (¯)
415     176 => "°",     # Degree sign (°)
416     177 => "±",  # Plus or minus (±)
417     178 => "²",    # Superscript two (²)
418     179 => "³",    # Superscript three (³)
419     180 => "´",   # Acute accent (´)
420     181 => "µ",   # Micro sign (µ)
421     182 => "¶",    # Paragraph sign (¶)
422     183 => "·",  # Middle dot (·)
423     184 => "¸",   # Cedilla (¸)
424     185 => "¹",    # Superscript one (¹)
425     186 => "º",    # Masculine ordinal (º)
426     187 => "»",   # Right angle quote (»)
427     188 => "¼",  # One-forth (¼)
428     189 => "½",  # One-half (½)
429     190 => "&frac24;",  # Three-fourths (¾)
430     191 => "¿",  # Inverted question mark (¿)
431     192 => "À",  # Uppercase A, grave accent (À)
432     193 => "Á",  # Uppercase A, acute accent (Á)
433     194 => "Â",   # Uppercase A, circumflex accent (Â)
434     195 => "Ã",  # Uppercase A, tilde (Ã)
435     196 => "Ä",    # Uppercase A, umlaut (Ä)
436     197 => "Å",   # Uppercase A, ring (Å)
437     198 => "Æ",   # Uppercase AE (Æ)
438     199 => "Ç",  # Uppercase C, cedilla (Ç)
439     200 => "È",  # Uppercase E, grave accent (È)
440     201 => "É",  # Uppercase E, acute accent (É)
441     202 => "Ê",   # Uppercase E, circumflex accent (Ê)
442     203 => "Ë",    # Uppercase E, umlaut (Ë)
443     204 => "Ì",  # Uppercase I, grave accent (Ì)
444     205 => "Í",  # Uppercase I, acute accent (Í)
445     206 => "Î",   # Uppercase I, circumflex accent (Î)
446     207 => "Ï",    # Uppercase I, umlaut (Ï)
447     208 => "Ð",     # Uppercase Eth, Icelandic (Ð)
448     209 => "Ñ",  # Uppercase N, tilde (Ñ)
449     210 => "Ò",  # Uppercase O, grave accent (Ò)
450     211 => "Ó",  # Uppercase O, acute accent (Ó)
451     212 => "Ô",   # Uppercase O, circumflex accent (Ô)
452     213 => "Õ",  # Uppercase O, tilde (Õ)
453     214 => "Ö",    # Uppercase O, umlaut (Ö)
454     215 => "×",   # Muliplication sign (×)
455     216 => "Ø",  # Uppercase O, slash (Ø)
456     217 => "Ù",  # Uppercase U, grave accent (Ù)
457     218 => "Ú",  # Uppercase U, acute accent (Ú)
458     219 => "Û",   # Uppercase U, circumflex accent (Û)
459     220 => "Ü",    # Uppercase U, umlaut (Ü)
460     221 => "Ý",  # Uppercase Y, acute accent (Ý)
461     222 => "Þ",   # Uppercase THORN, Icelandic (Þ)
462     223 => "ß",   # Lowercase sharps, German (ß)
463     224 => "à",  # Lowercase a, grave accent (à)
464     225 => "á",  # Lowercase a, acute accent (á)
465     226 => "â",   # Lowercase a, circumflex acirc (â)
466     227 => "ã",  # Lowercase a, tilde (ã)
467     228 => "ä",    # Lowercase a, umlaut (ä)
468     229 => "å",   # Lowercase a, ring (å)
469     230 => "æ",   # Lowercase ae (æ)
470     231 => "ç",  # Lowercase c, cedilla (ç)
471     232 => "è",  # Lowercase e, grave accent (è)
472     233 => "é",  # Lowercase e, acute accent (é)
473     234 => "ê",   # Lowercase e, circumflex accent (ê)
474     235 => "ë",    # Lowercase e, umlaut (ë)
475     236 => "ì",  # Lowercase i, grave accent (ì)
476     237 => "í",  # Lowercase i, acute accent (í)
477     238 => "î",   # Lowercase i, circumflex accent (î)
478     239 => "ï",    # Lowercase i, umlaut (ï)
479     240 => "ð",     # Lowercase eth, Icelandic (ð)
480     241 => "ñ",  # Lowercase n, tilde (ñ)
481     242 => "ò",  # Lowercase o, grave accent (ò)
482     243 => "ó",  # Lowercase o, acute accent (ó)
483     244 => "ô",   # Lowercase o, circumflex accent (ô)
484     245 => "õ",  # Lowercase o, tilde (õ)
485     246 => "ö",    # Lowercase o, umlaut (ö)
486     247 => "÷",  # Division sign (÷)
487     248 => "ø",  # Lowercase o, slash (ø)
488     249 => "ù",  # Lowercase u, grave accent (ù)
489     250 => "ú",  # Lowercase u, acute accent (ú)
490     251 => "û",   # Lowercase u, circumflex accent (û)
491     252 => "ü",    # Lowercase u, umlaut (ü)
492     253 => "ý",  # Lowercase y, acute accent (ý)
493     254 => "þ",   # Lowercase thorn, Icelandic (þ)
494     255 => "ÿ",    # Lowercase y, umlaut (ÿ)
495   );
496
497   ## Exported functions ##
498   # Add a value to a field's dynamic list
499   sub AddToFieldChoiceList {
500     my $session         = shift;
501     my $entity          = shift;
502     my $dynamic_list    = shift;
503     my $name            = shift;
504     my $value           = shift;
505
506     return if $value eq "";
507
508     # It seems that adding the entry to the dynamic list is not enough.
509     # I believe that Clearquest caches entries on a dynamic list so we
510     # need to tell Clearquest about this new entry.
511     my $add_value  = 1;
512     my @values = @{$entity->GetFieldChoiceList ($name)};
513
514     # Ack! Seems now we have values like Service_Pack = "1.A" and
515     # Service_Pack = "1.a", which translate to the same value as far
516     # as a dynamic list is concerned, so we'll do the comparison
517     # ignoring case... Additionally there can be regex meta characters
518     # in the value so we'll need to protect from that.
519     foreach (@values) {
520       if ("\L$value\E" eq "\L$_\E") {
521         $add_value = 0;
522         last;
523       } # if
524     } # foreach
525
526     if ($add_value) {
527       push @values, $value;
528
529       $entity->SetFieldChoiceList ($name, \@values);
530     } # if
531
532     # Get the current values, if any
533     @values = @{$session->GetListMembers ($dynamic_list)};
534
535     # Search to see if the item is already on the list
536     foreach (@values) {
537       return if ("\L$value\E" eq "\L$_\E");
538     } # if
539
540     $session->AddListMember ($dynamic_list, $value);
541
542     push @values, $value;
543
544     $session->SetListMembers ($dynamic_list, \@values);
545   } # AddToDynamicList
546
547   # TO: defect: Found_In_Project is currently a dynamic list but is
548   # going to Cont: defect: Found_In_Project which is a reference to
549   # Cont: Project. So we need to dynamically add those.
550   sub AddToProject {
551     my $log     = shift;
552     my $to      = shift;
553     my $project = shift;
554
555     if (ProjectExists $to, $project) {
556       return;
557     } # if
558
559     my $entity = $to->BuildEntity ("Project");
560
561     $entity->SetFieldValue ("name", $project);
562
563     # Call the Validate method
564     my $errmsg = $entity->Validate;
565
566     $log->err ("Unable to validate Project record: $project:\n$errmsg", 1) if $errmsg ne "";
567
568     # Post record to database
569     $entity->Commit if $errmsg eq "";
570   } # AddToProject
571
572   sub CheckField {
573     my $log             = shift;
574     my $db_name         = shift;
575     my $record_name     = shift;
576     my $id              = shift;
577     my $field_name      = shift;
578     my $str             = shift;
579
580     return $str if length $str eq 0; # Ignore empty strings
581
582     if ($str =~ /[^\t\n\r -\177]/) {
583       for (my $x = 0; $x < length $str; $x++) {
584         my $y = substr $str, $x, 1;
585         if ($y =~ /[^\t\n\r -\177]/) {
586           my $o = ord ($y);
587           display "At char #$x found \"$y\" ($o)";
588           my $s = substr $str, $x - 20, 40;
589           display "\"$s\"";
590         } # if
591       } # for
592       error "$field_name match", 1;
593     } # if
594
595     for (my $i = 0; $i < length $str; $i++) {
596       my $ord = ord (substr $str, $i, 1);
597
598       if ($ord < 0 or $ord > 127) {
599         # $id is undefined at this point...
600         $log->msg ("$db_name:$record_name:$id:$field_name:$i");
601         $log->msg ("Old Contents:\n$str");
602         $str = FixChar ($str, $i);
603         $log->msg ("New Contents:\n$str");
604       } # if
605     } # foreach
606
607     return $str;
608   } # CheckField
609
610   sub CheckRecord {
611     my $log             = shift;
612     my $session         = shift;
613     my $id_name         = shift;
614     my $record_name     = shift;
615     my $id              = shift;
616     my @fields          = @_;
617
618     my $result;
619
620     if (defined $id) {
621       $result = GetDefectRecord $log, $session, $record_name, $id;
622     } else {
623       $result = GetAllDefectRecords $log, $session, $record_name;
624     } # if
625
626     while ($result->MoveNext == $CQPerlExt::CQ_SUCCESS) {
627       # GetEntity by using $id
628       $id               = $result->GetColumnValue (1);
629       my $entity        = $session->GetEntity ($record_name, $id);
630
631       $log->msg ($id);
632
633       foreach (@fields) {
634         my $name        = $_;
635         my $value       = $entity->GetFieldValue ($name)->GetValue;
636
637         $value = CheckField $log, $db_name, $record_name, $id, $name, $value;
638       } # for
639     } # for
640   } # CheckRecord
641
642   sub DeleteDynamicLists {
643     my $log             = shift;
644     my $from            = shift;
645
646     my @dynamic_lists = (
647       "Advanced_Feature",
648       "Board_Revision",
649       "HUT",
650       "HUT_Revision",
651     &nb