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   : scanComments.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     : See POD at end of file
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} = 'MS_READONLY'; 
58
$ENV{GBE_RM_PASSWORD} =  'MS_READONLY';
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
    #   Now extract the package with matching comments
82
    #
83
    my $m_sqlstr = "SELECT UNIQUE pv.PV_ID, pkg.PKG_NAME,pv.PKG_VERSION " .
84
                   " FROM release_manager.package_versions pv,release_manager.packages pkg" .
85
                   " WHERE pv.pkg_id = pkg.pkg_id AND ( " . join(' or ', @search) . ") " .
86
                   " order by upper(pkg.PKG_NAME), pv.PKG_VERSION"
87
                   ;
88
#$m_sqlstr =~ s~\s+~ ~g;
89
#print "\n\n$m_sqlstr\n";
90
    my $sth = $RM_DB->prepare($m_sqlstr);
91
    if ( defined($sth) )
92
    {
93
        if ( $sth->execute( ) )
94
        {
95
            if ( $sth->rows )
96
            {
97
                while ( my @row = $sth->fetchrow_array )
98
                {
99
                    print "@row\n";
100
                    $found = 1;
101
                }
102
            }
103
            $sth->finish();
104
        }
105
        else
106
        {
107
            Error("GetDepends:Execute failure: $m_sqlstr", $sth->errstr() );
108
        }
109
    }
110
    else
111
    {
112
        Error("GetDepends:Prepare failure" );
113
    }
114
 
115
    unless ( $found )
116
    {
117
        Warning("No Packages found with comment containing: @args");
118
    }
119
}
120
 
121
#-------------------------------------------------------------------------------
122
#   Documentation
123
#
124
 
125
=pod
126
 
127
=head1 NAME
128
 
129
scanComments - Scan Release Manager commants for text
130
 
131
=head1 SYNOPSIS
132
 
133
 Usage: jats [opts] scanComments [cmd-options] text [text...]
134
 
135
 Where opts:
136
    -help                       - brief help message
137
    -help -help                 - Detailed help message
138
    -man                        - Full documentation
139
 
140
=head1 OPTIONS
141
 
142
=over 8
143
 
144
=item B<-help>
145
 
146
Print a brief help message and exits.
147
 
148
=item B<-help -help>
149
 
150
Print a detailed help message with an explanation for each option.
151
 
152
=item B<-man>
153
 
154
Prints the manual page and exits.
155
 
156
=back
157
 
158
=head1 ARGUMENTS
159
 
160
=head2 Basic Commands
161
 
162
Scans the 'Reason For Release' field of all packages for matching text.
163
 
164
The '%' character can be used as a wild card character
165
 
166
=head1 EXAMPLES
167
 
168
jats scanComments DEVI%066675
169
 
170
Will locate all packages that contain 'DEVI-066675' or 'DEVI 066675' or the like.
171
 
172
=cut
173