Subversion Repositories DevTools

Rev

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