Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
2
# CLASS RmPkgInfo
3
# Gathers information about package from the Release Manager Database
4
#
5
# By convention all members/methods that begin with an '_' are private.
6
#
7
###############################################################################
8
 
361 dpurdie 9
=head1 NAME
10
 
227 dpurdie 11
    RmPkgInfo: Class to allow package details to be collected from release manager
12
 
361 dpurdie 13
=head1 DATA
14
 
227 dpurdie 15
    By default will load details about the provided package.  
16
    The following information is gathered and stored in a hash with the following keys
17
        pkg_id          => The ID Number of the package
18
        pkg_name        => The Name of the package
19
        pv_id           => The ID number of the package version
20
        pkg_version     => The Version number of the package
21
        pv_description  => The package Version description (or default if not available)
22
        pv_reason       => The package Version reason or default if not available)
23
        pv_label        => The package Version label (or default if not available)
24
        pv_dlocked      => Flag to indicate package Version is locked (or default if not available)
25
        pv_source_path  => Package source patch (or undefined if not available) )
26
        pv_modified_time => DateTime the package was created
27
 
28
 
29
    Will also gather optional information if requested
30
 
31
    Attached issues will be collected if called, will gather the following in a multi level hash
32
    keyed by database (TDSE or DEVI) and issue number
33
        iss_numStr      => The Issue Number as a string
34
        iss_state       => The Issue State flag
35
        iss_id          => The Issue database number
36
        iss_summary     => The Issue summary
37
        iss_status      => The Issue Status flag
38
        iss_priority    => The Issue priority
39
        iss_type        => The Issue Type
40
 
41
    The package runtime dependencies are also gathered and stored in a hash if called upon.
42
    The following details are collected in a hash keyed by dependency name.
43
        rt_name         => The Runtime Dependency Name
44
        rt_version      => The Runtime Dependency Version
45
        rt_comments     => The Runtime Dependency Comments
46
 
47
    The package dependencies can also be retrieved.  For each dependency found it will create
48
    a new RmPkgInfo object and stores it in the object.  Information about a dependency can be
49
    retrieved from the objects themselves
50
 
361 dpurdie 51
=head1 SYNOPSIS
227 dpurdie 52
 
53
    use DeployUtils::RmPkgInfo
54
 
55
    my $pkg = DeployUtils::RmPkgInfo->new({ PKG_NAME => "name", PKG_VERSION => "ver" })
56
    or
57
    my $pkg = DeployUtils::RmPkgInfo->new({ PV_ID => "1234" })
58
    or
59
    my $pkg = DeployUtils::RmPkgInfo->new({ PKG_NAME => "name", RTAG_ID => "ver", WIP => 1 })
60
 
61
        Instantiates the object, connects to RM and tries to load details about the package.
62
        Will always return the class object (unless invalid args which will abort).  
63
        Failure to connect or retrieve package information will still succeed. Use the foundPkg() & foundDetails() 
64
        members to verify the appropriate data has been collected
65
        Synopsis 1
66
            Will try to locate pkg_id for the name supplied, foundPkg() will return true or false depending on result.
67
            If successfull will use pkg_id & supplied version to get package details, foundDetails() will 
68
            return true or false depending on result.
69
            In this case foundDetails() implies foundPkg()
70
        Synopsis 2
71
            Will locate package details by supplied pv_id, both foundPkg() & foundDetails() will return true 
72
            or false depending on result.
73
        Synopsis 3
74
            Will try to locate the current version of PkgName in Release rTagId.
75
            If WIP is set to non 0 then will look for the latest version is release managers Work In Progress view.
76
            If not defined or set to 0 then it will look in the standard release view.
77
 
78
    $rv = $pkg->foundPkg()
79
        Returns true if package information is found ie pkg_id is non 0 (see new above)
80
 
81
    $rv = $pkg->foundDetails()
82
        Returns true if package version information is found ie pv_id is non 0 (see new above)
83
 
84
    $str = $pkg->pkg_id()
85
    $str = $pkg->pkg_name()
86
    $str = $pkg->pv_id()
87
    $str = $pkg->pkg_version()
88
    $str = $pkg->pv_description()
89
    $str = $pkg->pv_reason()
90
    $str = $pkg->pv_label()
91
    $str = $pkg->pv_dlocked()
92
    $str = $pkg->pv_source_path()
93
    $str = $pkg->pv_modified_time()
94
        Details Accessor members, returns the associated field from the package details
95
 
96
 
97
    The following calls are used to access associated Issue details
98
 
99
    $rv = $pkg->getPkgIssues()
100
        Will connect to RM & CQ to get details about issues attached to current package.
101
        First gets a list of issue number attached from RM and then gets the issue details from CQ.
102
        Returns 1 for success and 0 for failure, however foundIssues() can be used to determine
103
        if issues have been found.
104
 
105
    $rv = $pkg->foundIssues()
106
        Returns true if Issues details for package have been retrieved.
107
 
108
    $typelist = $pkg->getIssueTypes()
109
        Returns as a list of strings, the issue types found.  This will be one or both of
110
        ( "tdse", "devi" ).  This will call getPkgIssues if foundIssues() is false.
111
 
112
    $issuelist = $pkg->getIssueNumbers(issuetype)
113
        Returns as a list of strings, the issue numbers (iss_id) found for the passed issue type.
114
        This will call getPkgIssues if foundIssues() is false.
115
        Will abort if parameter not passed
116
        example
117
            foreach $i ( $pkg->getIssueTypes() )
118
                print $pkg->getIssueNumbers($i)
119
 
120
    $str = $pkg->iss_numStr(issuetype, issueId)
121
    $str = $pkg->iss_state(issuetype, issueId)
122
    $str = $pkg->iss_id(issuetype, issueId)
123
    $str = $pkg->iss_summary(issuetype, issueId)
124
    $str = $pkg->iss_status(issuetype, issueId)
125
    $str = $pkg->iss_priority(issuetype, issueId)
126
    $str = $pkg->iss_type(issuetype, issueId)
127
        Details Accessor members, returns the associated field from the issues details for the issuetype & issueId
128
        This will call getPkgIssues if foundIssues() is false. Will abort if parameters not passed
129
 
130
 
131
    The following calls are used to access associated Runtime Dependencies
132
 
133
    $rv = getRtDeps()
134
        Will Connect to RM to get details about associated RunTime dependencies.
135
        Returns 1 for success and 0 for failure, however foundRtDeps() can be used to determine
136
        if issues have been found.
137
 
138
    $rv = $pkg->foundRtDeps()
139
        Returns true if Runtime dependencies details for package have been retrieved.
140
 
141
    @rtlist = $pkg->getRtDepNames()
142
        Returns as a list of strings, the dependency names of all dependencies
143
        This will call getRtDeps if foundRtDeps() is false.
144
 
145
    $str = $pkg->rt_name(RtDepName)
146
    $str = $pkg->rt_version(RtDepName)
147
    $str = $pkg->rt_comments(RtDepName)
148
        Details Accessor members, returns the associated field from the runtime dependencies for the dependency name
149
        This will call getRtDeps if foundRtDeps() is false.  Will abort if parameters not passed
150
 
151
 
152
    The following calls are used to access associated Dependencies
153
 
154
    $rv = $getDependenciesHash()
155
        Will return a hash containing package name and versions for all the dependant
156
        packages, without extracting all the package information.
157
 
158
        This function corrects a problem in other function where multiple packages of the same
159
        name are mistreated.
160
 
161
    $rv = $pkg->getDependencies()
162
        Will Connect to RM to get details about associated dependencies.  For each dependency will instantiate
163
        a new RmPkgInfo object and stores it in this object.  By default the new object will automatically try
164
        to retrieve details about its package.
165
        Returns 1 if fetched dependencies from RM, returns 0 if problems retieving data from RM.  Use foundDependencies()
166
        to determine if these have been found.
167
        The new objects created should be checked with foundPkg() &/or foundDetails() to see if they got the 
168
        package details.
169
 
170
    $rv = $pkg->foundDependencies()
171
        Returns true if dependencies details for package have been retrieved.
172
 
173
    @list = $pkg->getDependencyNames()
174
        Returns as a list of strings, the names of all dependencies found.
175
 
176
    $depPkg = $pkg->getDependencyObject(DepNam)
177
        Returns the RmPkgInfo object for the supplied Dependency name.
178
 
179
 
180
    Global Parameter modification functions
181
 
182
    $str = DeployUtils::RmPkgInfo->DefaultDescription(str)
183
    DeployUtils::RmPkgInfo->DefaultOverview(str)
184
    DeployUtils::RmPkgInfo->DefaultReason(str)
185
    DeployUtils::RmPkgInfo->DefaultLabel(str)
186
    DeployUtils::RmPkgInfo->DefaultDlocked(str)
187
 
188
=cut
189
 
190
package DeployUtils::RmPkgInfo;
191
 
192
use strict;
193
use DBI;
194
use DeployUtils::Logger;
195
use JatsRmApi;
196
 
197
# The eponymous meta object is a hash that stores class global data
198
# It has the same name as the package with the ":" replaced by "_".
199
# All keys that dont begin with a _ have accessor members
200
our %DeployUtils__RmPkgInfo = (
201
    _RM_CONN                    => undef,
202
    _CQ_DB                      => "dbi:ODBC:DEVI",         # SHOULD BE USED !!!!!
203
    _CQ_USER                    => "release_manager",
204
    _CQ_PASS                    => "release_manager",
205
    _CQ_CONN                    => undef,
206
    # This should match the entries in the _DETAILS hash element so accessors can be constructed.
207
    _DetailsKeys                => [ "pkg_id", "pkg_name", "pv_id", "pkg_version", "pv_description", "pv_overview", "pv_reason", "pv_label", "pv_dlocked", "pv_source_path", "pv_modified_time" ],
208
    # This should match the keys used for DEVI & TDSE issue hashes so accessors can be constructed
209
    _IssueKeys                  => [ "iss_numStr", "iss_state", "iss_id", "iss_summary", "iss_status", "iss_priority", "iss_type" ],
210
    # This should match the keys in the _RTDEPS hash for each package name so accessors can be created
211
    _RtDepKeys                  => [ "rt_name", "rt_version", "rt_comments" ],
212
    # Constants for Clearquest issues
213
    _enumCLEARQUEST_MASSI_ID    => 1,
214
    _enumCLEARQUEST_DPGIM_ID    => 2,
215
    _enumCLEARQUEST_TDSE_ID     => 3,
216
    _enumCLEARQUEST_DEVI_ID     => 4,
217
    _enumISSUES_STATE_FIXED     => 1,
218
    # Default strings for missing items
219
    DefaultDescription          => "No description available.",
220
    DefaultOverview             => "No overview available.",
221
    DefaultReason               => "No reason available.",
222
    DefaultLabel                => "No label available.",
223
    DefaultDlocked              => "N",
224
);
225
 
226
 
227
 
228
#==============================================================================
229
#   Constructor
230
# Parameter is a hash that must contain the following
231
# PKG_NAME = X & PKG_VERSION = X or
232
# PV_ID = X
233
#==============================================================================
234
sub new
235
{
236
    my $obclass = shift;
237
    my $class = ref($obclass) || $obclass;
238
    my $args = shift;
239
 
240
    LogError("RmPkgInfo::new Must supply Hash with PKG_NAME & PKG_VERSION keys or PKG_NAME & RTAG_ID or PV_ID key to instatiate object")
241
        unless ( ( defined($args->{PKG_NAME}) && defined($args->{PKG_VERSION}) ) ||
242
                 ( defined($args->{PKG_NAME}) && defined($args->{RTAG_ID}) ) ||
243
                 ( defined($args->{PV_ID}) ) );
244
 
245
    my $globals = _classobj();
246
    my $nowarn = $args->{NO_WARN} || 0;
247
 
248
    LogDebug("RmPkgInfo::new Instantiating new object of class $class");
249
    bless my $self = {
250
        _ARG_PKGNAME    => $args->{PKG_NAME},
251
        _ARG_PKGVER     => $args->{PKG_VERSION},
252
        _ARG_PV_ID      => $args->{PV_ID},
253
        _ARG_RTAG_ID    => $args->{RTAG_ID},
254
        _ARG_WIP        => $args->{WIP},
255
        _DETAILS        => { 
256
                                pkg_id          => 0,
257
                                pkg_name        => "",
258
                                pv_id           => 0,
259
                                pkg_version     => 0,
260
                                pv_description  => $globals->{DefaultDescription},
261
                                pv_overview     => $globals->{DefaultOverview},
262
                                pv_reason       => $globals->{DefaultReason},
263
                                pv_label        => $globals->{DefaultLabel},
264
                                pv_dlocked      => $globals->{DefaultDlocked},
265
                                pv_modified_time => undef,
266
                                pv_source_path  => undef
267
                           },
268
        # Contains the issue information in multi level hashs
269
        # The main hash is keyed on issue type, currently devi & tdse
270
        # The issue type hash contains another hash that is keyed on issue ID
271
        # and those issue id hashes are keyed on items defined in _IssueKeys in global hash
272
        _ISSUES         => { },
273
        # Records if getPkgIssues has been run
274
        _GETPKGISSUES   => 0,
275
        # Stores the runtime dependencies
276
        # The hash is keyed on package name and contains another hash with keys defined by _RTKeys
277
        _RTDEPS         => { },
278
        # Records if getRtDeps has been run
279
        _GETRTDEPS      => 0, 
280
        # A hash of this packages dependencies, the key is the dependency package name and the value is a RmPkgInfo object
281
        _DEPOBJECTS     => { },
282
        # Records if getDependencies has been run
283
        _GETDEPENDENCIES => 0
284
    } => ( $class );
285
 
286
    if ( $self->_connectRM() )
287
    {
288
        # PVID is the minimum so if we have it use it.
289
        if ( defined($self->{_ARG_PV_ID}) )
290
        {
291
            if ( ! $self->_getPkgDetailsByPVID() )
292
            {
293
                LogWarn("RmPkgInfo::new Unable to get Package Details By PVID From Release Manager") unless $nowarn;
294
            }
295
        }
296
        # else we need to try to use name, ver oand/or rtag ID
297
        else
298
        {
299
            # if we have Name & RTAG but no version then get version from name & rtag
300
            if ( defined($self->{_ARG_RTAG_ID}) && defined($self->{_ARG_PKGNAME}) && ! defined($self->{_ARG_PKGVER}) )
301
            {
302
                $self->{_ARG_PKGVER} = $self->_getLatestPkgVersion();
303
            }
304
 
305
            # now we should have name & ver if not report so 
306
            if ( defined($self->{_ARG_PKGNAME}) && defined($self->{_ARG_PKGVER}) )
307
            {
308
                if ( ! $self->_getPkgDetailsByName() )
309
                {
310
                    LogWarn("RmPkgInfo::new Unable to get Package Details By Name From Release Manager")unless $nowarn;
311
                }
312
            }
313
            else
314
            { 
315
                LogWarn("RmPkgInfo::new Dont have enough info to get any information")unless $nowarn;
316
            }
317
        }
318
    }
319
 
320
    return($self);
321
}   # new
322
 
323
 
324
 
325
#==============================================================================
326
# _connectRM
327
# Connects the DBI to release Manager if not connected
328
#==============================================================================
329
sub _connectRM
330
{
331
    my $self = shift;
332
    my $globals = _classobj();
333
 
334
    connectRM (\$globals->{_RM_CONN} ) if ( ! defined($globals->{_RM_CONN}));
335
 
336
    return 1;
337
}   # _connectRM
338
 
339
 
340
#==============================================================================
341
# _connectCQ
342
# Connects the DBI to Clear Quest if not connected
343
#==============================================================================
344
sub _connectCQ
345
{
346
    my $self = shift;
347
    my $globals = _classobj();
348
 
349
    if ( ! defined($globals->{_CQ_CONN}) )
350
    {
351
        $globals->{_CQ_CONN} = DBI->connect($globals->{_CQ_DB}, $globals->{_CQ_USER}, $globals->{_CQ_PASS});
352
 
353
        if ( ! defined($globals->{_CQ_CONN}) )
354
        {
355
            LogError("-x", "RmPkgInfo::_connectCQ Failed to connect to database [$globals->{_CQ_DB}]. [$DBI::errstr].");
356
            return 0;
357
        }
358
        else
359
        {
360
            LogDebug("RmPkgInfo::_connectCQ Connected to database [$globals->{_CQ_DB}].");
361
        }
362
    }
363
    return 1;
364
}   # _connectCQ
365
 
366
 
367
#------------------------------------------------------------------------------
368
# _getPkgDetailsByName
369
# This function retrieves the package version comment from the
370
# release manager database, given the RM package id and version.
371
#------------------------------------------------------------------------------
372
sub _getPkgDetailsByName
373
{
374
    my $self = shift;
375
    my $globals = _classobj();
376
    my $foundPkg = 0;
377
    my (@row);
378
 
379
    # if we are not or cannot connect then return 0 as we have not found anything
380
    return 0 if ( ! $self->_connectRM() );
381
 
382
    # First get the pkg_id from the name
295 dpurdie 383
    my ($m_sqlstr ) = "SELECT pkg_id, pkg_name FROM RELEASE_MANAGER.PACKAGES WHERE pkg_name=?";
227 dpurdie 384
    my ($sth )  = $globals->{_RM_CONN}->prepare($m_sqlstr);
385
    if ( defined($sth) )
386
    {
387
        if ( $sth->execute( $self->{_ARG_PKGNAME}) )
388
        {
389
            if ( $sth->rows )
390
            {
391
                while ( @row = $sth->fetchrow_array )
392
                {
393
                    $self->{_DETAILS}{pkg_id}   = $row[0];
394
                    $self->{_DETAILS}{pkg_name} = $row[1];
395
                    LogDebug("RmPkgInfo::_getPkgDetailsByName Found PkgID & Name [$self->{_DETAILS}{pkg_id}] [$self->{_DETAILS}{pkg_name}]");
396
                    $foundPkg = 1;
397
                    last;
398
                }
399
            }
400
            $sth->finish();
401
            if ( ! $foundPkg )
402
            {
403
                LogWarn("RmPkgInfo::_getPkgDetailsByName Unable to find Package [$self->{_ARG_PKGNAME}]");
404
                return 0;
405
            }
406
        }
407
        else
408
        {
409
            LogError("-x", "RmPkgInfo::_getPkgDetailsByName Error executing query [$m_sqlstr] : " . $sth->errstr);
410
            return 0;
411
        }
412
    }
413
    else
414
    {
415
        LogError("-x", "RmPkgInfo::_getPkgDetailsByName Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
416
        return 0;
417
    }
418
 
419
    # Now get details using found pkg_id & version
420
    $m_sqlstr = "SELECT pkg_id, pv_id, pv_description, pv_overview, comments, pkg_label, dlocked, pkg_version, SRC_PATH, TO_CHAR(MODIFIED_STAMP, 'DD-MON-YYYY') AS MODIFIED_STAMP" .
295 dpurdie 421
                " FROM RELEASE_MANAGER.PACKAGE_VERSIONS" .
227 dpurdie 422
                " WHERE pkg_id=? AND pkg_version=?";
423
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
424
    if ( defined($sth) )
425
    {
426
        if ( $sth->execute( $self->{_DETAILS}{pkg_id}, $self->{_ARG_PKGVER} ) )
427
        {
428
            if ( $sth->rows )
429
            {
430
                while ( @row = $sth->fetchrow_array )
431
                {
432
                    $self->{_DETAILS}{pkg_id}         = $row[0];
433
                    $self->{_DETAILS}{pv_id}          = $row[1];
434
                    $self->{_DETAILS}{pv_description} = $row[2] if ( $row[2] );
435
                    $self->{_DETAILS}{pv_overview}    = $row[3] if ( $row[3] );
436
                    $self->{_DETAILS}{pv_reason}      = $row[4] if ( $row[4] );
437
                    $self->{_DETAILS}{pv_label}       = $row[5] if ( $row[5] );
438
                    $self->{_DETAILS}{pv_dlocked}     = $row[6] if ( $row[6] );
439
                    $self->{_DETAILS}{pkg_version}    = $row[7] if ( $row[7] );
440
                    $self->{_DETAILS}{pv_source_path} = $row[8] if ( $row[8] );
441
                    $self->{_DETAILS}{pv_modified_time}= $row[9] if ( $row[9] );
442
 
443
                    LogDebug("RmPkgInfo::_getPkgDetailsByName Found Details for Package");
444
                    return 1;
445
                }
446
                LogWarn("RmPkgInfo::_getPkgDetailsByName Unable to find Package Details for [$self->{_ARG_PKGNAME}, $self->{_ARG_PKGVER}]");
447
            }
448
        }
449
        else
450
        {
451
            LogError("-x", "RmPkgInfo::_getPkgDetailsByName Error executing query [$m_sqlstr] : " . $sth->errstr);
452
            return 0;
453
        }
454
    }
455
    else
456
    {
457
        LogError("-x", "RmPkgInfo::_getPkgDetailsByName Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
458
        return 0;
459
    }
460
    return 0;
461
}
462
 
463
 
464
 
465
#------------------------------------------------------------------------------
466
# _getPkgDetailsByPVID
467
# This function retrieves the package version comment from the
468
# release manager database, given the Package Version id PVID.
469
#------------------------------------------------------------------------------
470
sub _getPkgDetailsByPVID
471
{
472
    my $self = shift;
473
    my $globals = _classobj();
474
    my $foundDetails = 0;
475
    my (@row);
476
 
477
    # if we are not or cannot connect then return 0 as we have not found anything
478
    return 0 if ( ! $self->_connectRM() );
479
 
480
    # First get details from pv_id
481
    my $m_sqlstr = "SELECT pkg_id, pv_id, pv_description, pv_overview, comments, pkg_label, dlocked, pkg_version, SRC_PATH, TO_CHAR(MODIFIED_STAMP, 'DD-MON-YYYY') AS MODIFIED_STAMP" .
295 dpurdie 482
                   " FROM RELEASE_MANAGER.PACKAGE_VERSIONS" .
227 dpurdie 483
                   " WHERE pv_id=?";
484
    my $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
485
    if ( defined($sth) )
486
    {
487
        if ( $sth->execute( $self->{_ARG_PV_ID} ) )
488
        {
489
            if ( $sth->rows )
490
            {
491
                while ( @row = $sth->fetchrow_array )
492
                {
493
                    $self->{_DETAILS}{pkg_id}         = $row[0];
494
                    $self->{_DETAILS}{pv_id}          = $row[1];
495
                    $self->{_DETAILS}{pv_description} = $row[2] if ( $row[2] );
496
                    $self->{_DETAILS}{pv_overview}    = $row[3] if ( $row[3] );
497
                    $self->{_DETAILS}{pv_reason}      = $row[4] if ( $row[4] );
498
                    $self->{_DETAILS}{pv_label}       = $row[5] if ( $row[5] );
499
                    $self->{_DETAILS}{pv_dlocked}     = $row[6] if ( $row[6] );
500
                    $self->{_DETAILS}{pkg_version}    = $row[7] if ( $row[7] );
501
                    $self->{_DETAILS}{pv_source_path} = $row[8] if ( $row[8] );
502
                    $self->{_DETAILS}{pv_modified_time}= $row[9] if ( $row[9] );
503
                    LogDebug("RmPkgInfo::_getPkgDetailsByPVID Found Details for Package");
504
                    $foundDetails = 1;
505
                    last;
506
                }
507
            }
508
            $sth->finish();
509
            if ( ! $foundDetails )
510
            {
511
                LogWarn("RmPkgInfo::_getPkgDetailsByPVID Unable to find Package [$self->{_ARG_PV_ID}]");
512
                return 0;
513
            }
514
        }
515
        else
516
        {
517
            LogError("-x", "RmPkgInfo::_getPkgDetailsByPVID Error executing query [$m_sqlstr] : " . $sth->errstr);
518
            return 0;
519
        }
520
    }
521
    else
522
    {
523
        LogError("-x", "RmPkgInfo::_getPkgDetailsByPVID Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
524
        return 0;
525
    }
526
 
527
    # now get pkgName from found pkg_id
295 dpurdie 528
    $m_sqlstr = "SELECT pkg_id, pkg_name FROM RELEASE_MANAGER.PACKAGES WHERE pkg_id=?";
227 dpurdie 529
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
530
    if ( defined($sth) )
531
    {
532
        if ( $sth->execute( $self->{_DETAILS}{pkg_id} ) )
533
        {
534
            if ( $sth->rows )
535
            {
536
                while ( @row = $sth->fetchrow_array )
537
                {
538
                    $self->{_DETAILS}{pkg_id}   = $row[0];
539
                    $self->{_DETAILS}{pkg_name} = $row[1];
540
                    LogDebug("RmPkgInfo::_getPkgDetailsByPVID Found PkgID & Name [$self->{_DETAILS}{pkg_id}] [$self->{_DETAILS}{pkg_name}]");
541
                    return 1;
542
                }
543
            }
544
        }
545
        else
546
        {
547
            LogError("-x", "RmPkgInfo::_getPkgDetailsByPVID Error executing query [$m_sqlstr] : " . $sth->errstr);
548
            return 0;
549
        }
550
    }
551
    else
552
    {
553
        LogError("-x", "RmPkgInfo::_getPkgDetailsByPVID Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
554
        return 0;
555
    }
556
    return 0;
557
}
558
 
559
 
560
sub _getLatestPkgVersion
561
{ 
562
    my ( $self ) = shift;
563
    my $globals = _classobj();
564
    my $foundPkg = 0;
565
    my $pkgver = undef;
566
    my (@row);
567
 
568
    # if we are not or cannot connect then return 0 as we have not found anything
569
    return undef if ( ! $self->_connectRM() );
570
 
571
    # First get the pkg_id from the name
572
    my ($m_sqlstr );
573
    if ( defined($self->{_ARG_WIP}) && $self->{_ARG_WIP} != 0 )
574
    {
575
        LogDebug("RmPkgInfo::_getLatestPkgVersion Using Work In Progress View");
295 dpurdie 576
        $m_sqlstr = "SELECT pv.pkg_version FROM RELEASE_MANAGER.work_in_progress wip, RELEASE_MANAGER.package_versions pv, RELEASE_MANAGER.PACKAGES pkg WHERE ( wip.pv_id=pv.pv_id AND pv.pkg_id=pkg.pkg_id AND wip.rtag_id=? AND pkg.pkg_name=? )";
227 dpurdie 577
    }
578
    else
579
    {
580
        LogDebug("RmPkgInfo::_getLatestPkgVersion Using Released View");
295 dpurdie 581
        $m_sqlstr = "SELECT pv.pkg_version FROM RELEASE_MANAGER.release_content rel, RELEASE_MANAGER.package_versions pv, RELEASE_MANAGER.PACKAGES pkg WHERE ( rel.pv_id=pv.pv_id AND pv.pkg_id=pkg.pkg_id AND rel.rtag_id=? AND pkg.pkg_name=? )";
227 dpurdie 582
    }
583
 
584
    my ($sth )  = $globals->{_RM_CONN}->prepare($m_sqlstr);
585
    if ( defined($sth) )
586
    {
587
        if ( $sth->execute( $self->{_ARG_RTAG_ID}, $self->{_ARG_PKGNAME}) )
588
        {
589
            if ( $sth->rows )
590
            {
591
                while ( @row = $sth->fetchrow_array )
592
                {
593
                    $pkgver = $row[0];
594
                    LogDebug("RmPkgInfo::_getLatestPkgVersion Found Latest PVID [$pkgver]");
595
                    $foundPkg++;
596
                }
597
            }
598
            $sth->finish();
599
            if ( ! $foundPkg )
600
            {
601
                LogWarn("RmPkgInfo::_getLatestPkgVersion Unable to find Latest Version for [$self->{_ARG_PKGNAME}] in [$self->{_ARG_RTAG_ID}]");
602
                return undef;
603
            }
604
            elsif ( $foundPkg > 1 )
605
            { 
606
                LogWarn("RmPkgInfo::_getLatestPkgVersion Found more than 1 version of [$self->{_ARG_PKGNAME}] in [$self->{_ARG_RTAG_ID}]");
607
                return undef;
608
            }
609
        }
610
        else
611
        {
612
            LogError("-x", "RmPkgInfo::_getPkgDetailsByName Error executing query [$m_sqlstr] : " . $sth->errstr);
613
            return undef;
614
        }
615
    }
616
    else
617
    {
618
        LogError("-x", "RmPkgInfo::_getPkgDetailsByName Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
619
        return undef;
620
    }
621
 
622
    return $pkgver;
623
}
624
 
625
 
626
 
627
 
628
#------------------------------------------------------------------------------
629
# getPkgIssues
630
# Updates the ISSUES hash containing information about assigned issues.
631
#------------------------------------------------------------------------------
632
sub getPkgIssues
633
{
634
    my $self = shift;
635
    my $globals = _classobj();
636
 
637
    my ($sth);
638
    my (@row);
639
    my ($m_sqlstr);
640
    my ($TDSEissues)  = "-1";
641
    my ($DEVIiss )    = "-1";
642
 
643
    # if we are not or cannot connect then return 0 as we have not found anything
644
    return 0 if ( ! $self->_connectRM() );
645
 
295 dpurdie 646
    $m_sqlstr = "SELECT iss_db, iss_id, iss_state, notes FROM RELEASE_MANAGER.CQ_ISSUES WHERE pv_id=?";
227 dpurdie 647
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
648
    if ( defined($sth) )
649
    {
650
        if ( $sth->execute( $self->{_DETAILS}{pv_id} ) )
651
        {
652
            if ( $sth->rows )
653
            {
654
                while ( @row = $sth->fetchrow_array )
655
                {
656
                    if ( $row[0] == $globals->{_enumCLEARQUEST_DEVI_ID} )
657
                    {
658
                        $DEVIiss = "$DEVIiss" . "," . $row[1];
659
 
660
                        $self->{_ISSUES}{devi}{$row[1]}{iss_numStr} = $row[1];
661
                        $self->{_ISSUES}{devi}{$row[1]}{iss_state}  = $row[2];
662
                    }
663
                    elsif ( $row[0] == $globals->{_enumCLEARQUEST_TDSE_ID} )
664
                    {
665
                        $TDSEissues = "$TDSEissues" . "," . $row[1];
666
 
667
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_numStr} = $row[1];
668
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_state}  = $row[2];
669
                    }
670
                    else
671
                    {
672
                        LogWarn("RmPkgInfo::getPkgIssues Issue type [$row[0]] not supported.");
673
                    }
674
                }
675
            }
676
            $sth->finish();        
677
        }
678
        else
679
        {
680
            LogError("-x", "RmPkgInfo::getPkgIssues Error executing query [$m_sqlstr] : " . $sth->errstr);
681
            return 0;
682
        }
683
    }
684
    else
685
    {
686
        LogError("-x", "RmPkgInfo::getPkgIssues Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
687
        return 0;
688
    }
689
 
690
    LogInfo($self->pkg_name() . ":" . $self->pkg_version() . "DEVIiss =[$DEVIiss]");
691
    LogInfo($self->pkg_name() . ":" . $self->pkg_version() . "TDSEiss =[$TDSEissues]");
692
 
693
    # if we are not or cannot connect then return 0 as we have not found anything
694
    return 0 if ( ! $self->_connectCQ() );
695
 
696
    # now we create the SQL statement to get the detaisl from the CQ database
697
    if ( "$DEVIiss" ne "" || "$TDSEissues" ne "" )
698
    {
699
        $m_sqlstr = "\n" .
700
        "SELECT * FROM ( \n" .
701
        "       SELECT " . $globals->{_enumCLEARQUEST_DEVI_ID} . " AS iss_db,\n" .
702
        "               si.dbid AS iss_id, \n" .
703
        "               si.new_num AS iss_num, \n" .
704
        "               si.headline AS summary, \n" .
705
        "               sdef.name AS status, \n" .
706
        "               si.priority AS priority,\n" .
707
        "               si.issue_type AS issue_type\n".
708
        "       FROM  DEVI_PROD.admin.software_issue si INNER JOIN DEVI_PROD.admin.statedef sdef ON si.state = sdef.id\n" .
709
        "       WHERE  si.dbid IN ( $DEVIiss )\n" .
710
        "       UNION ALL\n" .
711
        "       SELECT " . $globals->{_enumCLEARQUEST_TDSE_ID} . " AS iss_db,\n" .
712
        "               si.dbid AS iss_id, \n" .
713
        "               si.job_number AS iss_num, \n" .
714
        "               si.problem_summary AS summary, \n" .
715
        "               sdef.name AS status, \n" .
716
        "               si.priority AS priority,\n" .
717
        "               NULL AS issue_type\n" .
718
        "       FROM  TDSE_2002.admin.request si INNER JOIN TDSE_2002.admin.statedef sdef ON si.state = sdef.id\n" .
719
        "       WHERE  si.dbid IN ( $TDSEissues )\n" .
720
        "     ) AS issues ORDER BY iss_num ASC";
721
 
722
        undef($sth);
723
        $sth = $globals->{_CQ_CONN}->prepare($m_sqlstr);
724
        if ( defined($sth) )
725
        {
726
            if ( $sth->execute() )
727
            {
728
                while ( @row = $sth->fetchrow_array )
729
                {
730
                    if ( $row[0] == $globals->{_enumCLEARQUEST_DEVI_ID} )
731
                    {
732
                        $self->{_ISSUES}{devi}{$row[1]}{iss_id}       = $row[1];
733
                        $self->{_ISSUES}{devi}{$row[1]}{iss_numStr}   = $row[2];
734
                        $self->{_ISSUES}{devi}{$row[1]}{iss_summary}  = $row[3];
735
                        $self->{_ISSUES}{devi}{$row[1]}{iss_status}   = $row[4];
736
                        $self->{_ISSUES}{devi}{$row[1]}{iss_priority} = $row[5];
737
 
738
                        if ( $row[6] )
739
                        {
740
                            $self->{_ISSUES}{devi}{$row[1]}{iss_type} = $row[6];
741
                        }                                             
742
                        else
743
                        {
744
                            $self->{_ISSUES}{devi}{$row[1]}{iss_type} = "Not Known";
745
                        }
746
 
747
                    }
748
                    elsif ( $row[0] == $globals->{_enumCLEARQUEST_TDSE_ID} )
749
                    {
750
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_id}       = $row[1];
751
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_numStr}   = $row[2];
752
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_summary}  = $row[3];
753
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_status}   = $row[4];
754
                        $self->{_ISSUES}{tdse}{$row[1]}{iss_priority} = $row[5];
755
 
756
                        if ( $row[6] )
757
                        {
758
                            $self->{_ISSUES}{tdse}{$row[1]}{iss_type} = $row[6];
759
                        }
760
                        else
761
                        {
762
                            $self->{_ISSUES}{tdse}{$row[1]}{iss_type} = "Not Known";
763
                        }
764
                    }
765
                    else
766
                    {
767
                        LogWarn("RmPkgInfo::getPkgIssues Issue type [$row[0]] not supported.");
768
                    }
769
                }
770
            }
771
            else
772
            {
773
                LogError("-x", "RmPkgInfo::getPkgIssues Error executing query [$m_sqlstr] : " . $sth->errstr);
774
                return 0;
775
            }
776
        }
777
        else
778
        {
779
            LogError("-x", "RmPkgInfo::getPkgIssues Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
780
            return 0;
781
        }
782
    }
783
 
784
    $self->{_GETPKGISSUES} = 1;
785
    return 1;
786
}
787
 
788
 
789
 
790
#------------------------------------------------------------------------------
791
# getRtDeps
792
# Populates the RTDeps Hash with runtime dependencies
793
#------------------------------------------------------------------------------
794
sub getRtDeps
795
{
796
    my $self = shift;
797
    my $globals = _classobj();
798
 
799
    my ($sth );
800
    my (@row);
801
    my ($m_sqlstr);
802
 
803
    # if we are not or cannot connect then return 0 as we have not found anything
804
    return 0 if ( ! $self->_connectRM() );
805
 
806
    $m_sqlstr = "SELECT pkg.pkg_name, pv.pkg_version, rd.rtd_comments, rd.rtd_url, rd.mod_date, \n" .
807
                "usr.full_name, usr.user_email \n" .
295 dpurdie 808
                "FROM RELEASE_MANAGER.runtime_dependencies rd, RELEASE_MANAGER.package_versions pv, RELEASE_MANAGER.PACKAGES pkg, RELEASE_MANAGER.users usr \n".
227 dpurdie 809
                "WHERE pv.pkg_id = pkg.pkg_id \n" .
810
                "AND rd.rtd_id = pv.pv_id \n" .
811
                "AND rd.mod_user = usr.user_id \n" .
812
                "AND rd.pv_id = ?\n" .
813
                "ORDER BY UPPER(pkg.pkg_name) ASC";
814
 
815
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
816
    if ( defined($sth) )
817
    {
818
        if ( $sth->execute( $self->{_DETAILS}{pv_id} ) ) 
819
        {
820
            if ( $sth->rows )
821
            {
822
                while ( @row = $sth->fetchrow_array )
823
                {
824
                    $self->{_RTDEPS}{$row[0]}{rt_name}    = $row[0];
825
                    $self->{_RTDEPS}{$row[0]}{rt_version} = $row[1];
826
                    if ( $row[2] )
827
                    {
828
                        $self->{_RTDEPS}{$row[0]}{rt_comments} = $row[2];
829
                    }
830
                    else
831
                    {
832
                        $self->{_RTDEPS}{$row[0]}{rt_comments} = "None";
833
                    }
834
                }
835
            }
836
        }
837
        else
838
        {
839
            LogError("-x", "RmPkgInfo::getRtDeps Error executing query [$m_sqlstr] : " . $sth->errstr);
840
            return 0;
841
        }
842
    }
843
    else
844
    {
845
        LogError("-x", "RmPkgInfo::getRtDeps Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
846
        return 0;
847
    }
848
 
849
    $self->{_GETRTDEPS} = 1;
850
    return 1;
851
}
852
 
853
 
854
#------------------------------------------------------------------------------
855
# zapProductContents
856
#
857
# This function ZAPs the contents of a product.
858
#
859
# The contents are determined by 'pv_id' and a 'machtype' both of which are
860
# set during build time and are globally accessible.
861
#
862
#------------------------------------------------------------------------------
863
sub zapProductContents
864
{
865
    my $self = shift;
866
    my $globals = _classobj();
867
 
868
    my ( $platform ) = shift;
869
 
870
    # if we are not or cannot connect then return 0 as we have not found anything
871
    return 0 if ( ! $self->_connectRM() );
872
 
873
    LogNorm("RmPkgInfo::zapProductContents Removing Contents for [$self->{_DETAILS}{pv_id}], [$platform]");
874
 
875
    my ($sth );
876
    my ($m_sqlstr);
877
 
878
    $m_sqlstr = "BEGIN PK_BUILDAPI.Remove_All_Product_Components(?,?); END;";
879
 
880
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
881
    if ( defined($sth) )
882
    {
883
        if ( ! $sth->execute( $self->{_DETAILS}{pv_id},  $platform ) )
884
        {
885
            LogError("-x", "RmPkgInfo::zapProductContents Error executing query [$m_sqlstr] : " . $sth->errstr);
886
            return 0;
887
        }
888
    }
889
    else
890
    {
891
        LogError("-x", "RmPkgInfo::zapProductContents Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
892
        return 0;
893
    }
894
 
895
    # done
896
    return 1;
897
}
898
 
899
 
900
#------------------------------------------------------------------------------
901
# insertProductContentItem
902
#
903
# This function inserts and item into the product contents table.
904
#
905
# The 'pv_id' and a 'machtype' are set during build time and are globally accessible.
906
# ans are not required to be passed.
907
#
908
#------------------------------------------------------------------------------
909
sub insertProductContentItem
910
{
911
    my $self = shift;
912
    my $globals = _classobj();
913
 
914
    my ($platform, $sOrigFilePath, $sFileName, $sDestFilePath, $nByteSize, $sCRCcksum) = @_;
915
 
916
    # if we are not or cannot connect then return 0 as we have not found anything
917
    return 0 if ( ! $self->_connectRM() );
918
 
919
    LogNorm ("RmPkgInfo::insertProductContentItem: [$self->{_DETAILS}{pv_id}], [$platform], [$sOrigFilePath], [$sFileName], [$sDestFilePath], [$nByteSize], [$sCRCcksum]");
920
 
921
 
922
    my ($sth );
923
    my ($m_sqlstr);
924
 
925
    $m_sqlstr = "BEGIN PK_BUILDAPI.Add_Product_Component( ?, ?, ?, ?, ?, ?, ?); END;";
926
 
927
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
928
    if ( defined($sth) )
929
    {
930
        if ( ! $sth->execute( $self->{_DETAILS}{pv_id}, $platform, $sOrigFilePath, $sFileName, $sDestFilePath, $nByteSize, $sCRCcksum ) )
931
        {
932
            LogError("-x", "RmPkgInfo::insertProductContentItem Error executing query [$m_sqlstr] : " . $sth->errstr);
933
            return 0;
934
        }
935
    }
936
    else
937
    {
938
        LogError("-x", "RmPkgInfo::insertProductContentItem Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
939
        return 0;
940
    }
941
    # done
942
    return 1;
943
}
944
 
945
 
946
#==============================================================================
947
#   getDependencies
948
#==============================================================================
949
sub getDependencies
950
{
951
    my $self = shift;
952
    my $globals = _classobj();
953
 
954
    my ($obj, $name);
955
    my ($m_sqlstr);
956
    my ($sth);
957
    my (@row);
958
 
959
    # First we get the list of dependenciy pvid's and use them to create new objects
295 dpurdie 960
    $m_sqlstr = "select dpv_id from RELEASE_MANAGER.package_dependencies where pv_id=?";
227 dpurdie 961
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
962
    if ( defined($sth) )
963
    {
964
        if ( $sth->execute( $self->{_DETAILS}{pv_id} ) )
965
        {
966
            if ( $sth->rows )
967
            {
968
                while ( @row = $sth->fetchrow_array )
969
                {
970
                    $obj = DeployUtils::RmPkgInfo->new( { PV_ID => $row[0] } );
971
                    if ( $obj->foundDetails() )
972
                    {
973
                        $name = $obj->pkg_name();
974
                        $self->{_DEPOBJECTS}{$name} = $obj;
975
                        LogDebug("RmPkgInfo::getDependencies Created Dependency object for $name");
976
                    }
977
                }
978
            }
979
        }
980
        else
981
        {
982
            LogError("-x", "RmPkgInfo::getDependencies Error executing query [$m_sqlstr] : " . $sth->errstr);
983
            return 0;
984
        }
985
    }
986
    else
987
    {
988
        LogError("-x", "RmPkgInfo::getDependencies Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
989
        return 0;
990
    }
991
 
992
    $self->{_GETDEPENDENCIES} = 1;
993
    return 1;
994
}   # getDependencies
995
 
996
#==============================================================================
997
#   getDependenciesHash
998
#==============================================================================
999
sub getDependenciesHash
1000
{
1001
    my $self = shift;
1002
    my $globals = _classobj();
1003
 
1004
    my ($obj, $name);
1005
    my ($m_sqlstr);
1006
    my ($sth);
1007
    my (@row);
1008
    my %result;
1009
 
1010
    # First we get the list of dependenciy pvid's
295 dpurdie 1011
    $m_sqlstr = "SELECT pkg.PKG_NAME, pv.PKG_VERSION FROM RELEASE_MANAGER.PACKAGE_DEPENDENCIES pd, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg WHERE pd.PV_ID=? AND pd.DPV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
227 dpurdie 1012
    $sth = $globals->{_RM_CONN}->prepare($m_sqlstr);
1013
    if ( defined($sth) )
1014
    {
1015
        if ( $sth->execute( $self->{_DETAILS}{pv_id} ) )
1016
        {
1017
            if ( $sth->rows )
1018
            {
1019
                while ( @row = $sth->fetchrow_array )
1020
                {
1021
                    $result{$row[0]}{$row[1]} = 1;
1022
                }
1023
            }
1024
        }
1025
        else
1026
        {
1027
            LogError("-x", "RmPkgInfo::getDependenciesHash Error executing query [$m_sqlstr] : " . $sth->errstr);
1028
            return 0;
1029
        }
1030
    }
1031
    else
1032
    {
1033
        LogError("-x", "RmPkgInfo::getDependenciesHash Unable to prepare SQL Statement [$m_sqlstr] : " . $globals->{_RM_CONN}->errstr);
1034
        return 0;
1035
    }
1036
 
1037
    return \%result;
1038
}   # getDependenciesHash
1039
 
1040
 
1041
#==============================================================================
1042
# getDependencyNames
1043
# Returns the keys from the _DEPOBJECTS hash that are the names of the dependencies
1044
#==============================================================================
1045
sub getDependencyNames
1046
{
1047
    my $self = shift;
1048
 
1049
    $self->getDependencies() if ( ! $self->foundDependencies() );
1050
 
1051
    return sort keys %{$self->{_DEPOBJECTS}};
1052
}   # getDependencyNames
1053
 
1054
 
1055
 
1056
#==============================================================================
1057
# getDependencyObject
1058
# Returns the RmPkgInfo object for name
1059
#==============================================================================
1060
sub getDependencyObject
1061
{
1062
    my $self = shift;
1063
    my $name = shift;
1064
 
1065
    LogError("RmPkgInfo::getDependencyObject Must supply Dependency name") if ( ! defined($name) );
1066
 
1067
    $self->getDependencies() if ( ! $self->foundDependencies() );
1068
 
1069
    return $self->{_DEPOBJECTS}{$name};
1070
}   # getDependencyObject
1071
 
1072
 
1073
#==============================================================================
1074
# getIssueTypes
1075
# Returns the issues types stored in the ISSUES array, should be devi and/or tdse
1076
#==============================================================================
1077
sub getIssueTypes
1078
{
1079
    my $self = shift;
1080
 
1081
    # Call getPkgIssues if not already
1082
    $self->getPkgIssues() if ( ! $self->foundIssues() );
1083
 
1084
    return keys %{$self->{_ISSUES}};
1085
}   # getIssueTypes
1086
 
1087
 
1088
 
1089
#==============================================================================
1090
#   getIssueNumbers
1091
# Returns a list of the issue numbers for the associated issue type passed
1092
#==============================================================================
1093
sub getIssueNumbers
1094
{
1095
    my $self = shift;
1096
    my $issType = shift;
1097
    LogError("RmPkgInfo::getIssueNumbers Must supply issue type") if ( ! defined($issType) );
1098
    # Call getPkgIssues if not already
1099
    $self->getPkgIssues() if ( ! $self->foundIssues() );
1100
    return sort keys %{$self->{_ISSUES}{$issType}};
1101
}   # getIssueNumbers
1102
 
1103
 
1104
 
1105
#==============================================================================
1106
#   getRtDepNames
1107
# Returns a list of the Runtime Dependencies found
1108
#==============================================================================
1109
sub getRtDepNames
1110
{
1111
    my $self = shift;
1112
    $self->getRtDeps() if ( ! $self->foundRtDeps() );
1113
    return keys %{$self->{_RTDEPS}};
1114
}   # getRtDepNames
1115
 
1116
 
1117
#==============================================================================
1118
# foundPkg
1119
# Returns TRUE if the package has been found in RM otherwise FALSE.
1120
# A pkg is found if the pkg_id is non 0
1121
#==============================================================================
1122
sub foundPkg
1123
{
1124
    my $self = shift;
1125
 
1126
    return ( $self->{_DETAILS}{pkg_id} != 0 ) ? 1 : 0;
1127
}   # foundPkg
1128
 
1129
 
1130
 
1131
#==============================================================================
1132
# foundDetails
1133
# Returns TRUE if the package details has been found in RM otherwise FALSE.
1134
# A pkg is found if the pv_id is non 0
1135
#==============================================================================
1136
sub foundDetails
1137
{
1138
    my $self = shift;
1139
 
1140
    return ( $self->{_DETAILS}{pv_id} != 0 ) ? 1 : 0;
1141
}   # foundDetails
1142
 
1143
 
1144
 
1145
#==============================================================================
1146
# foundIssues
1147
# Returns TRUE if the package Issues has been found in RM otherwise FALSE.
1148
#==============================================================================
1149
sub foundIssues
1150
{
1151
    my $self = shift;
1152
 
1153
    return $self->{_GETPKGISSUES};
1154
}   # foundIssues
1155
 
1156
 
1157
 
1158
#==============================================================================
1159
# foundRtDeps
1160
# Returns TRUE if the package RtDeps has been found in RM otherwise FALSE.
1161
#==============================================================================
1162
sub foundRtDeps
1163
{
1164
    my $self = shift;
1165
 
1166
    return $self->{_GETRTDEPS};
1167
}   # foundRtDeps
1168
 
1169
 
1170
 
1171
#==============================================================================
1172
# foundDependencies
1173
# Returns TRUE if the package Dependencies has been found in RM otherwise FALSE.
1174
#==============================================================================
1175
sub foundDependencies
1176
{
1177
    my $self = shift;
1178
 
1179
    return $self->{_GETDEPENDENCIES};
1180
}   # foundDependencies
1181
 
1182
 
1183
 
1184
#==============================================================================
1185
# _classobj
1186
# Internal member that is tri-natured: can be called as function, class method, 
1187
# or object method.
1188
# It returns a reference to the eponymous hash for access to class global data
1189
#==============================================================================
1190
sub _classobj 
1191
{
1192
    my $obclass = shift || __PACKAGE__;
1193
    my $class   = ref($obclass) || $obclass;
1194
    $class =~ s/:/_/g;  # Replace all ": with "_" to get the name of the hash
1195
    no strict "refs";   # to convert sym ref to real one
1196
    return \%$class;
1197
}
1198
 
1199
 
1200
#==============================================================================
1201
#   dumpSelf, debugging member to dump selfs hash
1202
#==============================================================================
1203
sub dumpSelf
1204
{
1205
    use Data::Dumper;
1206
 
1207
    my $self = shift;
1208
 
1209
    print Data::Dumper->Dump([$self, $self->_classobj()], [ref($self), "Globals"]);
1210
}   # dumpSelf
1211
 
1212
 
1213
 
1214
# This code is executed when the package is included and generates accessor methods for accessing
1215
# global vars in the eponymous object
1216
for my $datum (grep(!/^_/, keys %{ _classobj() }) ) 
1217
{ 
1218
    # turn off strict refs so that we can
1219
    # register a method in the symbol table
1220
    no strict "refs";       
1221
    *$datum = sub {
1222
        use strict "refs";
1223
        my $self = shift->_classobj();
1224
        $self->{$datum} = shift if @_;
1225
        return $self->{$datum};
1226
    }
1227
}
1228
 
1229
# This code is executed when the package is included and generates accessor methods for accessing
1230
# self data from the details hash
1231
for my $datum ( @{_classobj()->{_DetailsKeys}} ) 
1232
{ 
1233
    # turn off strict refs so that we can
1234
    # register a method in the symbol table
1235
    no strict "refs";       
1236
    *$datum = sub {
1237
        use strict "refs";
1238
        my $self = shift;
1239
        return $self->{_DETAILS}{$datum};
1240
    }
1241
}
1242
 
1243
# This code is executed when the package is included and generates accessor methods for accessing
1244
# self data from the Issues Hash
1245
for my $datum ( @{_classobj()->{_IssueKeys}} ) 
1246
{ 
1247
    # turn off strict refs so that we can
1248
    # register a method in the symbol table
1249
    no strict "refs";       
1250
    *$datum = sub {
1251
        use strict "refs";
1252
        my $self = shift;
1253
        my $issType = shift;
1254
        my $issId = shift;
1255
        LogError("RmPkgInfo::$datum Must supply IssueType & Issue ID as parameters") if ( ! defined($issId) );
1256
        # Call getPkgIssues if not already
1257
        $self->getPkgIssues() if ( ! $self->foundIssues() );
1258
        return $self->{_ISSUES}{$issType}{$issId}{$datum};
1259
    }
1260
}
1261
 
1262
 
1263
# This code is executed when the package is included and generates accessor methods for accessing
1264
# self data from the RTDEPS Hash
1265
for my $datum ( @{_classobj()->{_RtDepKeys}} ) 
1266
{ 
1267
    # turn off strict refs so that we can
1268
    # register a method in the symbol table
1269
    no strict "refs";       
1270
    *$datum = sub {
1271
        use strict "refs";
1272
        my $self = shift;
1273
        my $RtName = shift;
1274
        LogError("RmPkgInfo::$datum Must supply Runtime Dependency Name as parameter") if ( ! defined($RtName) );
1275
        # Call getRtDeps if not already
1276
        $self->getRtDeps() if ( ! $self->foundRtDeps() );
1277
        return $self->{_RTDEPS}{$RtName}{$datum};
1278
    }
1279
}
1280
 
1281
1;