Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6887 dpurdie 1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
3
#
4
# Module name   : jats_rm_play28.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Extract packages with text in comment
10
#
11
#
12
#......................................................................#
13
 
14
require 5.006_001;
15
use strict;
16
use warnings;
17
use JatsError;
18
use JatsSystem;
19
use Getopt::Long;
20
use Pod::Usage;                             # required for help support
21
use JatsRmApi;
22
 
23
use DBI;
24
 
25
my $VERSION = "1.2.3";                      # Update this
26
my $opt_verbose = 1;
27
my $opt_help = 0;
28
my $opt_manual;
29
my $RM_DB;
30
 
31
#-------------------------------------------------------------------------------
32
# Function        : Main Entry
33
#
34
# Description     :
35
#
36
# Inputs          :
37
#
38
# Returns         :
39
#
40
my $result = GetOptions (
41
                "help+"         => \$opt_help,          # flag, multiple use allowed
42
                "manual"        => \$opt_manual,        # flag
43
                "verbose+"      => \$opt_verbose,       # flag
44
                );
45
 
46
#
47
#   Process help and manual options
48
#
49
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result || scalar(@ARGV) <= 0);
50
pod2usage(-verbose => 1)  if ($opt_help == 2 );
51
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
52
 
53
 
54
ErrorConfig( 'name'    =>'scanComments' );
55
 
56
#$ENV{GBE_RM_LOCATION} = 'jdbc:oracle:thin:@auperaora07:1521:RELMANU1';
57
#$ENV{GBE_RM_USERNAME} = 'release_manager'; 
58
#$ENV{GBE_RM_PASSWORD} =  'release_manager';
59
 
60
getTextInComment( @ARGV );
61
 
62
sub getTextInComment
63
{
64
    my (@args ) = @_;
65
    my $found = 0;
66
    my @rows;
67
 
68
    connectRM(\$RM_DB) unless $RM_DB;
69
 
70
    #
71
    #   Create an arg list
72
    #   ie: like '%txt%'
73
    #   
74
    my @search;
75
    foreach my $arg (@args)
76
    {
77
        push @search, " pv.comments like '%$arg%' ";
78
    }
79
 
80
 
81
    #
82
    #   Now extract the package with matching comments
83
    #
84
    my $m_sqlstr = "SELECT UNIQUE pv.PV_ID, pkg.PKG_NAME,pv.PKG_VERSION " .
85
                   " FROM package_versions pv,packages pkg" .
86
                   " WHERE pv.pkg_id = pkg.pkg_id AND ( " . join(' or ', @search) . ") " .
87
                   " order by upper(pkg.PKG_NAME), pv.PKG_VERSION"
88
                   ;
89
#$m_sqlstr =~ s~\s+~ ~g;
90
#print "\n\n$m_sqlstr\n";
91
    my $sth = $RM_DB->prepare($m_sqlstr);
92
    if ( defined($sth) )
93
    {
94
        if ( $sth->execute( ) )
95
        {
96
            if ( $sth->rows )
97
            {
98
                while ( my @row = $sth->fetchrow_array )
99
                {
100
                    print "@row\n";
101
                    $found = 1;
102
                }
103
            }
104
            $sth->finish();
105
        }
106
        else
107
        {
108
            Error("GetDepends:Execute failure: $m_sqlstr", $sth->errstr() );
109
        }
110
    }
111
    else
112
    {
113
        Error("GetDepends:Prepare failure" );
114
    }
115
 
116
    unless ( $found )
117
    {
118
        Warning("No Packages found with comment containing: @args");
119
    }
120
}
121
 
122
#-------------------------------------------------------------------------------
123
#   Documentation
124
#
125
 
126
=pod
127
 
128
=head1 NAME
129
 
130
scanComments - Scan Release Manager commants for text
131
 
132
=head1 SYNOPSIS
133
 
134
 Usage: jats [opts] scanComments [cmd-options] text [text...]
135
 
136
 Where opts:
137
    -help                       - brief help message
138
    -help -help                 - Detailed help message
139
    -man                        - Full documentation
140
 
141
=head1 OPTIONS
142
 
143
=over 8
144
 
145
=item B<-help>
146
 
147
Print a brief help message and exits.
148
 
149
=item B<-help -help>
150
 
151
Print a detailed help message with an explanation for each option.
152
 
153
=item B<-man>
154
 
155
Prints the manual page and exits.
156
 
157
=back
158
 
159
=head1 ARGUMENTS
160
 
161
=head2 Basic Commands
162
 
163
Scans the 'Reason For Release' field of all packages for matching text.
164
 
165
The '%' character can be used as a wild card character
166
 
167
=head1 EXAMPLES
168
 
169
jats scanComments DEVI%066675
170
 
171
Will locate all packages that contain 'DEVI-066675' or 'DEVI 066675' or the like.
172
 
173
=cut
174