Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
3
# Copyright ( C ) 2004 ERG Limited, All rights reserved
4
#
5
# Module name   : jats.sh
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description   : Display the currently released version of ALL packages
11
#                 that are a part of a given release
12
#
13
#                 Currently hard coded to Sydney Legacy
14
#                 Appears to be an OLD version of play5
15
#
16
# Usage:
17
#
18
# Version   Who      Date        Description
19
#
20
#......................................................................#
21
 
22
require 5.6.1;
23
use strict;
24
use warnings;
25
use JatsError;
26
use JatsRmApi;
27
 
28
#use Data::Dumper;
29
use Cwd;
30
use DBI;
31
my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
32
my $GBE_CORE     = $ENV{'GBE_CORE'};
33
my $opt_verbose = 0;
34
 
35
 
36
my $RM_DB;
37
 
38
our %CM_DATA = (
39
    _CQ_DB                      => "dbi:ODBC:DEVI",
40
    _CQ_USER                    => "release_manager",
41
    _CQ_PASS                    => "release_manager",
42
    _CQ_CONN                    => undef,
43
);
44
 
45
#==============================================================================
46
# connectCQ
47
# Connects the DBI to Clear Quest if not connected
48
#==============================================================================
49
sub connectCQ
50
{
51
    my $globals = \%CM_DATA;
52
 
53
    if ( ! defined($globals->{_CQ_CONN}) )
54
    {
55
        $globals->{_CQ_CONN} = DBI->connect($globals->{_CQ_DB}, $globals->{_CQ_USER}, $globals->{_CQ_PASS});
56
 
57
        if ( ! defined($globals->{_CQ_CONN}) )
58
        {
59
            Error("connectCQ Failed to connect to database [$globals->{_CQ_DB}]. [$DBI::errstr].");
60
            return 0;
61
        }
62
        else
63
        {
64
            Message("connectCQ Connected to database [$globals->{_CQ_DB}].");
65
        }
66
    }
67
    return 1;
68
}   # _connectCQ
69
 
70
 
71
my @GDATA;
72
sub getPkgDetailsByRTAG_ID
73
{
74
    print "Test:1\n";
75
    my ($RTAG_ID) = @_;
76
    my $foundDetails = 0;
77
    my (@row);
78
    my $row_count = 0;
79
 
80
    # First get details from pv_id
81
 
82
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION FROM RELEASE_CONTENT rc, PACKAGE_VERSIONS pv, PACKAGES pkg WHERE rc.RTAG_ID = $RTAG_ID AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
83
    print "--- Prepare\n";
84
    my $sth = $RM_DB->prepare($m_sqlstr);
85
    if ( defined($sth) )
86
    {
87
        print "--- Execute\n";
88
        if ( $sth->execute( ) )
89
        {
90
            print "--- Test Rows\n";
91
            if ( $sth->rows )
92
            {
93
                print "--- Fetch Rows\n";
94
                while ( @row = $sth->fetchrow_array )
95
                {
96
                    my %DATA;
97
                    $DATA{pv_id}            = $row[0];
98
                    $DATA{name}             = $row[1];
99
                    $DATA{version}          = $row[2];
100
                    push @GDATA, (\%DATA);
101
                    $row_count++;
102
                }
103
            }
104
            print "--- Finish: $row_count rows extracted\n";
105
            $sth->finish();
106
        }
107
        else
108
        {
109
            Warning("Execute failure: " . $sth->errstr );
110
        }
111
    }
112
    else
113
    {
114
        Warning("Prepare failure" );
115
    }
116
}
117
 
118
 
119
sub test_2
120
{
121
    print "Test:2\n";
122
 
123
    my $foundPkg = 0;
124
    my $pkg = 'mos_api';
125
    my @row;
126
    my ($m_sqlstr ) = "SELECT pkg_id, pkg_name FROM PACKAGES WHERE pkg_name=?";
127
    my ($sth )  = $RM_DB->prepare($m_sqlstr);
128
    if ( defined($sth) )
129
    {
130
        if ( $sth->execute( $pkg ) )
131
        {
132
            if ( $sth->rows )
133
            {
134
                while ( @row = $sth->fetchrow_array )
135
                {
136
                    print "---- @row\n";
137
                    $foundPkg = 1;
138
                    last;
139
                }
140
            }
141
            $sth->finish();
142
            if ( ! $foundPkg )
143
            {
144
                Warning("Unable to find Package [$pkg]");
145
            }
146
        }
147
        else
148
        {
149
            Warning("executing query [$m_sqlstr] : " . $sth->errstr);
150
        }
151
    }
152
    else
153
    {
154
        Warning("Unable to prepare SQL Statement [$m_sqlstr] : " . $RM_DB->errstr);
155
    }
156
 
157
}
158
 
159
sub test_3
160
{
161
    print "Test:3\n";
162
 
163
    my $m_sqlstr = "BEGIN PK_BUILDAPI.Remove_All_Product_Components(?,?); END;";
164
 
165
    my $sth = $RM_DB->prepare($m_sqlstr);
166
    if ( defined($sth) )
167
    {
168
        if ( ! $sth->execute( 12,  'SomePlatform' ) )
169
        {
170
            Warning("Expected Error executing query [$m_sqlstr] : " . $sth->errstr);
171
        }
172
        else
173
        {
174
            Warning("Expected error, but got a good result");
175
        }
176
    }
177
    else
178
    {
179
        Warning("Unable to prepare SQL Statement [$m_sqlstr] : " . $RM_DB->errstr);
180
    }
181
 
182
}
183
 
184
#-------------------------------------------------------------------------------
185
# Function        : Main
186
#
187
# Description     :
188
#
189
# Inputs          :
190
#
191
# Returns         :
192
#
193
 
194
ErrorConfig( 'name'    =>'TEST' );
195
 
196
connectRM( \$RM_DB);
197
#connectCQ();
198
getPkgDetailsByRTAG_ID(1861);               # Sydney Legacy
199
test_2();
200
test_3();
201
#DebugDumpData("GDATA", \@GDATA);
202
print "End of tests\n";
203
exit;
204
 
205
connectRM();
206
print "Connecting: $CM_DATA{_CQ_CONN}\n";
207
 
208