| 6887 |
dpurdie |
1 |
########################################################################
|
|
|
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
|
|
3 |
#
|
|
|
4 |
# Module name : rmMerge_suckRelease.pl
|
|
|
5 |
# Module type : JATS Utility
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : Extact package-version data from RM
|
|
|
10 |
#
|
|
|
11 |
# Usage : See POD at the end of this file
|
|
|
12 |
#
|
|
|
13 |
#......................................................................#
|
|
|
14 |
|
|
|
15 |
require 5.008_002;
|
|
|
16 |
use strict;
|
|
|
17 |
use warnings;
|
|
|
18 |
|
|
|
19 |
use Pod::Usage;
|
|
|
20 |
use Getopt::Long;
|
|
|
21 |
|
|
|
22 |
use JatsError;
|
|
|
23 |
use JatsRmApi;
|
|
|
24 |
use JatsSystem;
|
|
|
25 |
use FileUtils;
|
|
|
26 |
use ConfigurationFile;
|
|
|
27 |
use File::Copy;
|
|
|
28 |
use DBI;
|
|
|
29 |
my $RM_DB;
|
|
|
30 |
my $VERSION = "1.0";
|
|
|
31 |
my $newRMCred = ['NEW', 'jdbc:oracle:thin:@auawsards002:1521:RELEASEM', 'RM_READONLY', 'Tp8WmmDKMq2Z'];
|
|
|
32 |
|
|
|
33 |
my $opt_reuse=1;
|
|
|
34 |
my $opt_help=0;
|
|
|
35 |
my $opt_verbose=0;
|
|
|
36 |
my $opt_debug=0;
|
|
|
37 |
my $opt_outfile;
|
|
|
38 |
my $opt_rtagId;
|
|
|
39 |
|
|
|
40 |
our %rmData;
|
|
|
41 |
my @keyFields = qw(PV_ID RTAG_ID PROJ_ID PKG_ID CREATOR_ID RELEASOR_ID PARENT_RTAG_ID OFFICIAL_ID BASE_VIEW_ID INSERTOR_ID RCON_ID BM_CON_ID ROOT_PV_ID VTREE_ID SDKTAG_ID GBE_ID BMCON_ID);
|
|
|
42 |
|
|
|
43 |
my %keyFields = map {$_ => 1} @keyFields;
|
|
|
44 |
my %keyFieldsData;
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
#-------------------------------------------------------------------------------
|
|
|
48 |
# Function : Mainline Entry Point
|
|
|
49 |
#
|
|
|
50 |
# Description :
|
|
|
51 |
#
|
|
|
52 |
# Inputs :
|
|
|
53 |
#
|
|
|
54 |
my $result = GetOptions (
|
|
|
55 |
"help:+" => \$opt_help,
|
|
|
56 |
"manual:3" => \$opt_help,
|
|
|
57 |
"verbose:+" => \$opt_verbose,
|
|
|
58 |
"debug:+" => \$opt_debug,
|
|
|
59 |
"reuse!" => \$opt_reuse,
|
|
|
60 |
"outfile:s" => \$opt_outfile,
|
|
|
61 |
"rtagid:i" => \$opt_rtagId,
|
|
|
62 |
);
|
|
|
63 |
|
|
|
64 |
#
|
|
|
65 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
66 |
#
|
|
|
67 |
|
|
|
68 |
#
|
|
|
69 |
# Process help and manual options
|
|
|
70 |
#
|
|
|
71 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
72 |
pod2usage(-verbose => 1) if ( $opt_help == 2 );
|
|
|
73 |
pod2usage(-verbose => 2) if ( $opt_help > 2 );
|
|
|
74 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV >= 0 );
|
|
|
75 |
|
|
|
76 |
#
|
|
|
77 |
# Configure the error reporting rmMerge_process now that we have the user options
|
|
|
78 |
#
|
|
|
79 |
ErrorConfig( 'name' =>'SUCKRELEASE',
|
|
|
80 |
'verbose' => $opt_verbose,
|
|
|
81 |
'debug' => $opt_debug,
|
|
|
82 |
);
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
# Generate the output filename
|
|
|
86 |
#
|
|
|
87 |
$opt_outfile = join('.', $opt_rtagId, 'releaseinfo', 'txt') unless ($opt_outfile);
|
|
|
88 |
my $localDataStore = $opt_outfile;
|
|
|
89 |
|
|
|
90 |
$ENV{GBE_RM_LOCATION} = $newRMCred->[1];
|
|
|
91 |
$ENV{GBE_RM_USERNAME} = $newRMCred->[2];
|
|
|
92 |
$ENV{GBE_RM_PASSWORD} = $newRMCred->[3];
|
|
|
93 |
connectRM(\$RM_DB) unless ( $RM_DB );
|
|
|
94 |
|
|
|
95 |
unless (GetRelease( $opt_rtagId)){
|
|
|
96 |
Error ("Release not found for rtag_id: $opt_rtagId");
|
|
|
97 |
}
|
|
|
98 |
Message("Extacting: $opt_rtagId to $opt_outfile");
|
|
|
99 |
|
|
|
100 |
#
|
|
|
101 |
# Insert some basic information
|
|
|
102 |
#
|
|
|
103 |
$rmData{METADATA}{RTAG_ID} = $opt_rtagId;
|
|
|
104 |
|
|
|
105 |
GetTableData('RELEASE_TAGS');
|
|
|
106 |
GetTableData('RELEASE_CONTENT');
|
|
|
107 |
GetTableData('PEGGED_VERSIONS');
|
|
|
108 |
GetTableData('ADVISORY_RIPPLE');
|
|
|
109 |
GetTableData('RELEASE_CONFIG');
|
|
|
110 |
|
|
|
111 |
#
|
|
|
112 |
# Have the basic data - don't know about blobs !!!!
|
|
|
113 |
# Need to extract, as text, those fields that are used for linkage purposes
|
|
|
114 |
# PV_IDs, PKG_IDS
|
|
|
115 |
#
|
|
|
116 |
GetXrefsUsers(qw(CREATOR_ID RELEASOR_ID OFFICIAL_ID INSERTOR_ID ));
|
|
|
117 |
GetXrefsPvid(qw(PV_ID ROOT_PV_ID));
|
|
|
118 |
#GetXrefsPkg(qw(PKG_ID));
|
|
|
119 |
GetXrefsRtagId(qw( RTAG_ID PARENT_RTAG_ID ));
|
|
|
120 |
GetXrefsProjId(qw( PROJ_ID ));
|
|
|
121 |
GetXrefsBaseViewId(qw( BASE_VIEW_ID ));
|
|
|
122 |
GetXrefsGbeId(qw(GBE_ID ));
|
|
|
123 |
|
|
|
124 |
GetXrefsIgnore(qw( RCON_ID BMCON_ID )); # Primary keys - ignore
|
|
|
125 |
GetXrefsIgnore(qw( VTREE_ID SDKTAG_ID)); # Assume these have not changed
|
|
|
126 |
|
|
|
127 |
disconnectRM(\$RM_DB);
|
|
|
128 |
ErrorDoExit();
|
|
|
129 |
saveLocalData();
|
|
|
130 |
|
|
|
131 |
my @unProcessed;
|
|
|
132 |
foreach my $tableName (keys %keyFieldsData) {
|
|
|
133 |
foreach my $name ( keys %{$keyFieldsData{$tableName}}) {
|
|
|
134 |
foreach my $key ( keys %{$keyFieldsData{$tableName}{$name}}) {
|
|
|
135 |
push @unProcessed, "$tableName, $name, $key";
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
if (@unProcessed) {
|
|
|
141 |
Error("Some the key fields have not been rmMerge_processed", @unProcessed )
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
exit 0;
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
#-------------------------------------------------------------------------------
|
|
|
148 |
# Function : GetXrefsCommon
|
|
|
149 |
#
|
|
|
150 |
# Description : Common code for getting cross reference data
|
|
|
151 |
#
|
|
|
152 |
# Inputs : $refFields - Ref to fields to rmMerge_process
|
|
|
153 |
# $tag - Tag base name
|
|
|
154 |
# $sql - Sql fragment
|
|
|
155 |
#
|
|
|
156 |
# Returns :
|
|
|
157 |
#
|
|
|
158 |
sub GetXrefsCommon
|
|
|
159 |
{
|
|
|
160 |
my ($refFields, $tag, $sql) = @_;
|
|
|
161 |
my %idList;
|
|
|
162 |
|
|
|
163 |
foreach my $name (@$refFields) {
|
|
|
164 |
$rmData{XREF_MAP}{$name} = $tag;
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
foreach my $tableName (keys %keyFieldsData) {
|
|
|
168 |
foreach my $name (@$refFields) {
|
|
|
169 |
foreach my $key ( keys %{$keyFieldsData{$tableName}{$name}}) {
|
|
|
170 |
$idList{ $key} = 1;
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
return unless %idList;
|
|
|
175 |
|
|
|
176 |
#
|
|
|
177 |
# Get all the table data
|
|
|
178 |
#
|
|
|
179 |
my %xRef;
|
|
|
180 |
my $m_sqlstr = $sql . " in (". join(',',keys %idList) .")";
|
|
|
181 |
my $data = getDataFromRm('GetXrefsCommon:'. $tag, $m_sqlstr, {dump => 0} );
|
|
|
182 |
|
|
|
183 |
#
|
|
|
184 |
# Post rmMerge_process the data
|
|
|
185 |
#
|
|
|
186 |
foreach my $row ( @{$data} ){
|
|
|
187 |
$xRef{$row->[0]} = $row->[1];
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
#
|
|
|
191 |
# Create data structures
|
|
|
192 |
#
|
|
|
193 |
foreach my $tableName (keys %keyFieldsData) {
|
|
|
194 |
my $tName = $tableName . "_XREF";
|
|
|
195 |
foreach my $name (@$refFields) {
|
|
|
196 |
foreach my $key ( keys %{$keyFieldsData{$tableName}{$name}}) {
|
|
|
197 |
DebugDumpData("Xref", \%xRef) unless exists $xRef{$key};
|
|
|
198 |
ReportError("Cannot locate cross ref for $tableName, $name, $key") unless exists $xRef{$key} ;
|
|
|
199 |
$rmData{$tName}{$tag}{$key} = $xRef{$key};
|
|
|
200 |
}
|
|
|
201 |
delete $keyFieldsData{$tableName}{$name};
|
|
|
202 |
}
|
|
|
203 |
}
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
#-------------------------------------------------------------------------------
|
|
|
207 |
# Function : GetXrefsBaseViewId
|
|
|
208 |
#
|
|
|
209 |
# Description : Get cross references to other entites
|
|
|
210 |
#
|
|
|
211 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
212 |
#
|
|
|
213 |
# Returns :
|
|
|
214 |
#
|
|
|
215 |
sub GetXrefsBaseViewId
|
|
|
216 |
{
|
|
|
217 |
GetXrefsCommon( \@_, 'VIEW_ID',"select view_id, view_name from views where view_id");
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
#-------------------------------------------------------------------------------
|
|
|
221 |
# Function : GetXrefsGbeId
|
|
|
222 |
#
|
|
|
223 |
# Description : Get cross references to other entites
|
|
|
224 |
#
|
|
|
225 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
226 |
#
|
|
|
227 |
# Returns :
|
|
|
228 |
#
|
|
|
229 |
sub GetXrefsGbeId
|
|
|
230 |
{
|
|
|
231 |
GetXrefsCommon( \@_, 'GBE_ID',"select gbe_id, gbe_value from release_manager.gbe_machtype where gbe_id");
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
#-------------------------------------------------------------------------------
|
|
|
235 |
# Function : GetXrefsProjId
|
|
|
236 |
#
|
|
|
237 |
# Description : Get cross references to other entites
|
|
|
238 |
#
|
|
|
239 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
240 |
#
|
|
|
241 |
# Returns :
|
|
|
242 |
#
|
|
|
243 |
sub GetXrefsProjId
|
|
|
244 |
{
|
|
|
245 |
GetXrefsCommon( \@_, 'PROJ_ID',"select proj_id, proj_name from projects where proj_id");
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
#-------------------------------------------------------------------------------
|
|
|
249 |
# Function : GetXrefsRtagId
|
|
|
250 |
#
|
|
|
251 |
# Description : Get cross references to other entites
|
|
|
252 |
#
|
|
|
253 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
254 |
#
|
|
|
255 |
# Returns :
|
|
|
256 |
#
|
|
|
257 |
sub GetXrefsRtagId
|
|
|
258 |
{
|
|
|
259 |
GetXrefsCommon( \@_, 'RTAG_ID',"select rtag_id, rtag_name from release_tags where rtag_id");
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
#-------------------------------------------------------------------------------
|
|
|
263 |
# Function : GetXrefsIgnore
|
|
|
264 |
#
|
|
|
265 |
# Description : Ignore the cross references to other entites
|
|
|
266 |
#
|
|
|
267 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
268 |
#
|
|
|
269 |
# Returns :
|
|
|
270 |
#
|
|
|
271 |
sub GetXrefsIgnore
|
|
|
272 |
{
|
|
|
273 |
my (@refFields) = @_;
|
|
|
274 |
foreach my $tableName (keys %keyFieldsData) {
|
|
|
275 |
foreach my $name (@refFields) {
|
|
|
276 |
delete $keyFieldsData{$tableName}{$name};
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
#-------------------------------------------------------------------------------
|
|
|
282 |
# Function : GetXrefsPkg
|
|
|
283 |
#
|
|
|
284 |
# Description : Get cross references to other entites
|
|
|
285 |
#
|
|
|
286 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
287 |
#
|
|
|
288 |
# Returns :
|
|
|
289 |
#
|
|
|
290 |
sub GetXrefsPkg
|
|
|
291 |
{
|
|
|
292 |
GetXrefsCommon( \@_, 'PKG_ID',"select p.pkg_id, p.pkg_name from release_manager.packages p where pkg_id");
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
#-------------------------------------------------------------------------------
|
|
|
296 |
# Function : GetXrefsPvid
|
|
|
297 |
#
|
|
|
298 |
# Description : Get cross references to other entites
|
|
|
299 |
#
|
|
|
300 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
301 |
#
|
|
|
302 |
# Returns :
|
|
|
303 |
#
|
|
|
304 |
sub GetXrefsPvid
|
|
|
305 |
{
|
|
|
306 |
GetXrefsCommon( \@_, 'PV_ID',"select pv.pv_id, p.pkg_name ||'$;'|| pv.pkg_version from release_manager.packages p, release_manager.package_versions pv where p.pkg_id = pv.pkg_id and pv.pv_id");
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
#-------------------------------------------------------------------------------
|
|
|
310 |
# Function : GetXrefsUsers
|
|
|
311 |
#
|
|
|
312 |
# Description : Get cross references to other entites
|
|
|
313 |
#
|
|
|
314 |
# Inputs : list of keyFieldData keys to rmMerge_process
|
|
|
315 |
#
|
|
|
316 |
# Returns :
|
|
|
317 |
#
|
|
|
318 |
sub GetXrefsUsers
|
|
|
319 |
{
|
|
|
320 |
GetXrefsCommon( \@_, 'USER_ID',"select user_id, user_name from access_manager.users where user_id");
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
#-------------------------------------------------------------------------------
|
|
|
324 |
# Function : GetRelease
|
|
|
325 |
#
|
|
|
326 |
# Description : Get Details of a Release
|
|
|
327 |
#
|
|
|
328 |
# Inputs : rtagId
|
|
|
329 |
#
|
|
|
330 |
# Returns : A hash of data
|
|
|
331 |
#
|
|
|
332 |
sub GetRelease
|
|
|
333 |
{
|
|
|
334 |
my ($rtagId) = @_;
|
|
|
335 |
|
|
|
336 |
my $m_sqlstr = "select rtag_id, rtag_name from release_tags where rtag_id = $rtagId";
|
|
|
337 |
my $data = getDataFromRm('GetRelease', $m_sqlstr, {oneRow => 1});
|
|
|
338 |
return $data;
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
#-------------------------------------------------------------------------------
|
|
|
342 |
# Function : GetTableData
|
|
|
343 |
#
|
|
|
344 |
# Description : Get all data from a table for the package
|
|
|
345 |
# Its pretty dumb
|
|
|
346 |
#
|
|
|
347 |
# Inputs : $tableName
|
|
|
348 |
#
|
|
|
349 |
# Returns :
|
|
|
350 |
#
|
|
|
351 |
sub GetTableData
|
|
|
352 |
{
|
|
|
353 |
my ($tableName) = @_;
|
|
|
354 |
my (@row);
|
|
|
355 |
my @names;
|
|
|
356 |
Verbose ("GetTableData: $tableName");
|
|
|
357 |
|
|
|
358 |
#
|
|
|
359 |
# Get the list of table names
|
|
|
360 |
#
|
|
|
361 |
my $names = GetColumnNames($tableName);
|
|
|
362 |
$rmData{$tableName . '_NAMES'} = $names;
|
|
|
363 |
|
|
|
364 |
#
|
|
|
365 |
# Scan the colums looking for key names
|
|
|
366 |
#
|
|
|
367 |
my %xref;
|
|
|
368 |
my $index = 0;
|
|
|
369 |
foreach my $entry ( @{$names}) {
|
|
|
370 |
my $fname = $entry->[0];
|
|
|
371 |
if ( exists $keyFields{$fname}) {
|
|
|
372 |
$xref{$index} = $fname;
|
|
|
373 |
} elsif ( $fname =~ m~_ID~ ) {
|
|
|
374 |
Error("Consider $fname in $tableName");
|
|
|
375 |
}
|
|
|
376 |
$index++;
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
#
|
|
|
380 |
# Get all the table data
|
|
|
381 |
#
|
|
|
382 |
my $m_sqlstr = "select * from release_manager.$tableName where rtag_id = $opt_rtagId";
|
|
|
383 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
384 |
if ( defined($sth) )
|
|
|
385 |
{
|
|
|
386 |
if ( $sth->execute( ) )
|
|
|
387 |
{
|
|
|
388 |
if ( $sth->rows )
|
|
|
389 |
{
|
|
|
390 |
while ( @row = $sth->fetchrow_array )
|
|
|
391 |
{
|
|
|
392 |
my @data = @row;
|
|
|
393 |
escapeRowData(\@data);
|
|
|
394 |
push @{$rmData{$tableName . '_DATA'}}, \@data;
|
|
|
395 |
|
|
|
396 |
#
|
|
|
397 |
# Extract key linkage fields as we go
|
|
|
398 |
#
|
|
|
399 |
while (my($index, $fname) = each %xref) {
|
|
|
400 |
my $data = $row[$index];
|
|
|
401 |
next unless defined $data;
|
|
|
402 |
next if length($data) == 0;
|
|
|
403 |
$keyFieldsData{$tableName}{$fname}{$row[$index]} = 1;
|
|
|
404 |
}
|
|
|
405 |
}
|
|
|
406 |
}
|
|
|
407 |
$sth->finish();
|
|
|
408 |
}
|
|
|
409 |
else
|
|
|
410 |
{
|
|
|
411 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
else
|
|
|
415 |
{
|
|
|
416 |
Error("Prepare failure" );
|
|
|
417 |
}
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
#-------------------------------------------------------------------------------
|
|
|
421 |
# Function : GetColumnNames
|
|
|
422 |
#
|
|
|
423 |
# Description : Get Database information
|
|
|
424 |
#
|
|
|
425 |
# Inputs : table to rmMerge_process
|
|
|
426 |
#
|
|
|
427 |
# Returns : Ref to an array of data
|
|
|
428 |
#
|
|
|
429 |
sub GetColumnNames
|
|
|
430 |
{
|
|
|
431 |
my ($tableName) = @_;
|
|
|
432 |
my (@row);
|
|
|
433 |
my $found;
|
|
|
434 |
my @names;
|
|
|
435 |
Verbose ("GetColumnNames: $tableName");
|
|
|
436 |
|
|
|
437 |
my $m_sqlstr = "select COLUMN_NAME, data_type, NULLABLE, COLUMN_ID from ALL_TAB_COLUMNS where TABLE_NAME='$tableName'";
|
|
|
438 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
439 |
if ( defined($sth) )
|
|
|
440 |
{
|
|
|
441 |
if ( $sth->execute( ) )
|
|
|
442 |
{
|
|
|
443 |
if ( $sth->rows )
|
|
|
444 |
{
|
|
|
445 |
while ( @row = $sth->fetchrow_array )
|
|
|
446 |
{
|
|
|
447 |
my @data = @row;
|
|
|
448 |
$names[$row[3]-1] = \@data;
|
|
|
449 |
# print join(' ', @row), "\n";
|
|
|
450 |
$found = 1;
|
|
|
451 |
}
|
|
|
452 |
}
|
|
|
453 |
$sth->finish();
|
|
|
454 |
}
|
|
|
455 |
else
|
|
|
456 |
{
|
|
|
457 |
Error("Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
else
|
|
|
461 |
{
|
|
|
462 |
Error("Prepare failure" );
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
Error("Internal. Table not found: $tableName") unless $found;
|
|
|
466 |
return \@names;
|
|
|
467 |
}
|
|
|
468 |
|
|
|
469 |
#-------------------------------------------------------------------------------
|
|
|
470 |
# Function : escapeRowData
|
|
|
471 |
#
|
|
|
472 |
# Description : Given an array of data items massage the data so that special characters
|
|
|
473 |
# can be serailaized and deserailised via perl
|
|
|
474 |
#
|
|
|
475 |
# Special chars include: tab,newline, return
|
|
|
476 |
#
|
|
|
477 |
# At the moment there is not cross ref to the type of field
|
|
|
478 |
# Assume that if it has narsy data init then its a string
|
|
|
479 |
# and we don't do much to those
|
|
|
480 |
#
|
|
|
481 |
# Inputs : $row - Ref to an array
|
|
|
482 |
#
|
|
|
483 |
# Returns : Nothing. Data is rmMerge_processed in place
|
|
|
484 |
#
|
|
|
485 |
sub escapeRowData
|
|
|
486 |
{
|
|
|
487 |
my ($row) = @_;
|
|
|
488 |
foreach my $value ( @$row) {
|
|
|
489 |
|
|
|
490 |
$value =~ s/([\t\r\n%'])/"%" . uc(sprintf "%2.2x" , unpack("C", $1))/eg;
|
|
|
491 |
}
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
#-------------------------------------------------------------------------------
|
|
|
497 |
# Function : saveLocalData
|
|
|
498 |
#
|
|
|
499 |
# Description : Saves a hash of data to disk
|
|
|
500 |
#
|
|
|
501 |
# Inputs :
|
|
|
502 |
#
|
|
|
503 |
# Returns :
|
|
|
504 |
#
|
|
|
505 |
sub saveLocalData
|
|
|
506 |
{
|
|
|
507 |
#
|
|
|
508 |
# Dump out the configuration information
|
|
|
509 |
#
|
|
|
510 |
my $fh = ConfigurationFile::New( $localDataStore);
|
|
|
511 |
|
|
|
512 |
$fh->DumpData( "\n# rmData\n#\n", "rmData", \%rmData );
|
|
|
513 |
$fh->Close();
|
|
|
514 |
|
|
|
515 |
#DebugDumpData("rmData", \%rmData);
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
#-------------------------------------------------------------------------------
|
|
|
519 |
# Function : restoreLocalData
|
|
|
520 |
#
|
|
|
521 |
# Description : Read in the locally preserved data
|
|
|
522 |
#
|
|
|
523 |
# Inputs :
|
|
|
524 |
#
|
|
|
525 |
# Returns :
|
|
|
526 |
#
|
|
|
527 |
sub restoreLocalData
|
|
|
528 |
{
|
|
|
529 |
if (-f $localDataStore) {
|
|
|
530 |
require ( $localDataStore );
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
#-------------------------------------------------------------------------------
|
|
|
535 |
# Function : getDataFromRm
|
|
|
536 |
#
|
|
|
537 |
# Description : Get an array of data from RM
|
|
|
538 |
#
|
|
|
539 |
# Inputs : $name - Query Name
|
|
|
540 |
# $m_sqlstr - Query
|
|
|
541 |
# $options - Ref to a hash of options
|
|
|
542 |
# sql - show sql
|
|
|
543 |
# data - show data
|
|
|
544 |
# dump - show results
|
|
|
545 |
# oneRow - Only feth one row
|
|
|
546 |
# error - Must find data
|
|
|
547 |
#
|
|
|
548 |
# Returns :
|
|
|
549 |
#
|
|
|
550 |
sub getDataFromRm
|
|
|
551 |
{
|
|
|
552 |
my ($name,$m_sqlstr, $options ) = @_;
|
|
|
553 |
my @row;
|
|
|
554 |
my $data;
|
|
|
555 |
|
|
|
556 |
if (ref $options ne 'HASH') {
|
|
|
557 |
$options = {};
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
if ($options->{sql}) {
|
|
|
561 |
Message("$name: $m_sqlstr")
|
|
|
562 |
}
|
|
|
563 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
564 |
if ( defined($sth) )
|
|
|
565 |
{
|
|
|
566 |
if ( $sth->execute( ) ) {
|
|
|
567 |
if ( $sth->rows ) {
|
|
|
568 |
while ( @row = $sth->fetchrow_array ) {
|
|
|
569 |
if ($options->{data}) {
|
|
|
570 |
Message ("$name: @row");
|
|
|
571 |
}
|
|
|
572 |
#Debug0("$name: @row");
|
|
|
573 |
push @{$data}, [@row];
|
|
|
574 |
|
|
|
575 |
last if $options->{oneRow};
|
|
|
576 |
}
|
|
|
577 |
}
|
|
|
578 |
$sth->finish();
|
|
|
579 |
} else {
|
|
|
580 |
Error("Execute failure:$name: $m_sqlstr", $sth->errstr() );
|
|
|
581 |
}
|
|
|
582 |
} else {
|
|
|
583 |
Error("Prepare failure:$name" );
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
if (!$data && $options->{error}) {
|
|
|
587 |
Error( $options->{error} );
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
if ($data && $options->{oneRow}) {
|
|
|
591 |
$data = $data->[0];
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
if ($options->{dump}) {
|
|
|
595 |
DebugDumpData("$name", $data);
|
|
|
596 |
}
|
|
|
597 |
return $data;
|
|
|
598 |
}
|
|
|
599 |
|
|
|
600 |
|
|
|
601 |
#-------------------------------------------------------------------------------
|
|
|
602 |
# Documentation
|
|
|
603 |
#
|
|
|
604 |
|
|
|
605 |
=pod
|
|
|
606 |
|
|
|
607 |
=for htmltoc GENERAL::ClearCase::
|
|
|
608 |
|
|
|
609 |
=head1 NAME
|
|
|
610 |
|
|
|
611 |
rmMerge_suckRelease - Extract Release Information from RM
|
|
|
612 |
|
|
|
613 |
=head1 SYNOPSIS
|
|
|
614 |
|
|
|
615 |
jats rmMerge_suck [options] PackageName PackageVersion
|
|
|
616 |
|
|
|
617 |
Options:
|
|
|
618 |
-help - brief help message
|
|
|
619 |
-help -help - Detailed help message
|
|
|
620 |
-man - Full documentation
|
|
|
621 |
-outfile=name - Name of the output file (optional)
|
|
|
622 |
-rtagid=rtag - Identify the release
|
|
|
623 |
|
|
|
624 |
=head1 OPTIONS
|
|
|
625 |
|
|
|
626 |
=over 8
|
|
|
627 |
|
|
|
628 |
=item B<-help>
|
|
|
629 |
|
|
|
630 |
Print a brief help message and exits.
|
|
|
631 |
|
|
|
632 |
=item B<-help -help>
|
|
|
633 |
|
|
|
634 |
Print a detailed help message with an explanation for each option.
|
|
|
635 |
|
|
|
636 |
=back
|
|
|
637 |
|
|
|
638 |
=head1 EXAMPLE
|
|
|
639 |
|
|
|
640 |
jats rmMerge_suckRelease -rtagId=xxxxx
|
|
|
641 |
|
|
|
642 |
=cut
|
|
|
643 |
|
|
|
644 |
|