Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.ripple;
2
 
3
import java.sql.CallableStatement;
4
import java.sql.Connection;
5
 
6
import java.sql.DriverManager;
7
 
8
import java.sql.PreparedStatement;
9
import java.sql.ResultSet;
10
import java.sql.SQLException;
11
 
12
import java.sql.Timestamp;
13
 
14
import java.sql.Types;
15
 
16
import java.util.Calendar;
17
import java.util.Date;
18
import java.util.GregorianCalendar;
19
import java.util.Iterator;
20
import java.util.ListIterator;
21
import java.util.Vector;
850 mhunt 22
import java.util.concurrent.locks.ReentrantLock;
814 mhunt 23
 
850 mhunt 24
import oracle.jdbc.OracleDriver;
814 mhunt 25
 
26
import org.apache.log4j.Logger;
27
 
28
/**Release Manager schema abstraction
29
 */
30
public class ReleaseManager
31
{
32
  /**Unit test hook.
33
   * Prevents Oracle interaction when false.
34
   * @attribute
35
   */
36
  public static boolean mUseDatabase = true;
37
 
38
  /**Unit test hook
39
   * Container of persisted run levels for unit test usage
40
   * Must be managed by the unit test code
41
   * @attribute
42
   */
864 mhunt 43
  public static Vector<Integer> mPersistedRunLevelCollection = new Vector<Integer>();
814 mhunt 44
 
45
  /**database represented enumerated value
46
   * @attribute
47
   */
48
  public static final int DB_CANNOT_CONTINUE = 1;
49
 
50
  /**database represented enumerated value
51
   * @attribute
52
   */
53
  public static final int DB_PAUSED = 2;
54
 
55
  /**database represented enumerated value
56
   * @attribute
57
   */
58
  public static final int DB_ACTIVE = 3;
59
 
60
  /**database represented enumerated value
61
   * @attribute
62
   */
63
  public static final int DB_IDLE = 4;
64
 
65
  /**database represented enumerated value
66
   * @attribute
67
   */
68
  public static final int DB_WAITING = 5;
69
 
70
  /**package object of no consequence
71
   * @attribute
72
   */
73
  static final Package NULL_PACKAGE = new Package();
74
 
75
  /**registered status
76
   * @attribute
77
   */
78
  static boolean mRegistered = false;
79
 
80
  /**Logger
81
   * @attribute
82
   */
83
  private static final Logger mLogger = Logger.getLogger(ReleaseManager.class);
84
 
85
  /**database session handle
86
   * @attribute
87
   */
850 mhunt 88
  private static Connection mConnection = null;
814 mhunt 89
 
850 mhunt 90
  /**database session handle
91
   * @attribute
92
   */
93
  private static final ReentrantLock mSession = new ReentrantLock();
94
 
814 mhunt 95
  /**index to current ReleaseConfig item
96
   * @attribute
97
   */
98
  private int mReleaseConfigIndex = -1;
99
 
100
  /**index to current RunLevel item
101
   * @attribute
102
   */
103
  private int mRunLevelIndex = -1;
104
 
105
  /**collection of ReleaseConfig objects
106
   * @attribute
107
   */
864 mhunt 108
  private Vector<ReleaseConfig> mReleaseConfigCollection = new Vector<ReleaseConfig>();
814 mhunt 109
 
110
  /**database connection string
111
   * @attribute
112
   */
113
  private static String mConnectionString = new String();
114
 
115
  /**database username
116
   * @attribute
117
   */
118
  private static String mUsername = new String();
119
 
120
  /**database password
121
   * @attribute
122
   */
123
  private static String mPassword = new String();
124
 
125
  /**collection of RunLevel objects
126
   * @attribute
127
   */
864 mhunt 128
  private Vector<RunLevel> mRunLevelCollection = new Vector<RunLevel>();
868 mhunt 129
 
814 mhunt 130
  /**in daemon mode
131
   *   select gm.gbe_value from release_config rc, gbe_machtype gm
132
   *   where rc.rtag_id=<baseline> and gm.gbe_id=rc.gbe_id;
133
   * in escrow mode
134
   *   select gm.gbe_value from boms b, release_manager.release_config rc,
135
   *   release_manager.gbe_machtype gm
136
   *   where b.bom_id=<baseline> and rc.rtag_id=b.rtag_id_fk and gm.gbe_id=rc.gbe_id;
137
   * populates the machtypeCollection with the resultset
138
   */
864 mhunt 139
  void queryMachtypes(Vector<String> machtypeCollection, boolean daemonMode, int baseline) throws SQLException, Exception
814 mhunt 140
  {
141
    mLogger.debug("queryMachtypes " + daemonMode);
142
    if ( !mUseDatabase )
143
    {
144
      mLogger.info("queryMachtypes !mUseDatabase");
145
      // a highly unlikely set of machtypes
146
      String machtype = new String("linux_i386");
147
      machtypeCollection.add(machtype);
148
      machtype = new String("sparc");
149
      machtypeCollection.add(machtype);
150
      machtype = new String("solaris10_x86");
151
      machtypeCollection.add(machtype);
152
    }
153
    else
154
    {
155
      String sql = new String("");
156
 
157
      if ( daemonMode )
158
      {
159
        sql = "select gm.gbe_value from release_manager.release_config rc, release_manager.gbe_machtype gm where rc.rtag_id=" + baseline + " and gm.gbe_id=rc.gbe_id";
160
      }
161
      else
162
      {
163
        sql = 
164
        "select gm.gbe_value from boms b, release_manager.release_config rc, release_manager.gbe_machtype gm where b.bom_id=" + 
165
        baseline + " and rc.rtag_id=b.rtag_id_fk and gm.gbe_id=rc.gbe_id";
166
      }
167
 
168
      try
169
      {
170
        CallableStatement stmt = mConnection.prepareCall(sql);
171
        ResultSet rset = stmt.executeQuery();
172
 
173
        while( rset.next() )
174
        {
175
          String machtype = rset.getString("gbe_value");
176
 
177
          if ( machtype != null )
178
          {
179
            machtypeCollection.add(machtype);
180
          }
181
        }
830 mhunt 182
 
183
        rset.close();
184
        stmt.close();
814 mhunt 185
      }
186
      catch ( SQLException e )
187
      {
188
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
189
        {
190
          mLogger.error("queryMachtypes database access error only");
191
          throw new SQLException();
192
        }
193
        else
194
        {
195
          mLogger.fatal("queryMachtypes show stopper");
868 mhunt 196
          throw new Exception("queryMachtypes show stopper");
814 mhunt 197
        }
198
      }
199
    }
200
  }
201
 
202
  /**in daemon mode
203
   *   select p.proj_name, rt.rtag_name from projects p, release_tags rt
204
   *   where rt.rtag_id=<baseline> and p.proj_id=rt.proj_id;
205
   * returns a concatenation of the proj_name and rtag_name
206
   * in escrow mode
207
   *   select dp.proj_name, br.branch_name, b.bom_version, b.bom_lifecycle
208
   *   from dm_projects dp, branches br, boms b
209
   *   where b.bom_id=<baseline> and br.branch_id=b.branch_id and dp.proj_id=br.proj_id;
210
   * returns a concatenation of the proj_name, branch_name, bom_version and bom_lifecycle
211
   */
212
  String queryBaselineName(boolean daemonMode, int baseline) throws SQLException, Exception
213
  {
214
    mLogger.debug("queryBaselineName " + daemonMode);
215
    String retVal = new String();
216
 
217
    if ( !mUseDatabase )
218
    {
219
      mLogger.info("queryBaselineName !mUseDatabase");
220
      // a highly unlikely baseline name
221
      if (daemonMode)
222
      {
223
        retVal = "TIMBUKTU (TIM) > R7";
224
      }
225
      else
226
      {
227
        retVal = "TIMBUKTU (TIM) > R7 7.9";
228
      }
229
    }
230
    else
231
    {
232
      String sql = new String("");
233
 
234
      if ( daemonMode )
235
      {
236
        sql = "select p.proj_name, rt.rtag_name from release_manager.projects p, release_manager.release_tags rt where rt.rtag_id=" + baseline + " and p.proj_id=rt.proj_id";
237
      }
238
      else
239
      {
240
        sql = 
241
        "select dp.proj_name, br.branch_name, b.bom_version, b.bom_lifecycle from dm_projects dp, branches br, boms b where b.bom_id=" + 
242
        baseline + " and br.branch_id=b.branch_id and dp.proj_id=br.proj_id";
243
      }
244
 
245
      try
246
      {
247
        CallableStatement stmt = mConnection.prepareCall(sql);
248
        ResultSet rset = stmt.executeQuery();
249
 
250
        while( rset.next() )
251
        {
252
          String proj_name = rset.getString("proj_name");
253
 
254
          if ( proj_name != null )
255
          {
256
            retVal += proj_name;
257
          }
258
 
259
          if ( daemonMode )
260
          {
261
            String rtag_name = rset.getString("rtag_name");
262
 
263
            if ( rtag_name != null )
264
            {
265
              retVal += " > " + rtag_name;
266
            }
267
          }
268
          else
269
          {
270
            String branch_name = rset.getString("branch_name");
271
 
272
            if ( branch_name != null )
273
            {
274
              retVal += " > " + branch_name;
275
            }
276
 
277
            String bom_version = rset.getString("bom_version");
278
 
279
            if ( bom_version != null )
280
            {
281
              retVal += " " + bom_version;
282
            }
283
 
284
            String bom_lifecycle = rset.getString("bom_lifecycle");
285
 
286
            if ( bom_lifecycle != null )
287
            {
288
              retVal += "." + bom_lifecycle;
289
            }
290
          }
291
        }
830 mhunt 292
 
293
        rset.close();
294
        stmt.close();
814 mhunt 295
      }
296
      catch ( SQLException e )
297
      {
298
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
299
        {
300
          mLogger.error("queryBaselineName database access error only");
301
          throw new SQLException();
302
        }
303
        else
304
        {
305
          mLogger.fatal("queryBaselineName show stopper");
868 mhunt 306
          throw new Exception("queryBaselineName show stopper");
814 mhunt 307
        }
308
      }
309
    }
310
    mLogger.info("queryBaselineName returned " + retVal);
311
    return retVal;
312
  }
313
 
314
  /**in daemon mode
315
   *  1 get planned package info
316
   *     select pl.pv_id, p.pkg_id, p.pkg_name, pv.v_ext, pv.pkg_label, pv.src_path, pv.change_type
317
   *     from planned pl, package_versions pv, packages p
318
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
319
   *     and pv.pv_id=pl.pv_id and p.pkg_id=pv.pkg_id
320
   *     order by pl.pv_id;
321
   *  2 get planned package dependency info
322
   *     select pl.pv_id, p.pkg_name, dpv.v_ext
323
   *     from planned pl, package_versions pv, package_dependencies pd, package_versions dpv, packages p
324
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
325
   *     and pv.pv_id = pl.pv_id and pd.pv_id=pl.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
326
   *     order by pl.pv_id;
327
   *  3 get planned package build info
328
   *     select pl.pv_id, bm.bm_name, bsa.bsa_name
329
   *     from planned pl, package_versions pv, package_build_info pbi, build_machines bm, build_standards_addendum bsa
330
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
331
   *     and pv.pv_id = pl.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
332
   *     order by pl.pv_id;
333
   *  4 get planned package unit test info
334
   *     select pl.pv_id, tt.test_type_name
335
   *     from planned pl, package_versions pv, unit_tests ut, test_types tt
336
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
337
   *     and pv.pv_id = pl.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk
338
   *     order by pl.pv_id;
339
   *  5 get planned package build failure info
340
   *     select pl.pv_id, u.user_email
341
   *     from planned pl, release_tags rt, package_versions pv, autobuild_failure af, members_group mg, users u
342
   *     where pl.rtag_id=<mBaseline> and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A'
343
   *     and pv.pv_id = pl.pv_id and af.view_id=pl.view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id
344
   *     order by pl.pv_id;
345
   *  6 get planned package do not ripple info
346
   *     select pl.pv_id
347
   *     from planned pl, package_versions pv, do_not_ripple dnr
348
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
349
   *     and pv.pv_id = pl.pv_id and dnr.rtag_id=pl.rtag_id and dnr.pv_id=pl.pv_id
350
   *     order by pl.pv_id;
351
   *  7 get planned package advisory ripple info
352
   *     select pl.pv_id
353
   *     from planned pl, package_versions pv, advisory_ripple ar
354
   *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
355
   *     and pv.pv_id = pl.pv_id and ar.rtag_id=pl.rtag_id and ar.pv_id=pl.pv_id
356
   *     order by pl.pv_id;
357
   *  8 get released package info
358
   *     select rc.pv_id, p.pkg_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_label, pv.src_path, pv.ripple_field
359
   *     from release_content rc, package_versions pv, packages p
360
   *     where rc.rtag_id=<mBaseline>
361
   *     and pv.pv_id = rc.pv_id and p.pkg_id = pv.pkg_id
362
   *     order by rc.pv_id;
363
   *  9 get released package dependency info
364
   *     select rc.pv_id, dpv.pv_id, p.pkg_name, dpv.v_ext
365
   *     from release_content rc, package_versions pv, package_dependencies pd, package_versions dpv, packages p
366
   *     where rc.rtag_id=<mBaseline>
367
   *     and pv.pv_id = rc.pv_id and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
368
   *     order by rc.pv_id;
369
   * 10 get released package build info
370
   *     select rc.pv_id, bm.bm_name, bsa.bsa_name
371
   *     from release_content rc, package_versions pv, package_build_info pbi, build_machines bm, build_standards_addendum bsa
372
   *     where rc.rtag_id=<mBaseline>
373
   *     and pv.pv_id = rc.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
374
   *     order by rc.pv_id;
375
   * 11 get released package unit test info
376
   *     select rc.pv_id, tt.test_type_name
377
   *     from release_content rc, package_versions pv, unit_tests ut, test_types tt
378
   *     where rc.rtag_id=<mBaseline>
379
   *     and pv.pv_id = rc.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk
380
   *     order by rc.pv_id;
381
   * 12 get released package build failure email info
382
   *     select rc.pv_id, u.user_email
383
   *     from release_content rc, release_tags rt, package_versions pv, autobuild_failure af, members_group mg, users u
384
   *     where rc.rtag_id=<mBaseline> and rt.rtag_id=rc.rtag_id
385
   *     and pv.pv_id = rc.pv_id and af.view_id=rc.base_view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id
386
   *     order by rc.pv_id;
387
   * 13 get released package do not ripple info
388
   *     select rc.pv_id
389
   *     from release_content rc, package_versions pv, do_not_ripple dnr
390
   *     where rc.rtag_id=3741
391
   *     and pv.pv_id = rc.pv_id and dnr.rtag_id=rc.rtag_id and dnr.pv_id=rc.pv_id
392
   *     order by rc.pv_id;
393
   * 14 get released advisory ripple info
394
   *     select rc.pv_id
395
   *     from release_content rc, package_versions pv, advisory_ripple ar
396
   *     where rc.rtag_id=<mBaseline>
397
   *     and pv.pv_id = rc.pv_id and ar.rtag_id=rc.rtag_id and ar.pv_id=rc.pv_id
398
   *     order by rc.pv_id;
399
   * in escrow mode
400
   *  1 get released product info
401
   *     select oc.prod_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_label, pv.src_path
402
   *     from bom_contents bc, operating_systems os, os_contents oc, release_manager.package_versions pv, release_manager.packages p
403
   *     where bc.bom_id=<mBaseline> and os.node_id=bc.node_id and oc.os_id=os.os_id and pv.pv_id=oc.prod_id and p.pkg_id=pv.pkg_id
404
   *     order by oc.prod_id;
405
   *    this will generate a list of pv_ids associtaed with products
406
   *    many in the list will reference cots products outside the scope of a escrow build
407
   *  2 for each <pv_id>, call traverseDependencies( packageCollection, pv_id, false ) to traverse its set of dependencies
408
   *  3 for each Package, call queryBuildInfo to get released package build info
409
   *  
410
   * Supports
411
   *    test_type_name="Autobuild UTF"
412
   *    bm_name="Generic"|"Linux"|"Solaris"|"Win32"
413
   *    bsa_name="Debug"|"Production"|"Production and Debug"|"Java 1.4"|"Java 1.5"|"Java 1.6"
414
   */
415
  void queryPackageVersions(RippleEngine rippleEngine, 
864 mhunt 416
                            Vector<Package> packageCollection, boolean daemonMode, int baseline) throws SQLException, Exception
814 mhunt 417
  {
418
    mLogger.debug("queryPackageVersions " + daemonMode);
419
 
420
    if ( !mUseDatabase )
421
    {
422
      mLogger.info("queryPackageVersions !mUseDatabase");
423
 
424
      if (daemonMode)
425
      {
426
        /* a highly unlikely set of packages
427
         * planned info
428
         * pv_id pkg_id pkg_name                     v_ext pkg_label src_path                          change_type
429
         * 0     76     UncommonDependency           .tim  0.TIM.WIP \vob\UncommonDependency           P
430
         * 1     1011   DependencyMissingFromRelease .tim  1.TIM.WIP \vob\DependencyMissingFromRelease M
431
         * 2     34     CommonDependency             .tim  2.TIM.WIP \vob\CommonDependency             M
432
         * 3     908    SolarisCentricProduct        .tim  3.TIM.WIP \vob\SolarisCentricProduct        N
433
         * 4     6      GenericProduct               .tim  4.TIM.WIP \vob\GenericProduct               P
434
         * 5     11     Product                      .tim  5.TIM.WIP \vob\Product                      M
435
         * 6     113    UnfinishedProduct            .tim  6.TIM.WIP \vob\UnfinishedProduct            M
436
         */
437
         if ( mConnectionString.compareTo("iteration1") == 0 )
438
         {
439
           Package p = new Package(0, "UncommonDependency", ".tim", "UncommonDependency.tim", "0.TIM.WIP", "\\vob\\UncommonDependency", 'P');
440
           p.mPid = 76;
441
           p.mDirectlyPlanned = true;
442
           packageCollection.add(p);
443
         }
444
 
445
         Package p = new Package(1, "DependencyMissingFromRelease", ".tim", "DependencyMissingFromRelease.tim", "1.TIM.WIP", "\\vob\\DependencyMissingFromRelease", 'M');
446
         p.mPid = 1011;
447
         p.mDirectlyPlanned = true;
448
         packageCollection.add(p);
449
 
450
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
451
         {
452
           p = new Package(2, "CommonDependency", ".tim", "CommonDependency.tim", "2.TIM.WIP", "\\vob\\CommonDependency", 'M');
453
           p.mPid = 34;
454
           p.mDirectlyPlanned = true;
455
           packageCollection.add(p);
456
         }
457
 
458
         if ( mConnectionString.compareTo("iteration1") == 0 
459
           || mConnectionString.compareTo("iteration2") == 0
460
           || mConnectionString.compareTo("iteration3") == 0 )
461
         {
462
           p = new Package(3, "SolarisCentricProduct", ".tim", "SolarisCentricProduct.tim", "3.TIM.WIP", "\\vob\\SolarisCentricProduct", 'N');
463
           p.mPid = 908;
464
           p.mDirectlyPlanned = true;
465
           packageCollection.add(p);
466
         }
467
 
468
         if ( mConnectionString.compareTo("iteration1") == 0 
469
           || mConnectionString.compareTo("iteration2") == 0
470
           || mConnectionString.compareTo("iteration3") == 0
471
           || mConnectionString.compareTo("iteration4") == 0 )
472
         {
473
           p = new Package(4, "GenericProduct", ".tim", "GenericProduct.tim", "4.TIM.WIP", "\\vob\\GenericProduct", 'P');
474
           p.mPid = 6;
475
           p.mDirectlyPlanned = true;
476
           packageCollection.add(p);
477
         }
478
 
479
         if ( mConnectionString.compareTo("iteration1") == 0 
480
           || mConnectionString.compareTo("iteration2") == 0
481
           || mConnectionString.compareTo("iteration3") == 0
482
           || mConnectionString.compareTo("iteration4") == 0
483
           || mConnectionString.compareTo("iteration5") == 0 )
484
         {
485
           p = new Package(5, "Product", ".tim", "Product.tim", "5.TIM.WIP", "\\vob\\Product", 'M');
486
           p.mPid = 11;
487
           p.mDirectlyPlanned = true;
488
           packageCollection.add(p);
489
         }
490
 
491
         p = new Package(6, "UnfinishedProduct", ".tim", "UnfinishedProduct.tim", "6.TIM.WIP", "\\vob\\UnfinishedProduct", 'M');
492
         p.mPid = 113;
493
         p.mDirectlyPlanned = true;
494
         packageCollection.add(p);
495
 
496
        /* planned dependencies
497
         * pv_id pkg_name                     v_ext
498
         * 1     NotInTheRelease              .cots
499
         * 2     CotsWithFunnyVersion         .cots
500
         * 2     UncommonDependency           .tim
501
         * 3     CommonDependency             .tim
502
         * 4     CommonDependency             .tim
503
         * 5     UncommonDependency           .tim
504
         */
505
         p = findPackage(1, packageCollection);
506
         p.mDependencyCollection.add("NotInTheRelease.cots");
507
         p.mDependencyIDCollection.add(-1);
508
 
509
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
510
         {
511
           p = findPackage(2, packageCollection);
512
           p.mDependencyCollection.add("CotsWithFunnyVersion.cots");
513
           p.mDependencyIDCollection.add(-1);
514
           p.mDependencyCollection.add("UncommonDependency.tim");
515
           p.mDependencyIDCollection.add(-1);
516
         }
517
 
518
         if ( mConnectionString.compareTo("iteration1") == 0 
519
           || mConnectionString.compareTo("iteration2") == 0
520
           || mConnectionString.compareTo("iteration3") == 0 )
521
         {
522
           p = findPackage(3, packageCollection);
523
           p.mDependencyCollection.add("CommonDependency.tim");
524
           p.mDependencyIDCollection.add(-1);
525
         }
526
 
527
         if ( mConnectionString.compareTo("iteration1") == 0 
528
           || mConnectionString.compareTo("iteration2") == 0
529
           || mConnectionString.compareTo("iteration3") == 0
530
           || mConnectionString.compareTo("iteration4") == 0 )
531
         {
532
           p = findPackage(4, packageCollection);
533
           p.mDependencyCollection.add("CommonDependency.tim");
534
           p.mDependencyIDCollection.add(-1);
535
         }
536
 
537
         if ( mConnectionString.compareTo("iteration1") == 0 
538
           || mConnectionString.compareTo("iteration2") == 0
539
           || mConnectionString.compareTo("iteration3") == 0
540
           || mConnectionString.compareTo("iteration4") == 0
541
           || mConnectionString.compareTo("iteration5") == 0 )
542
         {
543
           p = findPackage(5, packageCollection);
544
           p.mDependencyCollection.add("UncommonDependency.tim");
545
           p.mDependencyIDCollection.add(-1);
546
         }
547
 
548
        /* planned build info
549
         * pv_id bm_name bsa_name
550
         * 0     Linux   Java 1.6
551
         * 1     Linux   Debug
552
         * 2     Linux   Debug
553
         * 2     Solaris Production
554
         * 2     Win32   Production and Debug
555
         * 3     Solaris Java 1.4
556
         * 4     Generic Java 1.5
557
         * 5     Linux   Java 1.6
558
         * 5     Win32   Java 1.6
559
         */
560
         if ( mConnectionString.compareTo("iteration1") == 0 )
561
         {
562
           p = findPackage(0, packageCollection);
563
           BuildStandard bs = new BuildStandard(rippleEngine);
564
           bs.setLinux();
565
           bs.set1_6();
566
           p.mBuildStandardCollection.add(bs);
567
         }
568
 
569
         p = findPackage(1, packageCollection);
570
         BuildStandard bs = new BuildStandard(rippleEngine);
571
         bs.setLinux();
572
         bs.setDebug();
573
         p.mBuildStandardCollection.add(bs);
574
 
575
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
576
         {
577
           p = findPackage(2, packageCollection);
578
           bs = new BuildStandard(rippleEngine);
579
           bs.setLinux();
580
           bs.setDebug();
581
           p.mBuildStandardCollection.add(bs);
582
           bs = new BuildStandard(rippleEngine);
583
           bs.setSolaris();
584
           bs.setProduction();
585
           p.mBuildStandardCollection.add(bs);
586
           bs = new BuildStandard(rippleEngine);
587
           bs.setWin32();
588
           bs.setAll();
589
           p.mBuildStandardCollection.add(bs);
590
         }
591
 
592
         if ( mConnectionString.compareTo("iteration1") == 0 
593
           || mConnectionString.compareTo("iteration2") == 0
594
           || mConnectionString.compareTo("iteration3") == 0 )
595
         {
596
           p = findPackage(3, packageCollection);
597
           bs = new BuildStandard(rippleEngine);
598
           bs.setSolaris();
599
           bs.set1_4();
600
           p.mBuildStandardCollection.add(bs);
601
         }
602
 
603
         if ( mConnectionString.compareTo("iteration1") == 0 
604
           || mConnectionString.compareTo("iteration2") == 0
605
           || mConnectionString.compareTo("iteration3") == 0
606
           || mConnectionString.compareTo("iteration4") == 0 )
607
         {
608
           p = findPackage(4, packageCollection);
609
           bs = new BuildStandard(rippleEngine);
610
           bs.setGeneric();
611
           bs.set1_5();
612
           p.mBuildStandardCollection.add(bs);
613
         }
614
 
615
         if ( mConnectionString.compareTo("iteration1") == 0 
616
           || mConnectionString.compareTo("iteration2") == 0
617
           || mConnectionString.compareTo("iteration3") == 0
618
           || mConnectionString.compareTo("iteration4") == 0
619
           || mConnectionString.compareTo("iteration5") == 0 )
620
         {
621
           p = findPackage(5, packageCollection);
622
           bs = new BuildStandard(rippleEngine);
623
           bs.setLinux();
624
           bs.set1_6();
625
           p.mBuildStandardCollection.add(bs);
626
           bs = new BuildStandard(rippleEngine);
627
           bs.setWin32();
628
           bs.set1_6();
629
           p.mBuildStandardCollection.add(bs);
630
         }
631
 
632
        /* planned unit test info
633
         * pv_id test_type_name
634
         * 2     Manual Test
635
         * 2     Interactive Test
636
         * 2     Integration Test
637
         * 5     Autobuild UTF
638
         */
639
         if ( mConnectionString.compareTo("iteration1") == 0 
640
           || mConnectionString.compareTo("iteration2") == 0
641
           || mConnectionString.compareTo("iteration3") == 0
642
           || mConnectionString.compareTo("iteration4") == 0
643
           || mConnectionString.compareTo("iteration5") == 0 )
644
         {
645
           p = findPackage(5, packageCollection);
646
           p.mHasAutomatedUnitTests = true;
647
         }
648
 
649
        /* planned build failure info
650
         * pv_id user_email
651
         * 3     jimmyfishcake@erggroup.com
652
         * 3     rayhaddock@erggroup.com
653
         * 5     timbutdim@erggroup.com
654
         */
655
         if ( mConnectionString.compareTo("iteration1") == 0 
656
           || mConnectionString.compareTo("iteration2") == 0
657
           || mConnectionString.compareTo("iteration3") == 0 )
658
         {
659
           p = findPackage(3, packageCollection);
864 mhunt 660
           p.addEmail("jimmyfishcake@erggroup.com");
661
           p.addEmail("rayhaddock@erggroup.com");
814 mhunt 662
         }
663
 
664
         if ( mConnectionString.compareTo("iteration1") == 0 
665
           || mConnectionString.compareTo("iteration2") == 0
666
           || mConnectionString.compareTo("iteration3") == 0
667
           || mConnectionString.compareTo("iteration4") == 0
668
           || mConnectionString.compareTo("iteration5") == 0 )
669
         {
670
           p = findPackage(5, packageCollection);
864 mhunt 671
           p.addEmail("timbutdim@erggroup.com");
814 mhunt 672
         }
673
 
674
        /* planned advisory ripple info
675
         * pv_id
676
         * 0
677
         */
678
         if ( mConnectionString.compareTo("iteration1") == 0 )
679
         {
680
           p = findPackage(0, packageCollection);
681
           p.mAdvisoryRipple = true;
682
         }
683
 
684
        /* released info
685
         * pv_id pkg_id pkg_name                     pkg_version      v_ext pkg_label                           src_path                   ripple_field
686
         * 7     8      CotsWithFunnyVersion         hoopla2_x.cots   .cots CotsWithFunnyVersion_hoopla2_x.cots \vob\CotsWithFunnyVersion
687
         * 8     17     NotInAnyWayReproducible      1.0.0.tim        .tim  NA                                  NA
688
         * 9     34     CommonDependency             1.0.0000.tim     .tim  CommonDependency_1.0.0000.tim       \vob\CommonDependency
689
         * 10    908    SolarisCentricProduct        1.0.0000.tim     .tim  SolarisCentricProduct_1.0.0000.tim  \vob\SolarisCentricProduct m
690
         * 11    16     LinuxCentricProduct          1.0.0000.tim     .tim  LinuxCentricProduct_1.0.0000.tim    \vob\LinuxCentricProduct
691
         * 12    312    Win32CentricProduct          1.0.0000.tim     .tim  Win32CentricProduct_1.0.0000.tim    \vob\Win32CentricProduct
692
         * 13    6      GenericProduct               1.0.0000.tim     .tim  GenericProduct_1.0.0000.tim         \vob\ToBeMovedFromHere     M
693
         * 14    81     AdvisoryDependency           1.0.0000.tim     .tim  AdvisoryDependency_1.0.0000.tim     \vob\AdvisoryDependency
694
         * 15    1      MergedProduct                1.0.0000.tim     .tim  MergedProduct_1.0.0000.tim          \vob\MergedProduct         m
695
         */
696
         if ( mConnectionString.compareTo("iteration1") != 0 )
697
         {
698
           p = new Package(0, "UncommonDependency", "0.0.1000.tim", ".tim", "UncommonDependency.tim", "UncommonDependency_0.0.1000.tim", "\\vob\\UncommonDependency", 'x');
699
           p.mPid = 76;
700
           Integer pv_id = new Integer(0);
701
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
702
           Package plannedPackage = findPackage(p.mAlias, packageCollection);
703
 
704
           if ( plannedPackage == NULL_PACKAGE )
705
           {
706
             packageCollection.add(p);
707
           }
708
           else
709
           {
710
             plannedPackage.mVersion = "0.0.1000";
711
           }
712
         }
713
 
714
         if ( mConnectionString.compareTo("iteration1") != 0 && mConnectionString.compareTo("iteration2") != 0 )
715
         {
716
           p = new Package(2, "CommonDependency", "2.0.0000.tim", ".tim", "CommonDependency.tim", "CommonDependency_2.0.0000.tim", "\\vob\\CommonDependency", 'x');
717
           p.mPid = 34;
718
           Integer pv_id = new Integer(2);
719
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
720
           Package plannedPackage = findPackage(p.mAlias, packageCollection);
721
 
722
           if ( plannedPackage == NULL_PACKAGE )
723
           {
724
             packageCollection.add(p);
725
           }
726
           else
727
           {
728
             plannedPackage.mVersion = "2.0.0000";
729
           }
730
         }
731
 
732
         if ( mConnectionString.compareTo("iteration1") != 0 
733
           && mConnectionString.compareTo("iteration2") != 0
734
           && mConnectionString.compareTo("iteration3") != 0 )
735
         {
736
           p = new Package(3, "SolarisCentricProduct", "1.1.0000.tim", ".tim", "SolarisCentricProduct.tim", "SolarisCentricProduct_1.1.0000.tim", "\\vob\\SolarisCentricProduct", 'm');
737
           p.mPid = 908;
738
           Integer pv_id = new Integer(3);
739
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
740
           Package plannedPackage = findPackage(p.mAlias, packageCollection);
741
 
742
           if ( plannedPackage == NULL_PACKAGE )
743
           {
744
             packageCollection.add(p);
745
           }
746
           else
747
           {
748
             plannedPackage.mVersion = "1.1.0000";
749
           }
750
         }
751
 
752
         if ( mConnectionString.compareTo("iteration1") != 0 
753
           && mConnectionString.compareTo("iteration2") != 0
754
           && mConnectionString.compareTo("iteration3") != 0
755
           && mConnectionString.compareTo("iteration4") != 0 )
756
         {
757
           p = new Package(4, "GenericProduct", "1.0.1000.tim", ".tim", "GenericProduct.tim", "GenericProduct_1.0.1000.tim", "\\vob\\GenericProduct", 'M');
758
           p.mPid = 6;
759
           Integer pv_id = new Integer(4);
760
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
761
           Package plannedPackage = findPackage(p.mAlias, packageCollection);
762
 
763
           if ( plannedPackage == NULL_PACKAGE )
764
           {
765
             packageCollection.add(p);
766
           }
767
           else
768
           {
769
             plannedPackage.mVersion = "1.0.1000";
770
           }
771
         }
772
 
773
         if ( mConnectionString.compareTo("iteration1") != 0 
774
           && mConnectionString.compareTo("iteration2") != 0
775
           && mConnectionString.compareTo("iteration3") != 0
776
           && mConnectionString.compareTo("iteration4") != 0
777
           && mConnectionString.compareTo("iteration5") != 0 )
778
         {
779
           p = new Package(5, "Product", "1.0.0000.tim", ".tim", "Product.tim", "Product_1.0.0000.tim", "\\vob\\Product", 'M');
780
           p.mPid = 11;
781
           Integer pv_id = new Integer(5);
782
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
783
           Package plannedPackage = findPackage(p.mAlias, packageCollection);
784
 
785
           if ( plannedPackage == NULL_PACKAGE )
786
           {
787
             packageCollection.add(p);
788
           }
789
           else
790
           {
791
             plannedPackage.mVersion = "1.0.0000";
792
           }
793
         }
794
 
795
         p = new Package(7, "CotsWithFunnyVersion", "hoopla2_x.cots", ".cots", "CotsWithFunnyVersion.cots", "CotsWithFunnyVersion_hoopla2_x", "\\vob\\CotsWithFunnyVersion", 'x');
796
         p.mPid = 8;
797
         Integer pv_id = new Integer(7);
798
         rippleEngine.mReleasedPvIDCollection.add(pv_id);
799
         Package plannedPackage = findPackage(p.mAlias, packageCollection);
800
 
801
         if ( plannedPackage == NULL_PACKAGE )
802
         {
803
           packageCollection.add(p);
804
         }
805
         else
806
         {
807
           plannedPackage.mVersion = "hoopla2_x";
808
         }
809
 
810
         p = new Package(8, "NotInAnyWayReproducible", "1.0.0.tim", ".tim", "NotInAnyWayReproducible.tim", "NA", "NA", 'x');
811
         p.mPid = 17;
812
         pv_id = new Integer(8);
813
         rippleEngine.mReleasedPvIDCollection.add(pv_id);
814
         plannedPackage = findPackage(p.mAlias, packageCollection);
815
 
816
         if ( plannedPackage == NULL_PACKAGE )
817
         {
818
           packageCollection.add(p);
819
         }
820
         else
821
         {
822
           plannedPackage.mVersion = "1.0.0";
823
         }
824
 
825
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
826
         {
827
           p = new Package(9, "CommonDependency", "1.0.0000.tim", ".tim", "CommonDependency.tim", "CommonDependency_1.0.0000.tim", "\\vob\\CommonDependency", 'x');
828
           p.mPid = 34;
829
           pv_id = new Integer(9);
830
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
831
           plannedPackage = findPackage(p.mAlias, packageCollection);
832
 
833
           if ( plannedPackage == NULL_PACKAGE )
834
           {
835
             packageCollection.add(p);
836
           }
837
           else
838
           {
839
             plannedPackage.mVersion = "1.0.0000";
840
           }
841
         }
842
 
843
         if ( mConnectionString.compareTo("iteration1") == 0 
844
           || mConnectionString.compareTo("iteration2") == 0
845
           || mConnectionString.compareTo("iteration3") == 0 )
846
         {
847
           p = new Package(10, "SolarisCentricProduct", "1.0.0000.tim", ".tim", "SolarisCentricProduct.tim", "SolarisCentricProduct_1.0.0000.tim", "\\vob\\SolarisCentricProduct", 'm');
848
           p.mPid = 908;
849
           pv_id = new Integer(10);
850
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
851
           plannedPackage = findPackage(p.mAlias, packageCollection);
852
 
853
           if ( plannedPackage == NULL_PACKAGE )
854
           {
855
             packageCollection.add(p);
856
           }
857
           else
858
           {
859
             plannedPackage.mVersion = "1.0.0000";
860
           }
861
         }
862
 
863
         p = new Package(11, "LinuxCentricProduct", "1.0.0000.tim", ".tim", "LinuxCentricProduct.tim", "LinuxCentricProduct_1.0.0000.tim", "\\vob\\LinuxCentricProduct", 'x');
864
         p.mPid = 16;
865
         pv_id = new Integer(11);
866
         rippleEngine.mReleasedPvIDCollection.add(pv_id);
867
         plannedPackage = findPackage(p.mAlias, packageCollection);
868
 
869
         if ( plannedPackage == NULL_PACKAGE )
870
         {
871
           packageCollection.add(p);
872
         }
873
         else
874
         {
875
           plannedPackage.mVersion = "1.0.0000";
876
         }
877
 
878
         p = new Package(12, "Win32CentricProduct", "1.0.0000.tim", ".tim", "Win32CentricProduct.tim", "Win32CentricProduct_1.0.0000.tim", "\\vob\\Win32CentricProduct", 'x');
879
         p.mPid = 312;
880
         pv_id = new Integer(12);
881
         rippleEngine.mReleasedPvIDCollection.add(pv_id);
882
         plannedPackage = findPackage(p.mAlias, packageCollection);
883
 
884
         if ( plannedPackage == NULL_PACKAGE )
885
         {
886
           packageCollection.add(p);
887
         }
888
         else
889
         {
890
           plannedPackage.mVersion = "1.0.0000";
891
         }
892
 
893
         if ( mConnectionString.compareTo("iteration1") == 0 
894
           || mConnectionString.compareTo("iteration2") == 0
895
           || mConnectionString.compareTo("iteration3") == 0
896
           || mConnectionString.compareTo("iteration4") == 0 )
897
         {
898
           p = new Package(13, "GenericProduct", "1.0.0000.tim", ".tim", "GenericProduct.tim", "GenericProduct_1.0.0000.tim", "\\vob\\ToBeMovedFromHere", 'M');
899
           p.mPid = 6;
900
           pv_id = new Integer(13);
901
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
902
           plannedPackage = findPackage(p.mAlias, packageCollection);
903
         }
904
 
905
         if ( plannedPackage == NULL_PACKAGE )
906
         {
907
           packageCollection.add(p);
908
         }
909
         else
910
         {
911
           plannedPackage.mVersion = "1.0.0000";
912
         }
913
 
914
         p = new Package(14, "AdvisoryDependency", "1.0.0000.tim", ".tim", "AdvisoryDependency.tim", "AdvisoryDependency_1.0.0000.tim", "\\vob\\AdvisoryDependency", 'x');
915
         p.mPid = 81;
916
         pv_id = new Integer(14);
917
         rippleEngine.mReleasedPvIDCollection.add(pv_id);
918
         plannedPackage = findPackage(p.mAlias, packageCollection);
919
 
920
         if ( plannedPackage == NULL_PACKAGE )
921
         {
922
           packageCollection.add(p);
923
         }
924
         else
925
         {
926
           plannedPackage.mVersion = "1.0.0000";
927
         }
928
 
929
         if ( mConnectionString.compareTo("iteration1") == 0 
930
           || mConnectionString.compareTo("iteration2") == 0
931
           || mConnectionString.compareTo("iteration3") == 0
932
           || mConnectionString.compareTo("iteration4") == 0
933
           || mConnectionString.compareTo("iteration5") == 0
934
           || mConnectionString.compareTo("iteration6") == 0 )
935
         {
936
           p = new Package(15, "MergedProduct", "1.0.0000.tim", ".tim", "MergedProduct.tim", "MergedProduct_1.0.0000.tim", "\\vob\\MergedProduct", 'm');
937
           p.mPid = 1;
938
           pv_id = new Integer(15);
939
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
940
           plannedPackage = findPackage(p.mAlias, packageCollection);
941
         }
942
         else
943
         {
944
           p = new Package(16, "MergedProduct", "1.0.0000.tim", ".tim", "MergedProduct.tim", "MergedProduct_1.0.0000.tim", "\\vob\\MergedProduct", 'm');
945
           p.mPid = 1;
946
           pv_id = new Integer(16);
947
           rippleEngine.mReleasedPvIDCollection.add(pv_id);
948
           plannedPackage = findPackage(p.mAlias, packageCollection);
949
         }
950
 
951
         if ( plannedPackage == NULL_PACKAGE )
952
         {
953
           packageCollection.add(p);
954
         }
955
         else
956
         {
957
           plannedPackage.mVersion = "1.0.0000";
958
         }
959
 
960
        /* released dependencies
961
         * pv_id dpv_id pkg_name                     v_ext
962
         * 8     9      CommonDependency             .tim
963
         * 9     7      CotsWithFunnyVersion         .cots
964
         * 10    9      CommonDependency             .tim
965
         * 11    44     AdvisoryDependency           .tim
966
         * 13    9      CommonDependency             .tim
967
         * 15    99     CommonDependency             .tim
968
         */
969
         if ( mConnectionString.compareTo("iteration1") != 0 && mConnectionString.compareTo("iteration2") != 0 )
970
         {
971
           p = findPackage(2, packageCollection);
972
           p.mDependencyCollection.add("CotsWithFunnyVersion.cots");
973
           p.mDependencyIDCollection.add(7);
974
           p.mDependencyCollection.add("UncommonDependency.tim");
975
           p.mDependencyIDCollection.add(0);
976
         }
977
 
978
         if ( mConnectionString.compareTo("iteration1") != 0 
979
           && mConnectionString.compareTo("iteration2") != 0
980
           && mConnectionString.compareTo("iteration3") != 0 )
981
         {
982
           p = findPackage(3, packageCollection);
983
           p.mDependencyCollection.add("CommonDependency.tim");
984
           p.mDependencyIDCollection.add(2);
985
         }
986
 
987
         if ( mConnectionString.compareTo("iteration1") != 0 
988
           && mConnectionString.compareTo("iteration2") != 0
989
           && mConnectionString.compareTo("iteration3") != 0
990
           && mConnectionString.compareTo("iteration4") != 0 )
991
         {
992
           p = findPackage(4, packageCollection);
993
           p.mDependencyCollection.add("CommonDependency.tim");
994
           p.mDependencyIDCollection.add(2);
995
         }
996
 
997
         if ( mConnectionString.compareTo("iteration1") != 0 
998
           && mConnectionString.compareTo("iteration2") != 0
999
           && mConnectionString.compareTo("iteration3") != 0
1000
           && mConnectionString.compareTo("iteration4") != 0
1001
           && mConnectionString.compareTo("iteration5") != 0 )
1002
         {
1003
           p = findPackage(5, packageCollection);
1004
           p.mDependencyCollection.add("UncommonDependency.tim");
1005
           p.mDependencyIDCollection.add(0);
1006
         }
1007
 
1008
         p = findPackage(8, packageCollection);
1009
         p.mDependencyCollection.add("CommonDependency.tim");
1010
         p.mDependencyIDCollection.add(9);
1011
 
1012
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
1013
         {
1014
           p = findPackage(9, packageCollection);
1015
           p.mDependencyCollection.add("CotsWithFunnyVersion.cots");
1016
           p.mDependencyIDCollection.add(7);
1017
         }
1018
 
1019
         if ( mConnectionString.compareTo("iteration1") == 0 
1020
           || mConnectionString.compareTo("iteration2") == 0
1021
           || mConnectionString.compareTo("iteration3") == 0 )
1022
         {
1023
           p = findPackage(10, packageCollection);
1024
           p.mDependencyCollection.add("CommonDependency.tim");
1025
           p.mDependencyIDCollection.add(9);
1026
         }
1027
 
1028
         p = findPackage(11, packageCollection);
1029
         p.mDependencyCollection.add("AdvisoryDependency.tim");
1030
         p.mDependencyIDCollection.add(44);
1031
 
1032
         if ( mConnectionString.compareTo("iteration1") == 0 
1033
           || mConnectionString.compareTo("iteration2") == 0
1034
           || mConnectionString.compareTo("iteration3") == 0
1035
           || mConnectionString.compareTo("iteration4") == 0 )
1036
         {
1037
           p = findPackage(13, packageCollection);
1038
           p.mDependencyCollection.add("CommonDependency.tim");
1039
           p.mDependencyIDCollection.add(9);
1040
         }
1041
 
1042
         if ( mConnectionString.compareTo("iteration1") == 0 
1043
           || mConnectionString.compareTo("iteration2") == 0
1044
           || mConnectionString.compareTo("iteration3") == 0
1045
           || mConnectionString.compareTo("iteration4") == 0
1046
           || mConnectionString.compareTo("iteration5") == 0
1047
           || mConnectionString.compareTo("iteration6") == 0 )
1048
         {
1049
           p = findPackage(15, packageCollection);
1050
           p.mDependencyCollection.add("CommonDependency.tim");
1051
           p.mDependencyIDCollection.add(99);
1052
         }
1053
         else
1054
         {
1055
           p = findPackage(16, packageCollection);
1056
           p.mDependencyCollection.add("CommonDependency.tim");
1057
           p.mDependencyIDCollection.add(2);
1058
         }
1059
 
1060
        /* released build info
1061
         * pv_id bm_name bsa_name
1062
         * 7     Solaris Debug
1063
         * 9     Linux   Debug
1064
         * 9     Solaris Debug
1065
         * 9     Win32   Production
1066
         * 10    Solaris Java 1.4
1067
         * 11    Linux   Production and Debug
1068
         * 12    Win32   Java 1.6
1069
         * 13    Generic Java 1.4
1070
         * 14    Linux   Debug
1071
         * 15    Linux   Debug
1072
         */
1073
         if ( mConnectionString.compareTo("iteration1") != 0 )
1074
         {
1075
           p = findPackage(0, packageCollection);
1076
           bs = new BuildStandard(rippleEngine);
1077
           bs.setLinux();
1078
           bs.set1_6();
1079
           p.mBuildStandardCollection.add(bs);
1080
         }
1081
 
1082
         if ( mConnectionString.compareTo("iteration1") != 0 && mConnectionString.compareTo("iteration2") != 0 )
1083
         {
1084
           p = findPackage(2, packageCollection);
1085
           bs = new BuildStandard(rippleEngine);
1086
           bs.setLinux();
1087
           bs.setDebug();
1088
           p.mBuildStandardCollection.add(bs);
1089
           bs = new BuildStandard(rippleEngine);
1090
           bs.setSolaris();
1091
           bs.setProduction();
1092
           p.mBuildStandardCollection.add(bs);
1093
           bs = new BuildStandard(rippleEngine);
1094
           bs.setWin32();
1095
           bs.setAll();
1096
           p.mBuildStandardCollection.add(bs);
1097
         }
1098
 
1099
         if ( mConnectionString.compareTo("iteration1") != 0 
1100
           && mConnectionString.compareTo("iteration2") != 0
1101
           && mConnectionString.compareTo("iteration3") != 0 )
1102
         {
1103
           p = findPackage(3, packageCollection);
1104
           bs = new BuildStandard(rippleEngine);
1105
           bs.setSolaris();
1106
           bs.set1_4();
1107
           p.mBuildStandardCollection.add(bs);
1108
         }
1109
 
1110
         if ( mConnectionString.compareTo("iteration1") != 0 
1111
           && mConnectionString.compareTo("iteration2") != 0
1112
           && mConnectionString.compareTo("iteration3") != 0
1113
           && mConnectionString.compareTo("iteration4") != 0 )
1114
         {
1115
           p = findPackage(4, packageCollection);
1116
           bs = new BuildStandard(rippleEngine);
1117
           bs.setGeneric();
1118
           bs.set1_5();
1119
           p.mBuildStandardCollection.add(bs);
1120
         }
1121
 
1122
         if ( mConnectionString.compareTo("iteration1") != 0 
1123
           && mConnectionString.compareTo("iteration2") != 0
1124
           && mConnectionString.compareTo("iteration3") != 0
1125
           && mConnectionString.compareTo("iteration4") != 0
1126
           && mConnectionString.compareTo("iteration5") != 0 )
1127
         {
1128
           p = findPackage(5, packageCollection);
1129
           bs = new BuildStandard(rippleEngine);
1130
           bs.setLinux();
1131
           bs.set1_6();
1132
           p.mBuildStandardCollection.add(bs);
1133
           bs = new BuildStandard(rippleEngine);
1134
           bs.setWin32();
1135
           bs.set1_6();
1136
           p.mBuildStandardCollection.add(bs);
1137
         }
1138
 
1139
         p = findPackage(7, packageCollection);
1140
         bs = new BuildStandard(rippleEngine);
1141
         bs.setSolaris();
1142
         bs.setDebug();
1143
         p.mBuildStandardCollection.add(bs);
1144
 
1145
         if ( mConnectionString.compareTo("iteration1") == 0 || mConnectionString.compareTo("iteration2") == 0 )
1146
         {
1147
           p = findPackage(9, packageCollection);
1148
           bs = new BuildStandard(rippleEngine);
1149
           bs.setLinux();
1150
           bs.setDebug();
1151
           p.mBuildStandardCollection.add(bs);
1152
           bs = new BuildStandard(rippleEngine);
1153
           bs.setSolaris();
1154
           bs.setDebug();
1155
           p.mBuildStandardCollection.add(bs);
1156
           bs = new BuildStandard(rippleEngine);
1157
           bs.setWin32();
1158
           bs.setProduction();
1159
           p.mBuildStandardCollection.add(bs);
1160
         }
1161
 
1162
         if ( mConnectionString.compareTo("iteration1") == 0 
1163
           || mConnectionString.compareTo("iteration2") == 0
1164
           || mConnectionString.compareTo("iteration3") == 0 )
1165
         {
1166
           p = findPackage(10, packageCollection);
1167
           bs = new BuildStandard(rippleEngine);
1168
           bs.setSolaris();
1169
           bs.set1_4();
1170
           p.mBuildStandardCollection.add(bs);
1171
         }
1172
 
1173
         p = findPackage(11, packageCollection);
1174
         bs = new BuildStandard(rippleEngine);
1175
         bs.setLinux();
1176
         bs.setAll();
1177
         p.mBuildStandardCollection.add(bs);
1178
 
1179
         p = findPackage(12, packageCollection);
1180
         bs = new BuildStandard(rippleEngine);
1181
         bs.setWin32();
1182
         bs.set1_6();
1183
         p.mBuildStandardCollection.add(bs);
1184
 
1185
         if ( mConnectionString.compareTo("iteration1") == 0 
1186
           || mConnectionString.compareTo("iteration2") == 0
1187
           || mConnectionString.compareTo("iteration3") == 0
1188
           || mConnectionString.compareTo("iteration4") == 0 )
1189
         {
1190
           p = findPackage(13, packageCollection);
1191
           bs = new BuildStandard(rippleEngine);
1192
           bs.setGeneric();
1193
           bs.set1_4();
1194
           p.mBuildStandardCollection.add(bs);
1195
         }
1196
 
1197
         p = findPackage(14, packageCollection);
1198
         bs = new BuildStandard(rippleEngine);
1199
         bs.setLinux();
1200
         bs.setDebug();
1201
         p.mBuildStandardCollection.add(bs);
1202
 
1203
         if ( mConnectionString.compareTo("iteration1") == 0 
1204
           || mConnectionString.compareTo("iteration2") == 0
1205
           || mConnectionString.compareTo("iteration3") == 0
1206
           || mConnectionString.compareTo("iteration4") == 0
1207
           || mConnectionString.compareTo("iteration5") == 0
1208
           || mConnectionString.compareTo("iteration6") == 0 )
1209
         {
1210
           p = findPackage(15, packageCollection);
1211
           bs = new BuildStandard(rippleEngine);
1212
           bs.setLinux();
1213
           bs.setDebug();
1214
           p.mBuildStandardCollection.add(bs);
1215
         }
1216
         else
1217
         {
1218
           p = findPackage(16, packageCollection);
1219
           bs = new BuildStandard(rippleEngine);
1220
           bs.setLinux();
1221
           bs.setDebug();
1222
           p.mBuildStandardCollection.add(bs);
1223
         }
1224
 
1225
        /* released package unit test info
1226
         * pv_id tt.test_type_name
1227
         * 9     Manual Test
1228
         * 9     Interactive Test
1229
         * 9     Integration Test
1230
         * 11    Autobuild UTF
1231
         */
1232
         if ( mConnectionString.compareTo("iteration1") != 0 
1233
           && mConnectionString.compareTo("iteration2") != 0
1234
           && mConnectionString.compareTo("iteration3") != 0
1235
           && mConnectionString.compareTo("iteration4") != 0
1236
           && mConnectionString.compareTo("iteration5") != 0 )
1237
         {
1238
           p = findPackage(5, packageCollection);
1239
           p.mHasAutomatedUnitTests = true;
1240
         }
1241
 
1242
         p = findPackage(11, packageCollection);
1243
         p.mHasAutomatedUnitTests = true;
1244
 
1245
        /* released build failure email info
1246
         * pv_id user_email
1247
         * 10    jimmyfishcake@erggroup.com
1248
         */
1249
         if ( mConnectionString.compareTo("iteration1") != 0 
1250
           && mConnectionString.compareTo("iteration2") != 0
1251
           && mConnectionString.compareTo("iteration3") != 0 )
1252
         {
1253
           p = findPackage(3, packageCollection);
864 mhunt 1254
           p.addEmail("jimmyfishcake@erggroup.com");
1255
           p.addEmail("rayhaddock@erggroup.com");
814 mhunt 1256
         }
1257
 
1258
         if ( mConnectionString.compareTo("iteration1") != 0 
1259
           && mConnectionString.compareTo("iteration2") != 0
1260
           && mConnectionString.compareTo("iteration3") != 0
1261
           && mConnectionString.compareTo("iteration4") != 0
1262
           && mConnectionString.compareTo("iteration5") != 0 )
1263
         {
1264
           p = findPackage(5, packageCollection);
864 mhunt 1265
           p.addEmail("timbutdim@erggroup.com");
814 mhunt 1266
         }
1267
 
1268
         if ( mConnectionString.compareTo("iteration1") == 0 
1269
           || mConnectionString.compareTo("iteration2") == 0
1270
           || mConnectionString.compareTo("iteration3") == 0 )
1271
         {
1272
           p = findPackage(10, packageCollection);
864 mhunt 1273
           p.addEmail("jimmyfishcake@erggroup.com");
814 mhunt 1274
         }
1275
 
1276
        /* released advisory ripple info
1277
         * pv_id
1278
         * 14
1279
         */
1280
         if ( mConnectionString.compareTo("iteration1") != 0 )
1281
         {
1282
           p = findPackage(0, packageCollection);
1283
           p.mAdvisoryRipple = true;
1284
         }
1285
 
1286
         p = findPackage(14, packageCollection);
1287
         p.mAdvisoryRipple = true;
1288
      }
1289
      else
1290
      {
1291
        /* prod_id pkg_name                pkg_version  v_ext pkg_label                           src_path
1292
         * 8       NotInAnyWayReproducible 1.0.0.tim    .tim  NA                                  NA
1293
         * 10      SolarisCentricProduct   1.0.0000.tim .tim  SolarisCentricProduct_1.0.0000.tim  \vob\SolarisCentricProduct
1294
         * 11      LinuxCentricProduct     1.0.0000.tim .tim  LinuxCentricProduct_1.0.0000.tim    \vob\LinuxCentricProduct
1295
         * 12      Win32CentricProduct     1.0.0000.tim .tim  Win32CentricProduct_1.0.0000.tim    \vob\Win32CentricProduct
1296
         * 13      GenericProduct          1.0.0000.tim .tim  GenericProduct_1.0.0000.tim         \vob\ToBeMovedFromHere
1297
         */
1298
         Package p = new Package(8, "NotInAnyWayReproducible", "1.0.0.tim", ".tim", "NotInAnyWayReproducible.1.0.0.tim", "NA", "NA", 'x');
1299
         packageCollection.add(p);
1300
         p = new Package(10, "SolarisCentricProduct", "1.0.0000.tim", ".tim", "SolarisCentricProduct.1.0.0000.tim", "SolarisCentricProduct_1.0.0000.tim", "\\vob\\SolarisCentricProduct", 'x');
1301
         packageCollection.add(p);
1302
         p = new Package(11, "LinuxCentricProduct", "1.0.0000.tim", ".tim", "LinuxCentricProduct.1.0.0000.tim", "LinuxCentricProduct_1.0.0000.tim", "\\vob\\LinuxCentricProduct", 'x');
1303
         packageCollection.add(p);
1304
         p = new Package(12, "Win32CentricProduct", "1.0.0000.tim", ".tim", "Win32CentricProduct.1.0.0000.tim", "Win32CentricProduct_1.0.0000.tim", "\\vob\\Win32CentricProduct", 'x');
1305
         packageCollection.add(p);
1306
         p = new Package(13, "GenericProduct", "1.0.0000.tim", ".tim", "GenericProduct.1.0.0000.tim", "GenericProduct_1.0.0000.tim", "\\vob\\ToBeMovedFromHere", 'x');
1307
         packageCollection.add(p);
1308
 
1309
        /* the above products have the following dependencies which will be discovered in traverseDependencies
1310
         * pv_id   pkg_name, dpv.pkg_version, dpv.v_ext, dpv.pkg_label, dpv.src_path
1311
         * 7     CotsWithFunnyVersion         hoopla2_x.cots   .cots CotsWithFunnyVersion_hoopla2_x.cots \vob\CotsWithFunnyVersion
1312
         * 9     CommonDependency             1.0.0000.tim     .tim  CommonDependency_1.0.0000.tim       \vob\CommonDependency
1313
         * 14    AdvisoryDependency           1.0.0000.tim     .tim  AdvisoryDependency_1.0.0000.tim     \vob\AdvisoryDependency
1314
         * the above packages have the following build info
1315
         * pv_id bm_name bsa_name
1316
         * 7     Solaris Debug
1317
         * 9     Linux   Debug
1318
         * 9     Solaris Debug
1319
         * 9     Win32   Production
1320
         * 10    Solaris Java 1.4
1321
         * 11    Linux   Production and Debug
1322
         * 12    Win32   Java 1.6
1323
         * 13    Generic Java 1.4
1324
         * 14    Linux   Debug
1325
         */
1326
      }
1327
    }
1328
    else
1329
    {
1330
      try
1331
      {
1332
        if (daemonMode)
1333
        {
864 mhunt 1334
          Vector<String> globalAndProjectWideBuildFailureEmailCollection = new Vector<String>();
868 mhunt 1335
          globalAndProjectWideBuildFailureEmailCollection.add(queryGlobalAddresses());
864 mhunt 1336
 
1337
          CallableStatement stmt0 = mConnection.prepareCall(
1338
          "select u.user_email " +
1339
          "from release_manager.autobuild_failure af, release_manager.members_group mg, release_manager.users u, release_manager.views v, release_manager.release_tags rt " +
1340
          "where rt.rtag_id=" + baseline + " " +
1341
          "and v.view_name='PROJECT WIDE' " +
1342
          "and af.proj_id=rt.proj_id " +
1343
          "and af.view_id=v.view_id " +
1344
          "and mg.group_email_id=af.group_email_id " +
1345
          "and u.user_id=mg.user_id"
1346
          );
1347
          ResultSet rset0 = stmt0.executeQuery();
1348
 
1349
          while( rset0.next() )
1350
          {
1351
            String email = rset0.getString("user_email");
1352
 
1353
            if ( email != null )
1354
            {
1355
              globalAndProjectWideBuildFailureEmailCollection.add(email);
1356
            }
1357
          }
1358
 
1359
          rset0.close();
1360
          stmt0.close();
1361
 
814 mhunt 1362
          // get planned package info
1363
          CallableStatement stmt1 = mConnection.prepareCall(
1364
          "select pl.pv_id, p.pkg_id, p.pkg_name, pv.v_ext, pv.pkg_label, pv.src_path, pv.change_type " +
1365
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.packages p " +
1366
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1367
          "and pv.pv_id=pl.pv_id and p.pkg_id=pv.pkg_id " +
1368
          "order by pl.pv_id"
1369
          );
1370
          ResultSet rset1 = stmt1.executeQuery();
1371
 
1372
          while( rset1.next() )
1373
          {
1374
            int pv_id = rset1.getInt("pv_id");
1375
 
1376
            if ( rset1.wasNull() )
1377
            {
1378
              mLogger.fatal("queryPackageVersions rset1 null pv_id");
1379
              // show stopper
868 mhunt 1380
              throw new Exception("queryPackageVersions rset1 null pv_id");
814 mhunt 1381
            }
1382
 
1383
            int pkg_id = rset1.getInt("pkg_id");
1384
 
1385
            if ( rset1.wasNull() )
1386
            {
1387
              mLogger.fatal("queryPackageVersions rset1 null pkg_id " + pv_id);
1388
              // show stopper
868 mhunt 1389
              throw new Exception("queryPackageVersions rset1 null pkg_id " + pv_id);
814 mhunt 1390
            }
1391
 
1392
            String pkg_name = rset1.getString("pkg_name");
1393
 
1394
            if ( pkg_name == null )
1395
            {
1396
              mLogger.fatal("queryPackageVersions rset1 null pkg_name " + pv_id);
1397
              // show stopper
868 mhunt 1398
              throw new Exception("queryPackageVersions rset1 null pkg_name " + pv_id);
814 mhunt 1399
            }
1400
 
1401
            String v_ext = rset1.getString("v_ext");
1402
 
1403
            if ( v_ext == null )
1404
            {
1405
              v_ext = "";
1406
            }
1407
 
1408
            String pkg_label = rset1.getString("pkg_label");
1409
 
1410
            if ( pkg_label == null )
1411
            {
1412
              pkg_label = "NA";
1413
            }
1414
 
1415
            String src_path = rset1.getString("src_path");
1416
 
1417
            if ( src_path == null )
1418
            {
1419
              src_path = "NA";
1420
            }
1421
 
1422
            String change_type = rset1.getString("change_type");
1423
 
1424
            if ( change_type == null )
1425
            {
1426
              change_type = "P";
1427
            }
1428
 
1429
            char ct = 'x';
1430
 
1431
            if ( change_type.compareTo("M") == 0 )
1432
            {
1433
              ct = 'M';
1434
            }
1435
            else if ( change_type.compareTo("N") == 0 )
1436
            {
1437
              ct = 'N';
1438
            }
1439
            else if ( change_type.compareTo("P") == 0 )
1440
            {
1441
              ct = 'P';
1442
            }
1443
 
1444
            if ( ct != 'x' )
1445
            {
1446
              Package p = new Package(pv_id, pkg_name, v_ext, pkg_name + v_ext, pkg_label, src_path, ct);
1447
              p.mPid = pkg_id;
1448
              p.mDirectlyPlanned = true;
1449
              packageCollection.add(p);
1450
            }
1451
          }
830 mhunt 1452
 
1453
          rset1.close();
1454
          stmt1.close();
814 mhunt 1455
 
1456
          // get planned package dependency info
1457
          CallableStatement stmt2 = mConnection.prepareCall(
1458
          "select pl.pv_id, p.pkg_name, dpv.v_ext " +
1459
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p " +
1460
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1461
          "and pv.pv_id = pl.pv_id and pd.pv_id=pl.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id " +
1462
          "order by pl.pv_id"
1463
          );
1464
          ResultSet rset2 = stmt2.executeQuery();
1465
 
1466
          while( rset2.next() )
1467
          {
1468
            boolean ignore = false;
1469
 
1470
            int pv_id = rset2.getInt("pv_id");
1471
 
1472
            if ( rset2.wasNull() )
1473
            {
1474
              mLogger.fatal("queryPackageVersions rset2 null pv_id");
1475
              // show stopper
868 mhunt 1476
              throw new Exception("queryPackageVersions rset2 null pv_id");
814 mhunt 1477
            }
1478
 
1479
            Package p = findPackage(pv_id, packageCollection);
1480
 
1481
            if ( p == NULL_PACKAGE )
1482
            {
1483
              mLogger.info("queryPackageVersions rset2 highly unlikely " + pv_id);
1484
              // highly unlikely but package may have been added in between queries
1485
              ignore = true;
1486
            }
1487
 
1488
            String pkg_name = rset2.getString("pkg_name");
1489
 
1490
            if ( pkg_name == null )
1491
            {
1492
              mLogger.fatal("queryPackageVersions rset2 null pkg_name " + pv_id);
1493
              // show stopper
868 mhunt 1494
              throw new Exception("queryPackageVersions rset2 null pkg_name " + pv_id);
814 mhunt 1495
            }
1496
 
1497
            String v_ext = rset2.getString("v_ext");
1498
 
1499
            if ( v_ext == null )
1500
            {
1501
              v_ext = "";
1502
            }
1503
 
1504
            if ( !ignore )
1505
            {
1506
              p.mDependencyCollection.add(pkg_name + v_ext);
1507
              p.mDependencyIDCollection.add(-1);
1508
            }
1509
          }
1510
 
830 mhunt 1511
          rset2.close();
1512
          stmt2.close();
1513
 
814 mhunt 1514
          // get planned package build info
1515
          CallableStatement stmt3 = mConnection.prepareCall(
1516
          "select pl.pv_id, bm.bm_name, bsa.bsa_name " +
1517
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa " +
1518
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1519
          "and pv.pv_id = pl.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id " +
1520
          "order by pl.pv_id"
1521
          );
1522
          ResultSet rset3 = stmt3.executeQuery();
1523
 
1524
          while( rset3.next() )
1525
          {
1526
            boolean ignore = false;
1527
            int pv_id = rset3.getInt("pv_id");
1528
 
1529
            if ( rset3.wasNull() )
1530
            {
1531
              mLogger.fatal("queryPackageVersions rset3 null pv_id");
1532
              // show stopper
868 mhunt 1533
              throw new Exception("queryPackageVersions rset3 null pv_id");
814 mhunt 1534
            }
1535
 
1536
            Package p = findPackage(pv_id, packageCollection);
1537
 
1538
            if ( p == NULL_PACKAGE )
1539
            {
1540
              mLogger.info("queryPackageVersions rset3 highly unlikely " + pv_id);
1541
              // highly unlikely but package may have been added in between queries
1542
              ignore = true;
1543
            }
1544
 
1545
            String bm_name = rset3.getString("bm_name");
1546
 
1547
            if ( bm_name == null )
1548
            {
1549
              mLogger.fatal("queryPackageVersions rset3 null bm_name " + pv_id);
1550
              // show stopper
868 mhunt 1551
              throw new Exception("queryPackageVersions rset3 null bm_name " + pv_id);
814 mhunt 1552
            }
1553
 
1554
            String bsa_name = rset3.getString("bsa_name");
1555
 
1556
            if ( bsa_name == null )
1557
            {
1558
              mLogger.fatal("queryPackageVersions rset3 null bsa_name " + pv_id);
1559
              // show stopper
868 mhunt 1560
              throw new Exception("queryPackageVersions rset3 null bsa_name " + pv_id);
814 mhunt 1561
            }
1562
 
1563
            if ( !ignore )
1564
            {
1565
              boolean supportedBuildStandard = true;
1566
              BuildStandard bs = new BuildStandard(rippleEngine);
1567
 
1568
              if ( bm_name.compareTo("Solaris") == 0 )
1569
              {
1570
                bs.setSolaris();
1571
              }
1572
              else if ( bm_name.compareTo("Win32") == 0 )
1573
              {
1574
                bs.setWin32();
1575
              }
1576
              else if ( bm_name.compareTo("Linux") == 0 )
1577
              {
1578
                bs.setLinux();
1579
              }
1580
              else if ( bm_name.compareTo("Generic") == 0 )
1581
              {
1582
                bs.setGeneric();
1583
              }
1584
              else
1585
              {
1586
                supportedBuildStandard = false;
1587
              }
1588
 
1589
              if ( bsa_name.compareTo("Production") == 0 )
1590
              {
1591
                bs.setProduction();
1592
              }
1593
              else if ( bsa_name.compareTo("Debug") == 0 )
1594
              {
1595
                bs.setDebug();
1596
              }
1597
              else if ( bsa_name.compareTo("Production and Debug") == 0 )
1598
              {
1599
                bs.setAll();
1600
              }
1601
              else if ( bsa_name.compareTo("Java 1.4") == 0 )
1602
              {
1603
                bs.set1_4();
1604
              }
1605
              else if ( bsa_name.compareTo("Java 1.5") == 0 )
1606
              {
1607
                bs.set1_5();
1608
              }
1609
              else if ( bsa_name.compareTo("Java 1.6") == 0 )
1610
              {
1611
                bs.set1_6();
1612
              }
1613
              else
1614
              {
1615
                supportedBuildStandard = false;
1616
              }
1617
 
1618
              if ( supportedBuildStandard )
1619
              {
1620
                p.mBuildStandardCollection.add(bs);
1621
              }
1622
            }
1623
          }
830 mhunt 1624
 
1625
          rset3.close();
1626
          stmt3.close();
814 mhunt 1627
 
1628
          // get planned package unit test info
1629
          CallableStatement stmt4 = mConnection.prepareCall(
1630
          "select pl.pv_id, tt.test_type_name " +
1631
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.unit_tests ut, release_manager.test_types tt " +
1632
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1633
          "and pv.pv_id = pl.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk " +
1634
          "order by pl.pv_id"
1635
          );
1636
          ResultSet rset4 = stmt4.executeQuery();
1637
 
1638
          while( rset4.next() )
1639
          {
1640
            boolean ignore = false;
1641
 
1642
            int pv_id = rset4.getInt("pv_id");
1643
 
1644
            if ( rset4.wasNull() )
1645
            {
1646
              mLogger.fatal("queryPackageVersions rset4 null pv_id");
1647
              // show stopper
868 mhunt 1648
              throw new Exception("queryPackageVersions rset4 null pv_id");
814 mhunt 1649
            }
1650
 
1651
            Package p = findPackage(pv_id, packageCollection);
1652
 
1653
            if ( p == NULL_PACKAGE )
1654
            {
1655
              mLogger.info("queryPackageVersions rset4 highly unlikely " + pv_id);
1656
              // highly unlikely but package may have been added in between queries
1657
              ignore = true;
1658
            }
1659
 
1660
            String test_type_name = rset4.getString("test_type_name");
1661
 
1662
            if ( test_type_name == null )
1663
            {
1664
              mLogger.fatal("queryPackageVersions rset4 null test_type_name " + pv_id);
1665
              // show stopper
868 mhunt 1666
              throw new Exception("queryPackageVersions rset4 null test_type_name " + pv_id);
814 mhunt 1667
            }
1668
 
1669
            if ( !ignore )
1670
            {
1671
              if ( test_type_name.compareTo("Autobuild UTF") == 0 )
1672
              {
1673
                p.mHasAutomatedUnitTests = true;
1674
              }
1675
            }
1676
          }
830 mhunt 1677
 
1678
          rset4.close();
1679
          stmt4.close();
814 mhunt 1680
 
864 mhunt 1681
          // get planned package build failure info...
1682
          // global and project wide based
1683
          CallableStatement stmt50 = mConnection.prepareCall(
1684
          "select pl.pv_id " +
1685
          "from release_manager.planned pl, release_manager.release_tags rt, release_manager.package_versions pv " +
1686
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1687
          "and pv.pv_id = pl.pv_id " +
1688
          "order by pl.pv_id"
1689
          );
1690
          ResultSet rset50 = stmt50.executeQuery();
1691
 
1692
          while( rset50.next() )
1693
          {
1694
            int pv_id = rset50.getInt("pv_id");
1695
 
1696
            if ( rset50.wasNull() )
1697
            {
1698
              mLogger.fatal("queryPackageVersions rset50 null pv_id");
1699
              // show stopper
868 mhunt 1700
              throw new Exception("queryPackageVersions rset50 null pv_id");
864 mhunt 1701
            }
1702
 
1703
            Package p = findPackage(pv_id, packageCollection);
1704
 
1705
            if ( p == NULL_PACKAGE )
1706
            {
1707
              mLogger.info("queryPackageVersions rset50 highly unlikely " + pv_id);
1708
              // highly unlikely but package may have been added in between queries
1709
            }
1710
            else
1711
            {
1712
              for (Iterator<String> it = globalAndProjectWideBuildFailureEmailCollection.iterator(); it.hasNext(); )
1713
              {
1714
                p.addEmail(it.next());
1715
              }
1716
            }
1717
          }
1718
 
1719
          rset50.close();
1720
          stmt50.close();
1721
 
1722
          // view based
814 mhunt 1723
          CallableStatement stmt5 = mConnection.prepareCall(
1724
          "select pl.pv_id, u.user_email " +
1725
          "from release_manager.planned pl, release_manager.release_tags rt, release_manager.package_versions pv, release_manager.autobuild_failure af, release_manager.members_group mg, release_manager.users u " +
1726
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1727
          "and pv.pv_id = pl.pv_id and af.view_id=pl.view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id " +
1728
          "order by pl.pv_id"
1729
          );
1730
          ResultSet rset5 = stmt5.executeQuery();
1731
 
1732
          while( rset5.next() )
1733
          {
1734
            int pv_id = rset5.getInt("pv_id");
1735
 
1736
            if ( rset5.wasNull() )
1737
            {
1738
              mLogger.fatal("queryPackageVersions rset5 null pv_id");
1739
              // show stopper
868 mhunt 1740
              throw new Exception("queryPackageVersions rset5 null pv_id");
814 mhunt 1741
            }
1742
 
1743
            Package p = findPackage(pv_id, packageCollection);
1744
 
1745
            if ( p == NULL_PACKAGE )
1746
            {
1747
              mLogger.info("queryPackageVersions rset5 highly unlikely " + pv_id);
1748
              // highly unlikely but package may have been added in between queries
1749
            }
864 mhunt 1750
            else
1751
            {
1752
              String user_email = rset5.getString("user_email");
814 mhunt 1753
 
864 mhunt 1754
              if ( user_email != null )
1755
              {
1756
                p.addEmail(user_email);
1757
              }
1758
            }
1759
          }
1760
 
1761
          rset5.close();
1762
          stmt5.close();
1763
 
1764
          // package version
1765
          CallableStatement stmt51 = mConnection.prepareCall(
1766
          "select pl.pv_id, u1.user_email, u2.user_email, u3.user_email " +
1767
          "from release_manager.planned pl, release_manager.release_tags rt, release_manager.package_versions pv, release_manager.users u1, release_manager.users u2, release_manager.users u3 " +
1768
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1769
          "and pv.pv_id = pl.pv_id and u1.user_id=pv.creator_id and u2.user_id=pv.owner_id and u3.user_id=pv.modifier_id " +
1770
          "order by pl.pv_id"
1771
          );
1772
          ResultSet rset51 = stmt51.executeQuery();
814 mhunt 1773
 
864 mhunt 1774
          while( rset51.next() )
1775
          {
1776
            int pv_id = rset51.getInt("pv_id");
1777
 
1778
            if ( rset51.wasNull() )
814 mhunt 1779
            {
864 mhunt 1780
              mLogger.fatal("queryPackageVersions rset51 null pv_id");
1781
              // show stopper
868 mhunt 1782
              throw new Exception("queryPackageVersions rset51 null pv_id");
814 mhunt 1783
            }
1784
 
864 mhunt 1785
            Package p = findPackage(pv_id, packageCollection);
1786
 
1787
            if ( p == NULL_PACKAGE )
814 mhunt 1788
            {
864 mhunt 1789
              mLogger.info("queryPackageVersions rset51 highly unlikely " + pv_id);
1790
              // highly unlikely but package may have been added in between queries
814 mhunt 1791
            }
864 mhunt 1792
            else
1793
            {
1794
 
1795
              // walk the 3 columns of user_email in the resultset
1796
              // columns 2, 3 and 4, all of the same name, repectively
1797
              for(int column=2; column<5; column++ )
1798
              {
1799
                String user_email = rset51.getString(column);
1800
 
1801
                if ( user_email != null )
1802
                {
1803
                  p.addEmail(user_email);
1804
                }
1805
              }
1806
            }
814 mhunt 1807
          }
830 mhunt 1808
 
864 mhunt 1809
          rset51.close();
1810
          stmt51.close();
814 mhunt 1811
 
1812
          // get planned package advisory ripple info
1813
          CallableStatement stmt7 = mConnection.prepareCall(
1814
          "select pl.pv_id " +
1815
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.advisory_ripple ar " +
1816
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1817
          "and pv.pv_id = pl.pv_id and ar.rtag_id=pl.rtag_id and ar.pv_id=pl.pv_id " +
1818
          "order by pl.pv_id"
1819
          );
1820
          ResultSet rset7 = stmt7.executeQuery();
1821
 
1822
          while( rset7.next() )
1823
          {
1824
            boolean ignore = false;
1825
 
1826
            int pv_id = rset7.getInt("pv_id");
1827
 
1828
            if ( rset7.wasNull() )
1829
            {
1830
              mLogger.fatal("queryPackageVersions rset7 null pv_id");
1831
              // show stopper
868 mhunt 1832
              throw new Exception("queryPackageVersions rset7 null pv_id");
814 mhunt 1833
            }
1834
 
1835
            Package p = findPackage(pv_id, packageCollection);
1836
 
1837
            if ( p == NULL_PACKAGE )
1838
            {
1839
              mLogger.info("queryPackageVersions rset7 highly unlikely " + pv_id);
1840
              // highly unlikely but package may have been added in between queries
1841
              ignore = true;
1842
            }
1843
 
1844
            if ( !ignore )
1845
            {
1846
              p.mAdvisoryRipple = true;
1847
            }
1848
          }
1849
 
830 mhunt 1850
          rset7.close();
1851
          stmt7.close();
1852
 
814 mhunt 1853
          // get released package info
1854
          CallableStatement stmt8 = mConnection.prepareCall(
1855
          "select rc.pv_id, p.pkg_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_label, pv.src_path, pv.ripple_field " +
1856
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.packages p " +
1857
          "where rc.rtag_id=" + baseline +
1858
          " and pv.pv_id = rc.pv_id and p.pkg_id = pv.pkg_id " +
1859
          "order by rc.pv_id"
1860
          );
1861
          ResultSet rset8 = stmt8.executeQuery();
1862
 
1863
          while( rset8.next() )
1864
          {
1865
            int pv_id = rset8.getInt("pv_id");
1866
 
1867
            if ( rset8.wasNull() )
1868
            {
1869
              mLogger.fatal("queryPackageVersions rset8 null pv_id");
1870
              // show stopper
868 mhunt 1871
              throw new Exception("queryPackageVersions rset8 null pv_id");
814 mhunt 1872
            }
1873
 
1874
            int pkg_id = rset8.getInt("pkg_id");
1875
 
1876
            if ( rset8.wasNull() )
1877
            {
1878
              mLogger.fatal("queryPackageVersions rset8 null pkg_id " + pv_id);
1879
              // show stopper
868 mhunt 1880
              throw new Exception("queryPackageVersions rset8 null pkg_id " + pv_id);
814 mhunt 1881
            }
1882
 
1883
            String pkg_name = rset8.getString("pkg_name");
1884
 
1885
            if ( pkg_name == null )
1886
            {
1887
              mLogger.fatal("queryPackageVersions rset8 null pkg_name " + pv_id);
1888
              // show stopper
868 mhunt 1889
              throw new Exception("queryPackageVersions rset8 null pkg_name " + pv_id);
814 mhunt 1890
            }
1891
 
1892
            String pkg_version = rset8.getString("pkg_version");
1893
 
1894
            if ( pkg_version == null )
1895
            {
1896
              mLogger.fatal("queryPackageVersions rset8 null pkg_version " + pv_id);
1897
              // show stopper
868 mhunt 1898
              throw new Exception("queryPackageVersions rset8 null pkg_version " + pv_id);
814 mhunt 1899
            }
1900
 
1901
            String v_ext = rset8.getString("v_ext");
1902
 
1903
            if ( v_ext == null )
1904
            {
1905
              v_ext = "";
1906
            }
1907
 
1908
            String pkg_label = rset8.getString("pkg_label");
1909
 
1910
            if ( pkg_label == null )
1911
            {
1912
              pkg_label = "NA";
1913
            }
1914
 
1915
            String src_path = rset8.getString("src_path");
1916
 
1917
            if ( src_path == null )
1918
            {
1919
              src_path = "NA";
1920
            }
1921
 
1922
            String ripple_field = rset8.getString("ripple_field");
1923
 
1924
            if ( ripple_field == null )
1925
            {
1926
              ripple_field = "x";
1927
            }
1928
            else if ( ripple_field.length() == 0 )
1929
            {
1930
              ripple_field = "x";
1931
            }
1932
 
1933
            Package p = new Package(pv_id, pkg_name, pkg_version, v_ext, pkg_name + v_ext, pkg_label, src_path, ripple_field.charAt(0));
1934
            p.mPid = pkg_id;
1935
            Integer ipv_id = new Integer(pv_id);
1936
            rippleEngine.mReleasedPvIDCollection.add(ipv_id);
1937
            Package plannedPackage = findPackage(p.mAlias, packageCollection);
1938
 
1939
            if ( plannedPackage == NULL_PACKAGE )
1940
            {
1941
              mLogger.info("queryPackageVersions rset8 no planned package " + pv_id);
1942
              packageCollection.add(p);
1943
            }
1944
            else
1945
            {
1946
              int endindex = pkg_version.length() - v_ext.length();
1947
 
1948
              if ( endindex > 0 )
1949
              {
1950
                pkg_version = pkg_version.substring(0, endindex);
1951
              }
1952
 
1953
              plannedPackage.mVersion = pkg_version;
1954
            }
1955
          }
830 mhunt 1956
 
1957
          rset8.close();
1958
          stmt8.close();
814 mhunt 1959
 
1960
          // get released package dependency info
1961
          CallableStatement stmt9 = mConnection.prepareCall(
1962
          "select rc.pv_id, dpv.pv_id, p.pkg_name, dpv.v_ext " +
1963
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p " +
1964
          "where rc.rtag_id=" + baseline +
1965
          " and pv.pv_id = rc.pv_id and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id " +
1966
          "order by rc.pv_id"
1967
          );
1968
          ResultSet rset9 = stmt9.executeQuery();
1969
 
1970
          while( rset9.next() )
1971
          {
1972
            boolean ignore = false;
1973
 
1974
            int pv_id = rset9.getInt(1);
1975
 
1976
            if ( rset9.wasNull() )
1977
            {
1978
              mLogger.fatal("queryPackageVersions rset9 null pv_id");
1979
              // show stopper
868 mhunt 1980
              throw new Exception("queryPackageVersions rset9 null pv_id");
814 mhunt 1981
            }
1982
 
1983
            int dpv_id = rset9.getInt(2);
1984
 
1985
            if ( rset9.wasNull() )
1986
            {
1987
              mLogger.fatal("queryPackageVersions rset9 null dpv_id " + pv_id);
1988
              // show stopper
868 mhunt 1989
              throw new Exception("queryPackageVersions rset9 null dpv_id " + pv_id);
814 mhunt 1990
            }
1991
 
1992
            Package p = findPackage(pv_id, packageCollection);
1993
 
1994
            if ( p == NULL_PACKAGE )
1995
            {
1996
              mLogger.info("queryPackageVersions rset9 package may have been superceded by planned " + pv_id);
1997
              ignore = true;
1998
            }
1999
 
2000
            String pkg_name = rset9.getString("pkg_name");
2001
 
2002
            if ( pkg_name == null )
2003
            {
2004
              mLogger.fatal("queryPackageVersions rset9 null pkg_name " + pv_id);
2005
              // show stopper
868 mhunt 2006
              throw new Exception("queryPackageVersions rset9 null pkg_name " + pv_id);
814 mhunt 2007
            }
2008
 
2009
            String v_ext = rset9.getString("v_ext");
2010
 
2011
            if ( v_ext == null )
2012
            {
2013
              v_ext = "";
2014
            }
2015
 
2016
            if ( !ignore )
2017
            {
2018
              p.mDependencyCollection.add(pkg_name + v_ext);
2019
              p.mDependencyIDCollection.add(dpv_id);
2020
            }
2021
          }
830 mhunt 2022
 
2023
          rset9.close();
2024
          stmt9.close();
814 mhunt 2025
 
2026
          // get released package build info
2027
          CallableStatement stmt10 = mConnection.prepareCall(
2028
          "select rc.pv_id, bm.bm_name, bsa.bsa_name " +
2029
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa " +
2030
          "where rc.rtag_id=" + baseline +
2031
          " and pv.pv_id = rc.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id " +
2032
          "order by rc.pv_id"
2033
          );
2034
          ResultSet rset10 = stmt10.executeQuery();
2035
 
2036
          while( rset10.next() )
2037
          {
2038
            boolean ignore = false;
2039
            int pv_id = rset10.getInt("pv_id");
2040
 
2041
            if ( rset10.wasNull() )
2042
            {
2043
              mLogger.fatal("queryPackageVersions rset10 null pv_id");
2044
              // show stopper
868 mhunt 2045
              throw new Exception("queryPackageVersions rset10 null pv_id");
814 mhunt 2046
            }
2047
 
2048
            Package p = findPackage(pv_id, packageCollection);
2049
 
2050
            if ( p == NULL_PACKAGE )
2051
            {
2052
              mLogger.info("queryPackageVersions rset10 package may have been superceded by planned " + pv_id);
2053
              ignore = true;
2054
            }
2055
 
2056
            String bm_name = rset10.getString("bm_name");
2057
 
2058
            if ( bm_name == null )
2059
            {
2060
              mLogger.fatal("queryPackageVersions rset10 null bm_name " + pv_id);
2061
              // show stopper
868 mhunt 2062
              throw new Exception("queryPackageVersions rset10 null bm_name " + pv_id);
814 mhunt 2063
            }
2064
 
2065
            String bsa_name = rset10.getString("bsa_name");
2066
 
2067
            if ( bsa_name == null )
2068
            {
2069
              mLogger.fatal("queryPackageVersions rset10 null bsa_name " + pv_id);
2070
              // show stopper
868 mhunt 2071
              throw new Exception("queryPackageVersions rset10 null bsa_name " + pv_id);
814 mhunt 2072
            }
2073
 
2074
            if ( !ignore )
2075
            {
2076
              boolean supportedBuildStandard = true;
2077
              BuildStandard bs = new BuildStandard(rippleEngine);
2078
 
2079
              if ( bm_name.compareTo("Solaris") == 0 )
2080
              {
2081
                bs.setSolaris();
2082
              }
2083
              else if ( bm_name.compareTo("Win32") == 0 )
2084
              {
2085
                bs.setWin32();
2086
              }
2087
              else if ( bm_name.compareTo("Linux") == 0 )
2088
              {
2089
                bs.setLinux();
2090
              }
2091
              else if ( bm_name.compareTo("Generic") == 0 )
2092
              {
2093
                bs.setGeneric();
2094
              }
2095
              else
2096
              {
2097
                supportedBuildStandard = false;
2098
              }
2099
 
2100
              if ( bsa_name.compareTo("Production") == 0 )
2101
              {
2102
                bs.setProduction();
2103
              }
2104
              else if ( bsa_name.compareTo("Debug") == 0 )
2105
              {
2106
                bs.setDebug();
2107
              }
2108
              else if ( bsa_name.compareTo("Production and Debug") == 0 )
2109
              {
2110
                bs.setAll();
2111
              }
2112
              else if ( bsa_name.compareTo("Java 1.4") == 0 )
2113
              {
2114
                bs.set1_4();
2115
              }
2116
              else if ( bsa_name.compareTo("Java 1.5") == 0 )
2117
              {
2118
                bs.set1_5();
2119
              }
2120
              else if ( bsa_name.compareTo("Java 1.6") == 0 )
2121
              {
2122
                bs.set1_6();
2123
              }
2124
              else
2125
              {
2126
                supportedBuildStandard = false;
2127
              }
2128
 
2129
              if ( supportedBuildStandard )
2130
              {
2131
                p.mBuildStandardCollection.add(bs);
2132
              }
2133
            }
2134
          }
830 mhunt 2135
 
2136
          rset10.close();
2137
          stmt10.close();
814 mhunt 2138
 
2139
          // get released package unit test info
2140
          CallableStatement stmt11 = mConnection.prepareCall(
2141
          "select rc.pv_id, tt.test_type_name " +
2142
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.unit_tests ut, release_manager.test_types tt " +
2143
          "where rc.rtag_id=" + baseline +
2144
          " and pv.pv_id = rc.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk " +
2145
          "order by rc.pv_id"
2146
          );
2147
          ResultSet rset11 = stmt11.executeQuery();
2148
 
2149
          while( rset11.next() )
2150
          {
2151
            boolean ignore = false;
2152
 
2153
            int pv_id = rset11.getInt("pv_id");
2154
 
2155
            if ( rset11.wasNull() )
2156
            {
2157
              mLogger.fatal("queryPackageVersions rset11 null pv_id");
2158
              // show stopper
868 mhunt 2159
              throw new Exception("queryPackageVersions rset11 null pv_id");
814 mhunt 2160
            }
2161
 
2162
            Package p = findPackage(pv_id, packageCollection);
2163
 
2164
            if ( p == NULL_PACKAGE )
2165
            {
2166
              mLogger.info("queryPackageVersions rset11 package may have been superceded by planned " + pv_id);
2167
              ignore = true;
2168
            }
2169
 
2170
            String test_type_name = rset11.getString("test_type_name");
2171
 
2172
            if ( test_type_name == null )
2173
            {
2174
              mLogger.fatal("queryPackageVersions rset11 null test_type_name " + pv_id);
2175
              // show stopper
868 mhunt 2176
              throw new Exception("queryPackageVersions rset11 null test_type_name " + pv_id);
814 mhunt 2177
            }
2178
 
2179
            if ( !ignore )
2180
            {
2181
              if ( test_type_name.compareTo("Autobuild UTF") == 0 )
2182
              {
2183
                p.mHasAutomatedUnitTests = true;
2184
              }
2185
            }
2186
          }
830 mhunt 2187
 
2188
          rset11.close();
2189
          stmt11.close();
814 mhunt 2190
 
864 mhunt 2191
          // get released package build failure info...
2192
          // global and project wide based
2193
          CallableStatement stmt120 = mConnection.prepareCall(
2194
          "select rc.pv_id " +
2195
          "from release_manager.release_content rc, release_manager.release_tags rt, release_manager.package_versions pv " +
2196
          "where rc.rtag_id=" + baseline + " and rt.rtag_id=rc.rtag_id " +
2197
          "and pv.pv_id = rc.pv_id " +
2198
          "order by rc.pv_id"
2199
          );
2200
          ResultSet rset120 = stmt120.executeQuery();
2201
 
2202
          while( rset120.next() )
2203
          {
2204
            int pv_id = rset120.getInt("pv_id");
2205
 
2206
            if ( rset120.wasNull() )
2207
            {
2208
              mLogger.fatal("queryPackageVersions rset120 null pv_id");
2209
              // show stopper
868 mhunt 2210
              throw new Exception("queryPackageVersions rset120 null pv_id");
864 mhunt 2211
            }
2212
 
2213
            Package p = findPackage(pv_id, packageCollection);
2214
 
2215
            if ( p == NULL_PACKAGE )
2216
            {
2217
              mLogger.info("queryPackageVersions rset120 highly unlikely " + pv_id);
2218
              // highly unlikely but package may have been added in between queries
2219
            }
2220
            else
2221
            {
2222
              for (Iterator<String> it = globalAndProjectWideBuildFailureEmailCollection.iterator(); it.hasNext(); )
2223
              {
2224
                p.addEmail(it.next());
2225
              }
2226
            }
2227
          }
2228
 
2229
          rset120.close();
2230
          stmt120.close();
2231
 
2232
          // view based
814 mhunt 2233
          CallableStatement stmt12 = mConnection.prepareCall(
2234
          "select rc.pv_id, u.user_email " +
2235
          "from release_manager.release_content rc, release_manager.release_tags rt, release_manager.package_versions pv, release_manager.autobuild_failure af, release_manager.members_group mg, release_manager.users u " +
2236
          "where rc.rtag_id=" + baseline + " and rt.rtag_id=rc.rtag_id " +
2237
          "and pv.pv_id = rc.pv_id and af.view_id=rc.base_view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id " +
2238
          "order by rc.pv_id"
2239
          );
2240
          ResultSet rset12 = stmt12.executeQuery();
2241
 
2242
          while( rset12.next() )
2243
          {
2244
            int pv_id = rset12.getInt("pv_id");
2245
 
2246
            if ( rset12.wasNull() )
2247
            {
2248
              mLogger.fatal("queryPackageVersions rset12 null pv_id");
2249
              // show stopper
868 mhunt 2250
              throw new Exception("queryPackageVersions rset12 null pv_id");
814 mhunt 2251
            }
2252
 
2253
            Package p = findPackage(pv_id, packageCollection);
2254
 
2255
            if ( p == NULL_PACKAGE )
2256
            {
2257
              mLogger.info("queryPackageVersions rset12 package may have been superceded by planned " + pv_id);
2258
            }
864 mhunt 2259
            else
814 mhunt 2260
            {
864 mhunt 2261
              String user_email = rset12.getString("user_email");
814 mhunt 2262
 
864 mhunt 2263
              if ( user_email != null )
2264
              {
2265
                p.addEmail(user_email);
2266
              }
814 mhunt 2267
            }
2268
          }
830 mhunt 2269
 
2270
          rset12.close();
2271
          stmt12.close();
814 mhunt 2272
 
2273
          // get released advisory ripple info
2274
          CallableStatement stmt14 = mConnection.prepareCall(
2275
          "select rc.pv_id " +
2276
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.advisory_ripple ar " +
2277
          "where rc.rtag_id=" + baseline +
2278
          " and pv.pv_id = rc.pv_id and ar.rtag_id=rc.rtag_id and ar.pv_id=rc.pv_id " +
2279
          "order by rc.pv_id"
2280
          );
2281
          ResultSet rset14 = stmt14.executeQuery();
2282
 
2283
          while( rset14.next() )
2284
          {
2285
            boolean ignore = false;
2286
 
2287
            int pv_id = rset14.getInt("pv_id");
2288
 
2289
            if ( rset14.wasNull() )
2290
            {
2291
              mLogger.fatal("queryPackageVersions rset14 null pv_id");
2292
              // show stopper
868 mhunt 2293
              throw new Exception("queryPackageVersions rset14 null pv_id");
814 mhunt 2294
            }
2295
 
2296
            Package p = findPackage(pv_id, packageCollection);
2297
 
2298
            if ( p == NULL_PACKAGE )
2299
            {
2300
              mLogger.info("queryPackageVersions rset14 package may have been superceded by planned " + pv_id);
2301
              ignore = true;
2302
            }
2303
 
2304
            if ( !ignore )
2305
            {
2306
              p.mAdvisoryRipple = true;
2307
            }
2308
          }
830 mhunt 2309
 
2310
          rset14.close();
2311
          stmt14.close();
814 mhunt 2312
        }
2313
        else
2314
        {
2315
          // get released product info
2316
          CallableStatement stmt = mConnection.prepareCall(
2317
          "select oc.prod_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_label, pv.src_path " +
2318
          "from bom_contents bc, operating_systems os, os_contents oc, release_manager.package_versions pv, release_manager.packages p " +
2319
          "where bc.bom_id=" + baseline + " and os.node_id=bc.node_id and oc.os_id=os.os_id and pv.pv_id=oc.prod_id and p.pkg_id=pv.pkg_id " +
2320
          "order by oc.prod_id"
2321
          );
2322
          ResultSet rset = stmt.executeQuery();
2323
 
2324
          while( rset.next() )
2325
          {
2326
            int pv_id = rset.getInt("prod_id");
2327
 
2328
            if ( rset.wasNull() )
2329
            {
2330
              mLogger.fatal("queryPackageVersions rset null prod_id");
2331
              // show stopper
868 mhunt 2332
              throw new Exception("queryPackageVersions rset null prod_id");
814 mhunt 2333
            }
2334
 
2335
            String pkg_name = rset.getString("pkg_name");
2336
 
2337
            if ( pkg_name == null )
2338
            {
2339
              mLogger.fatal("queryPackageVersions rset null pkg_name " + pv_id);
2340
              // show stopper
868 mhunt 2341
              throw new Exception("queryPackageVersions rset null pkg_name " + pv_id);
814 mhunt 2342
            }
2343
 
2344
            String pkg_version = rset.getString("pkg_version");
2345
 
2346
            if ( pkg_version == null )
2347
            {
2348
              mLogger.fatal("queryPackageVersions rset null pkg_version " + pv_id);
2349
              // show stopper
868 mhunt 2350
              throw new Exception("queryPackageVersions rset null pkg_version " + pv_id);
814 mhunt 2351
            }
2352
 
2353
            String v_ext = rset.getString("v_ext");
2354
 
2355
            if ( v_ext == null )
2356
            {
2357
              v_ext = "";
2358
            }
2359
 
2360
            String pkg_label = rset.getString("pkg_label");
2361
 
2362
            if ( pkg_label == null )
2363
            {
2364
              pkg_label = "NA";
2365
            }
2366
 
2367
            String src_path = rset.getString("src_path");
2368
 
2369
            if ( src_path == null )
2370
            {
2371
              src_path = "NA";
2372
            }
2373
 
834 mhunt 2374
            Package p = findPackage(pv_id, packageCollection);
2375
 
2376
            if ( p == NULL_PACKAGE )
2377
            {
2378
	            Package q = new Package(pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, pkg_label, src_path, 'x');
2379
	            packageCollection.add(q);
2380
            }
814 mhunt 2381
          }
830 mhunt 2382
 
2383
          rset.close();
2384
          stmt.close();
814 mhunt 2385
        }
2386
      }
2387
      catch ( SQLException e )
2388
      {
2389
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2390
        {
2391
          mLogger.error("queryPackageVersions database access error only");
2392
          throw new SQLException();
2393
        }
2394
        else
2395
        {
2396
          mLogger.fatal("queryPackageVersions show stopper");
868 mhunt 2397
          throw new Exception("queryPackageVersions show stopper");
814 mhunt 2398
        }
2399
      }
2400
    }
2401
 
2402
    if (!daemonMode)
2403
    {
2404
      // use a ListIterator as it allows traverseDependencies to modify the packageCollection
864 mhunt 2405
      for (ListIterator<Package> it = packageCollection.listIterator(); it.hasNext(); )
814 mhunt 2406
      {
864 mhunt 2407
        Package p = it.next();
814 mhunt 2408
        traverseDependencies(packageCollection, p, false, it);
2409
      }
2410
 
864 mhunt 2411
      for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2412
      {
864 mhunt 2413
        Package p = it.next();
814 mhunt 2414
        queryBuildInfo(rippleEngine, p);
2415
      }
2416
    }
2417
 
2418
  }
2419
 
2420
  /**only used in daemon mode
2421
   *   select config from build_service_config where service='MAIL SERVER';
2422
   * returns the configured service
2423
   */
2424
  String queryMailServer() throws SQLException, Exception
2425
  {
2426
    mLogger.debug("queryMailServer");
2427
    String retVal = new String();
2428
 
2429
    if ( !mUseDatabase )
2430
    {
2431
      mLogger.info("queryMailServer !mUseDatabase");
2432
      // a highly likely mail server
2433
      retVal = "aupera03.aupera.erggroup.com";
2434
    }
2435
    else
2436
    {
2437
      try
2438
      {
2439
        CallableStatement stmt = mConnection.prepareCall("select config from release_manager.build_service_config where service='MAIL SERVER'");
2440
        ResultSet rset = stmt.executeQuery();
2441
 
2442
        while( rset.next() )
2443
        {
2444
          String config = rset.getString("config");
2445
 
2446
          if ( config != null )
2447
          {
2448
            retVal += config;
2449
          }
2450
        }
830 mhunt 2451
 
2452
        rset.close();
2453
        stmt.close();
814 mhunt 2454
      }
2455
      catch ( SQLException e )
2456
      {
2457
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2458
        {
2459
          mLogger.error("queryMailServer database access error only");
2460
          throw new SQLException();
2461
        }
2462
        else
2463
        {
2464
          mLogger.fatal("queryMailServer show stopper");
868 mhunt 2465
          throw new Exception("queryMailServer show stopper");
814 mhunt 2466
        }
2467
      }
2468
    }
2469
 
2470
    mLogger.info("queryMailServer returned " + retVal);
2471
    return retVal;
2472
  }
2473
 
2474
  /**only used in daemon mode
2475
   *   select config from build_service_config where service='BUILD FAILURE MAIL SENDER';
2476
   * returns the configured service
2477
   */
2478
  String queryMailSender() throws SQLException, Exception
2479
  {
2480
    mLogger.debug("queryMailSender");
2481
    String retVal = new String();
2482
 
2483
    if ( !mUseDatabase )
2484
    {
2485
      mLogger.info("queryMailSender !mUseDatabase");
2486
      // a highly likely mail sender
2487
      retVal = "buildadm@erggroup.com";
2488
    }
2489
    else
2490
    {
2491
      try
2492
      {
2493
        CallableStatement stmt = mConnection.prepareCall("select config from release_manager.build_service_config where service='BUILD FAILURE MAIL SENDER'");
2494
        ResultSet rset = stmt.executeQuery();
2495
 
2496
        while( rset.next() )
2497
        {
2498
          String config = rset.getString("config");
2499
 
2500
          if ( config != null )
2501
          {
2502
            retVal += config;
2503
          }
2504
        }
830 mhunt 2505
 
2506
        rset.close();
2507
        stmt.close();
814 mhunt 2508
      }
2509
      catch ( SQLException e )
2510
      {
2511
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2512
        {
2513
          mLogger.error("queryMailSender database access error only");
2514
          throw new SQLException();
2515
        }
2516
        else
2517
        {
2518
          mLogger.fatal("queryMailSender show stopper");
868 mhunt 2519
          throw new Exception("queryMailSender show stopper");
814 mhunt 2520
        }
2521
      }
2522
    }
2523
 
2524
    mLogger.debug("queryMailSender returned " + retVal);
2525
    return retVal;
2526
  }
2527
 
868 mhunt 2528
  /**only used in daemon mode
2529
   * select u.user_email from release_manager.build_service_config bsc, users u
2530
   * where bsc.service='GLOBAL EMAIL ADDRESS LIST' and u.full_name=bsc.config
2531
   * returns the configured global email addresses
2532
   */
2533
  String queryGlobalAddresses() throws SQLException, Exception
2534
  {
2535
    mLogger.debug("queryGlobalAddresses");
2536
    String retVal = new String();
2537
 
2538
    if ( !mUseDatabase )
2539
    {
2540
      mLogger.info("queryGlobalAddresses !mUseDatabase");
2541
      // a highly unlikely address
2542
      retVal = "buildadm@erggroup.com";
2543
    }
2544
    else
2545
    {
2546
      try
2547
      {
2548
        CallableStatement stmt = mConnection.prepareCall(
2549
        "select u.user_email from release_manager.build_service_config bsc, users u " +
2550
        "where bsc.service='GLOBAL EMAIL ADDRESS LIST' and u.full_name=bsc.config"
2551
        );
2552
        ResultSet rset = stmt.executeQuery();
2553
 
2554
        while( rset.next() )
2555
        {
2556
          String email = rset.getString("user_email");
2557
 
2558
          if ( email != null )
2559
          {
2560
            retVal += email;
2561
          }
2562
        }
2563
 
2564
        rset.close();
2565
        stmt.close();
2566
      }
2567
      catch ( SQLException e )
2568
      {
2569
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2570
        {
2571
          mLogger.error("queryGlobalAddresses database access error only");
2572
          throw new SQLException();
2573
        }
2574
        else
2575
        {
2576
          mLogger.fatal("queryGlobalAddresses show stopper");
2577
          throw new Exception("queryGlobalAddresses show stopper");
2578
        }
2579
      }
2580
    }
2581
 
2582
    mLogger.debug("queryGlobalAddresses returned " + retVal);
2583
    return retVal;
2584
  }
2585
 
814 mhunt 2586
  /**called only in escrow mode
2587
   * if checkCollection is true, checks the pv_id is in the packageCollection
2588
   * if checkCollection is false, or the pv_id is not in the collection
2589
   * 1 traverses the pv_id package dependencies
2590
   *   select dpv.pv_id, p.pkg_name, dpv.pkg_version, dpv.v_ext, dpv.pkg_label, dpv.src_path
2591
   *   from release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p
2592
   *   where pv.pv_id = <pv_id> and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
2593
   *   order by pv.pv_id;
2594
   * 2 for each dpv.pv_id in the resultset
2595
   *     call traverseDependencies( packageCollection, dpv.pv_id, true )
2596
   *     if the pv_id is not in the collection, add it
2597
   *   
2598
   */
864 mhunt 2599
  private void traverseDependencies(Vector<Package> packageCollection, Package pkg, 
814 mhunt 2600
                                     boolean checkCollection, 
864 mhunt 2601
                                     ListIterator<Package> listIterator) throws SQLException, Exception
814 mhunt 2602
  {
2603
    mLogger.debug("traverseDependencies " + checkCollection);
2604
    boolean pvIdInCollection = false;
2605
 
2606
    if ( checkCollection )
2607
    {
864 mhunt 2608
      for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2609
      {
864 mhunt 2610
        Package p = it.next();
814 mhunt 2611
 
2612
        if ( p.mId == pkg.mId )
2613
        {
2614
          pvIdInCollection = true;
2615
          break;
2616
        }
2617
      }
2618
    }
2619
 
2620
    if ( !pvIdInCollection )
2621
    {
864 mhunt 2622
      Vector<Package> resultset = new Vector<Package>();
814 mhunt 2623
 
2624
      if ( !mUseDatabase )
2625
      {
2626
        mLogger.info("traverseDependencies !mUseDatabase");
2627
 
2628
        if ( pkg.mId == 8 || pkg.mId == 10 || pkg.mId == 13 )
2629
        {
2630
          Package p = new Package(9, "CommonDependency", "1.0.0000.tim", ".tim", "CommonDependency.1.0.0000.tim", "CommonDependency_1.0.0000.tim", "\\vob\\CommonDependency", 'x');
2631
          resultset.add(p);
2632
          pkg.mDependencyCollection.add(p.mAlias);
2633
        }
2634
        else if ( pkg.mId == 9 )
2635
        {
2636
          Package p = new Package(7, "CotsWithFunnyVersion", "hoopla2_x.cots", ".cots", "CotsWithFunnyVersion.hoopla2_x.cots", "CotsWithFunnyVersion_hoopla2_x.cots", "\\vob\\CotsWithFunnyVersion", 'x');
2637
          resultset.add(p);
2638
          pkg.mDependencyCollection.add(p.mAlias);
2639
        }
2640
        else if ( pkg.mId == 11 )
2641
        {
2642
          Package p = new Package(14, "AdvisoryDependency", "1.0.0000.tim", ".tim", "AdvisoryDependency.1.0.0000.tim", "AdvisoryDependency_1.0.0000.tim", "\\vob\\AdvisoryDependency", 'x');
2643
          resultset.add(p);
2644
          pkg.mDependencyCollection.add(p.mAlias);
2645
        }
2646
      }
2647
      else
2648
      {
2649
        try
2650
        {
2651
          CallableStatement stmt = mConnection.prepareCall(
2652
          "select dpv.pv_id, p.pkg_name, dpv.pkg_version, dpv.v_ext, dpv.pkg_label, dpv.src_path " +
2653
          "from release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p " +
2654
          "where pv.pv_id=" + pkg.mId + " and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id " +
2655
          "order by pv.pv_id"
2656
          );
2657
          ResultSet rset = stmt.executeQuery();
2658
 
2659
          while( rset.next() )
2660
          {
2661
            int pv_id = rset.getInt("pv_id");
2662
 
2663
            if ( rset.wasNull() )
2664
            {
2665
              mLogger.fatal("traverseDependencies null pv_id");
2666
              // show stopper
868 mhunt 2667
              throw new Exception("traverseDependencies null pv_id");
814 mhunt 2668
            }
2669
 
2670
            String pkg_name = rset.getString("pkg_name");
2671
 
2672
            if ( pkg_name == null )
2673
            {
2674
              mLogger.fatal("traverseDependencies null pkg_name " + pv_id);
2675
              // show stopper
868 mhunt 2676
              throw new Exception("traverseDependencies null pkg_name " + pv_id);
814 mhunt 2677
            }
2678
 
2679
            String pkg_version = rset.getString("pkg_version");
2680
 
2681
            if ( pkg_version == null )
2682
            {
2683
              mLogger.fatal("traverseDependencies null pkg_version " + pv_id);
2684
              // show stopper
868 mhunt 2685
              throw new Exception("traverseDependencies null pkg_version " + pv_id);
814 mhunt 2686
            }
2687
 
2688
            String v_ext = rset.getString("v_ext");
2689
 
2690
            if ( v_ext == null )
2691
            {
2692
              v_ext = "";
2693
            }
2694
 
2695
            String pkg_label = rset.getString("pkg_label");
2696
 
2697
            if ( pkg_label == null )
2698
            {
2699
              pkg_label = "NA";
2700
            }
2701
 
2702
            String src_path = rset.getString("src_path");
2703
 
2704
            if ( src_path == null )
2705
            {
2706
              src_path = "NA";
2707
            }
2708
 
2709
            Package p = new Package(pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, pkg_label, src_path, 'x');
2710
            resultset.add(p);
2711
            pkg.mDependencyCollection.add(p.mAlias);
2712
          }
830 mhunt 2713
 
2714
          rset.close();
2715
          stmt.close();
814 mhunt 2716
        }
2717
        catch ( SQLException e )
2718
        {
2719
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2720
          {
2721
            mLogger.fatal("traverseDependencies database access error only");
2722
            throw new SQLException();
2723
          }
2724
          else
2725
          {
2726
            mLogger.fatal("traverseDependencies show stopper");
868 mhunt 2727
            throw new Exception("traverseDependencies show stopper");
814 mhunt 2728
          }
2729
        }
2730
      }
2731
 
864 mhunt 2732
      for (Iterator<Package> it = resultset.iterator(); it.hasNext(); )
814 mhunt 2733
      {
864 mhunt 2734
        Package r = it.next();
814 mhunt 2735
        traverseDependencies(packageCollection, r, true, listIterator);
2736
 
2737
        pvIdInCollection = false;
2738
 
864 mhunt 2739
        for (Iterator<Package> it2 = packageCollection.iterator(); it2.hasNext(); )
814 mhunt 2740
        {
864 mhunt 2741
          Package p = it2.next();
814 mhunt 2742
 
2743
          if ( p.mId == r.mId )
2744
          {
2745
            pvIdInCollection = true;
2746
            break;
2747
          }
2748
        }
2749
 
2750
        if (!pvIdInCollection)
2751
        {
2752
          // insert the Package immediately before the next Package returned by next
2753
          // this does not change the next Package (if any) to be returned by next
2754
          listIterator.add(r);
2755
        }
2756
 
2757
      }
2758
    }
2759
  }
2760
 
2761
  /**returns the Package with the matching mID or NULL_PACKAGE if no package has the mID
2762
   */
864 mhunt 2763
  private Package findPackage(int id, Vector<Package> packageCollection)
814 mhunt 2764
  {
2765
    mLogger.debug("findPackage 1 id " + id);
2766
    Package retVal = NULL_PACKAGE;
2767
 
864 mhunt 2768
    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2769
    {
864 mhunt 2770
      Package p = it.next();
814 mhunt 2771
 
2772
      if ( p.mId == id )
2773
      {
2774
        retVal = p;
2775
        break;
2776
      }
2777
    }
2778
 
2779
    mLogger.debug("findPackage 1 returned " + retVal.mName);
2780
    return retVal;
2781
  }
2782
 
2783
  /**called only in escrow mode to add build info to the Package
2784
   * select bm.bm_name, bsa.bsa_name
2785
   * from release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa
2786
   * where pv.pv_id = <p.pv_id> and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
2787
   * order by pv.pv_id;
2788
   */
2789
  private void queryBuildInfo(RippleEngine rippleEngine, Package p) throws SQLException, Exception
2790
  {
2791
    mLogger.debug("queryBuildInfo");
2792
    if ( !mUseDatabase )
2793
    {
2794
      mLogger.info("queryBuildInfo !mUseDatabase");
2795
 
2796
      if (p.mId == 7)
2797
      {
2798
        BuildStandard bs = new BuildStandard(rippleEngine);
2799
        bs.setSolaris();
2800
        bs.setDebug();
2801
        p.mBuildStandardCollection.add(bs);
2802
      }
2803
      else if (p.mId == 9)
2804
      {
2805
        BuildStandard bs = new BuildStandard(rippleEngine);
2806
        bs.setLinux();
2807
        bs.setDebug();
2808
        p.mBuildStandardCollection.add(bs);
2809
        bs = new BuildStandard(rippleEngine);
2810
        bs.setSolaris();
2811
        bs.setDebug();
2812
        p.mBuildStandardCollection.add(bs);
2813
        bs = new BuildStandard(rippleEngine);
2814
        bs.setWin32();
2815
        bs.setProduction();
2816
        p.mBuildStandardCollection.add(bs);
2817
      }
2818
      else if (p.mId == 10)
2819
      {
2820
        BuildStandard bs = new BuildStandard(rippleEngine);
2821
        bs.setSolaris();
2822
        bs.set1_4();
2823
        p.mBuildStandardCollection.add(bs);
2824
      }
2825
      else if (p.mId == 11)
2826
      {
2827
        BuildStandard bs = new BuildStandard(rippleEngine);
2828
        bs.setLinux();
2829
        bs.setAll();
2830
        p.mBuildStandardCollection.add(bs);
2831
      }
2832
      else if (p.mId == 12)
2833
      {
2834
        BuildStandard bs = new BuildStandard(rippleEngine);
2835
        bs.setWin32();
2836
        bs.set1_6();
2837
        p.mBuildStandardCollection.add(bs);
2838
      }
2839
      else if (p.mId == 13)
2840
      {
2841
        BuildStandard bs = new BuildStandard(rippleEngine);
2842
        bs.setGeneric();
2843
        bs.set1_4();
2844
        p.mBuildStandardCollection.add(bs);
2845
      }
2846
      else if (p.mId == 14)
2847
      {
2848
        BuildStandard bs = new BuildStandard(rippleEngine);
2849
        bs.setLinux();
2850
        bs.setDebug();
2851
        p.mBuildStandardCollection.add(bs);
2852
      }
2853
 
2854
    }
2855
    else
2856
    {
2857
      try
2858
      {
2859
        CallableStatement stmt = mConnection.prepareCall(
2860
        "select bm.bm_name, bsa.bsa_name " +
2861
        "from release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa " +
2862
        "where pv.pv_id=" + p.mId + " and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id " +
2863
        "order by pv.pv_id"
2864
        );
2865
        ResultSet rset = stmt.executeQuery();
2866
 
2867
        while( rset.next() )
2868
        {
2869
          boolean supportedBuildStandard = true;
2870
          BuildStandard bs = new BuildStandard(rippleEngine);
2871
          String bm_name = rset.getString("bm_name");
2872
 
2873
          if ( bm_name == null )
2874
          {
2875
            mLogger.fatal("queryBuildInfo null bm_name " + p.mId);
2876
            // show stopper
868 mhunt 2877
            throw new Exception("queryBuildInfo null bm_name " + p.mId);
814 mhunt 2878
          }
2879
          else if ( bm_name.compareTo("Solaris") == 0 )
2880
          {
2881
            bs.setSolaris();
2882
          }
2883
          else if ( bm_name.compareTo("Win32") == 0 )
2884
          {
2885
            bs.setWin32();
2886
          }
2887
          else if ( bm_name.compareTo("Linux") == 0 )
2888
          {
2889
            bs.setLinux();
2890
          }
2891
          else if ( bm_name.compareTo("Generic") == 0 )
2892
          {
2893
            bs.setGeneric();
2894
          }
2895
          else
2896
          {
2897
            supportedBuildStandard = false;
2898
          }
2899
 
2900
          String bsa_name = rset.getString("bsa_name");
2901
 
2902
          if ( bsa_name == null )
2903
          {
2904
            mLogger.fatal("queryBuildInfo null bsa_name " + p.mId);
2905
            // show stopper
868 mhunt 2906
            throw new Exception("queryBuildInfo null bsa_name " + p.mId);
814 mhunt 2907
          }
2908
          else if ( bsa_name.compareTo("Production") == 0 )
2909
          {
2910
            bs.setProduction();
2911
          }
2912
          else if ( bsa_name.compareTo("Debug") == 0 )
2913
          {
2914
            bs.setDebug();
2915
          }
2916
          else if ( bsa_name.compareTo("Production and Debug") == 0 )
2917
          {
2918
            bs.setAll();
2919
          }
2920
          else if ( bsa_name.compareTo("Java 1.4") == 0 )
2921
          {
2922
            bs.set1_4();
2923
          }
2924
          else if ( bsa_name.compareTo("Java 1.5") == 0 )
2925
          {
2926
            bs.set1_5();
2927
          }
2928
          else if ( bsa_name.compareTo("Java 1.6") == 0 )
2929
          {
2930
            bs.set1_6();
2931
          }
2932
          else
2933
          {
2934
            supportedBuildStandard = false;
2935
          }
2936
 
2937
          if ( supportedBuildStandard )
2938
          {
2939
            p.mBuildStandardCollection.add(bs);
2940
          }
2941
        }
830 mhunt 2942
 
2943
        rset.close();
2944
        stmt.close();
814 mhunt 2945
      }
2946
      catch ( SQLException e )
2947
      {
2948
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2949
        {
2950
          mLogger.error("queryBuildInfo database access error only");
2951
          throw new SQLException();
2952
        }
2953
        else
2954
        {
2955
          mLogger.fatal("queryBuildInfo show stopper");
868 mhunt 2956
          throw new Exception("queryBuildInfo show stopper");
814 mhunt 2957
        }
2958
      }
2959
    }
2960
  }
2961
 
2962
  /**returns the Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
2963
   */
864 mhunt 2964
  private Package findPackage(String alias, Vector<Package> packageCollection)
814 mhunt 2965
  {
2966
    mLogger.debug("findPackage 2 alias " + alias);
2967
    Package retVal = NULL_PACKAGE;
2968
 
864 mhunt 2969
    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2970
    {
864 mhunt 2971
      Package p = it.next();
814 mhunt 2972
 
2973
      if ( p.mAlias.compareTo( alias ) == 0 )
2974
      {
2975
        retVal = p;
2976
        break;
2977
      }
2978
    }
844 dpurdie 2979
 
814 mhunt 2980
    mLogger.info("findPackage 2 returned " + retVal.mName);
2981
    return retVal;
2982
  }
2983
 
2984
  /**essentially locks the row in the BUILD_SERVICE_CONFIG table with a service of MUTEX
2985
   * for the duration of the connection
2986
   * this prevents other MasterThreads from generating build files in parallel
2987
   * and hence prevents planned version numbering contention
2988
   * select CONFIG from BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE
2989
   */
2990
  public void claimMutex() throws SQLException, Exception
2991
  {
2992
    mLogger.debug("claimMutex");
2993
    if ( mUseDatabase )
2994
    {
2995
      try
2996
      {
2997
        CallableStatement stmt = mConnection.prepareCall("select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE");
2998
        stmt.executeUpdate();
844 dpurdie 2999
        stmt.close();
814 mhunt 3000
      }
3001
      catch ( SQLException e )
3002
      {
3003
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3004
        {
3005
          mLogger.error("claimMutex database access error only");
3006
          throw new SQLException();
3007
        }
3008
        else
3009
        {
3010
          mLogger.fatal("claimMutex show stopper");
868 mhunt 3011
          throw new Exception("claimMutex show stopper");
814 mhunt 3012
        }
3013
      }
3014
    }
3015
  }
3016
 
3017
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3018
   * update run_level set current_build_files=null where rcon_id=<rcon_id>
3019
   * returns true if successful
3020
   */
3021
  public boolean clearBuildFile(int rcon_id) throws SQLException, Exception
3022
  {
3023
    mLogger.debug("clearBuildFile");
3024
    boolean retVal = false;
3025
 
3026
    try
3027
    {
3028
      connect();
3029
      CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_build_files=null where rcon_id=" + rcon_id);
3030
      stmt.executeUpdate();
844 dpurdie 3031
      stmt.close();
814 mhunt 3032
      mConnection.commit();
3033
      disconnect();
3034
      retVal = true;
3035
    }
3036
    catch ( SQLException e )
3037
    {
3038
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3039
      {
3040
        mLogger.error("clearBuildFile database access error only");
3041
        throw new SQLException();
3042
      }
3043
      else
3044
      {
3045
        mLogger.fatal("clearBuildFile show stopper");
868 mhunt 3046
        throw new Exception("clearBuildFile show stopper");
814 mhunt 3047
      }
3048
    }
3049
 
3050
    mLogger.info("clearBuildFile returned " + retVal);
3051
    return retVal;
3052
  }
3053
 
3054
  /**updates the CURRENT_BUILD_FILES for the rtag_id
3055
   * update (
3056
   * select current_build_files from run_level rl, release_config rc
3057
   * where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id
3058
   * ) set current_build_files=<buildFile>
3059
   * returns true if successful
3060
   */
3061
  public boolean publishBuildFile(int rtag_id, String buildFile) throws SQLException, Exception
3062
  {
3063
    mLogger.debug("publishBuildFile publishing a build file of length " + buildFile.length());
3064
    boolean retVal = false;
3065
 
3066
    try
3067
    {
3068
      connect();
3069
 
3070
      PreparedStatement stmt = mConnection.prepareStatement(
3071
      "update (" +
3072
      "select current_build_files from release_manager.run_level rl, release_manager.release_config rc " +
3073
      "where rc.rtag_id=? and rl.rcon_id=rc.rcon_id" +
3074
      ") set current_build_files=?");
3075
      stmt.setInt(1, rtag_id);
3076
      stmt.setString(2, buildFile);
3077
      stmt.executeUpdate();
3078
      mConnection.commit();
844 dpurdie 3079
      stmt.close();
814 mhunt 3080
      disconnect();
3081
      retVal = true;
3082
    }
3083
    catch ( SQLException e )
3084
    {
3085
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3086
      {
3087
        mLogger.error("publishBuildFile database access error only");
3088
        throw new SQLException();
3089
      }
3090
      else
3091
      {
3092
        mLogger.fatal("publishBuildFile show stopper");
868 mhunt 3093
        throw new Exception("publishBuildFile show stopper");
814 mhunt 3094
      }
3095
    }
3096
    catch ( Exception e )
3097
    {
3098
      // this catch and rethrow is historical
3099
      // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
3100
      mLogger.fatal("publishBuildFile caught Exception " + e.getMessage());
868 mhunt 3101
      throw new Exception("publishBuildFile caught Exception " + e.getMessage());
814 mhunt 3102
    }
3103
    mLogger.info("publishBuildFile returned " + retVal);
3104
    return retVal;
3105
  }
3106
 
3107
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3108
   * this is aimed at stopping all daemons dead
3109
   * it is raised when handling an unsupported exception case in either the main or slave daemons
3110
   * typically an SQLException other than a database connection related one
3111
   */
836 mhunt 3112
  public void indefinitePause() throws SQLException
814 mhunt 3113
  {
3114
    mLogger.debug("indefinitePause");
3115
    if ( mUseDatabase )
3116
    {
836 mhunt 3117
      try
3118
      {
814 mhunt 3119
      connect();
836 mhunt 3120
      CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
814 mhunt 3121
      stmt.executeUpdate();
844 dpurdie 3122
      stmt.close();
814 mhunt 3123
      mConnection.commit();
3124
      disconnect();
836 mhunt 3125
      }
3126
      catch( SQLException e )
3127
      {
3128
        // do not throw Exception
3129
        // this is part of Exception handling
3130
        mLogger.fatal( "indefinitePause caught SQLException " + e.getMessage() );
3131
      }
3132
      catch( Exception e )
3133
      {
3134
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3135
      }
814 mhunt 3136
    }
3137
  }
3138
 
3139
  /**only used in daemon mode to determine version existence in the database
3140
   *  1 select pkg_id from package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3141
   *  2 select pkg_id from planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3142
   * returns true if either resultset contains one record to indicate it already exists
3143
   */
3144
  boolean queryPackageVersions(int pkg_id, String pkg_version) throws SQLException, Exception
3145
  {
3146
    mLogger.debug("queryPackageVersions");
3147
    boolean retVal = false;
3148
 
3149
    if ( mUseDatabase )
3150
    {
3151
      try
3152
      {
3153
        mLogger.info("queryPackageVersions release_manager.package_versions");
3154
        CallableStatement stmt1 = mConnection.prepareCall("select pkg_id from release_manager.package_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3155
        ResultSet rset1 = stmt1.executeQuery();
3156
        int rsetSize = 0;
3157
 
3158
        while( rset1.next() )
3159
        {
3160
          rsetSize++;
3161
        }
830 mhunt 3162
 
3163
        rset1.close();
3164
        stmt1.close();
814 mhunt 3165
 
3166
        if ( rsetSize > 1 )
3167
        {
3168
          mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3169
          // show stopper
868 mhunt 3170
          throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3171
        }
3172
 
3173
        if ( rsetSize == 1 )
3174
        {
3175
          retVal = true;
3176
        }
3177
        else
3178
        {
3179
          mLogger.info("queryPackageVersions release_manager.planned_versions");
3180
          CallableStatement stmt2 = mConnection.prepareCall("select pkg_id from release_manager.planned_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3181
          ResultSet rset2 = stmt2.executeQuery();
3182
          rsetSize = 0;
3183
 
3184
          while( rset2.next() )
3185
          {
3186
            rsetSize++;
3187
          }
830 mhunt 3188
 
3189
          rset2.close();
3190
          stmt2.close();
814 mhunt 3191
 
3192
          if ( rsetSize > 1 )
3193
          {
3194
            mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3195
            // show stopper
868 mhunt 3196
            throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3197
          }
3198
 
3199
          if ( rsetSize == 1 )
3200
          {
3201
            retVal = true;
3202
          }
3203
          else
3204
          {
3205
            mLogger.info("queryPackageVersions archive_manager.package_versions");
3206
            CallableStatement stmt3 = mConnection.prepareCall("select pkg_id from archive_manager.package_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3207
            ResultSet rset3 = stmt3.executeQuery();
3208
            rsetSize = 0;
3209
 
3210
            while( rset3.next() )
3211
            {
3212
              rsetSize++;
3213
            }
830 mhunt 3214
 
3215
            rset3.close();
3216
            stmt3.close();
814 mhunt 3217
 
3218
            if ( rsetSize > 1 )
3219
            {
3220
              mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3221
              // show stopper
868 mhunt 3222
              throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3223
            }
3224
 
3225
            if ( rsetSize == 1 )
3226
            {
3227
              retVal = true;
3228
            }
3229
          }
3230
        }
3231
      }
3232
      catch ( SQLException e )
3233
      {
3234
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3235
        {
3236
          mLogger.error("queryPackageVersions database access error only");
3237
          throw new SQLException();
3238
        }
3239
        else
3240
        {
3241
          mLogger.fatal("queryPackageVersions show stopper");
868 mhunt 3242
          throw new Exception("queryPackageVersions show stopper");
814 mhunt 3243
        }
3244
      }
3245
    }
3246
 
3247
    mLogger.info("queryPackageVersions returned " + retVal);
3248
    return retVal;
3249
  }
3250
 
3251
  /**only used in daemon mode
3252
   *  insert into planned_versions (pkg_id, pkg_version) values (<pkg_id>, <pkg_version>);
3253
   *  update
3254
   *  (
3255
   *  select current_pkg_id_being_built from run_level rl, release_config rc
3256
   *  where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id
3257
   *  )
3258
   *  set current_pkg_id_being_built=<pkg_id>
3259
   */
3260
  void claimVersion(int pkg_id, String pkg_version, int rtag_id) throws SQLException, Exception
3261
  {
3262
    mLogger.debug("claimVersion " + pkg_id + " " + pkg_version);
3263
    if ( mUseDatabase )
3264
    {
3265
      try
3266
      {
3267
        CallableStatement stmt3 = mConnection.prepareCall("insert into release_manager.planned_versions (pkg_id, pkg_version) values (" + pkg_id + ", '" + pkg_version + "')");
3268
        stmt3.executeUpdate();
844 dpurdie 3269
        stmt3.close();
814 mhunt 3270
        CallableStatement stmt4 = mConnection.prepareCall(
3271
        "update " +
3272
        "(" +
3273
        "select current_pkg_id_being_built from release_manager.run_level rl, release_manager.release_config rc " +
3274
        "where rc.rtag_id=" + rtag_id + " and rl.rcon_id=rc.rcon_id" +
3275
        ")" +
3276
        "set current_pkg_id_being_built=" + pkg_id);
3277
        stmt4.executeUpdate();
844 dpurdie 3278
        stmt4.close();
814 mhunt 3279
        mConnection.commit();
3280
      }
3281
      catch ( SQLException e )
3282
      {
3283
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3284
        {
3285
          mLogger.error("claimVersion database access error only");
3286
          throw new SQLException();
3287
        }
3288
        else
3289
        {
3290
          mLogger.fatal("claimVersion show stopper");
868 mhunt 3291
          throw new Exception("claimVersion show stopper");
814 mhunt 3292
        }
3293
      }
3294
    }
3295
  }
3296
 
818 mhunt 3297
  /**only used in daemon mode
3298
   *  update
3299
   *  (
3300
   *  select current_pkg_id_being_built from run_level
3301
   *  where rcon_id=<rcon_id>
3302
   *  )
3303
   *  set current_pkg_id_being_built=null
3304
   */
3305
  public void clearCurrentPackageBeingBuilt(int rcon_id) throws SQLException, Exception
3306
  {
3307
    mLogger.debug("clearCurrentPackageBeingBuilt " + rcon_id);
3308
    if ( mUseDatabase )
3309
    {
3310
      try
3311
      {
820 mhunt 3312
        connect();
818 mhunt 3313
        CallableStatement stmt4 = mConnection.prepareCall(
3314
        "update " +
3315
        "(" +
3316
        "select current_pkg_id_being_built from run_level " +
3317
        "where rcon_id=" + rcon_id +
3318
        ")" +
3319
        "set current_pkg_id_being_built=null" );
3320
        stmt4.executeUpdate();
844 dpurdie 3321
        stmt4.close();
818 mhunt 3322
        mConnection.commit();
820 mhunt 3323
        disconnect();
818 mhunt 3324
      }
3325
      catch ( SQLException e )
3326
      {
3327
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3328
        {
3329
          mLogger.error("clearCurrentPackageBeingBuilt database access error only");
3330
          throw new SQLException();
3331
        }
3332
        else
3333
        {
3334
          mLogger.fatal("clearCurrentPackageBeingBuilt show stopper");
868 mhunt 3335
          throw new Exception("clearCurrentPackageBeingBuilt show stopper");
818 mhunt 3336
        }
3337
      }
3338
    }
3339
  }
3340
 
814 mhunt 3341
  /**handles database connection/disconnection
3342
   * executes the AutoMakeRelease stored procedure with the passed parameters
3343
   */
3344
  public void autoMakeRelease(String rtagId, String packageName, 
3345
                              String packageExtension, 
3346
                              String packageVersion, String packageLabel, 
3347
                              String packageDepends, String isRipple) throws SQLException, Exception
3348
  {
3349
    mLogger.debug("autoMakeRelease " + packageName);
3350
    if ( mUseDatabase )
3351
    {
3352
      try
3353
      {
3354
        connect();
3355
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.AUTO_MAKE_RELEASE(?,?,?,?,?,?,?,?); end;" );
3356
        stmt.registerOutParameter( 1, Types.INTEGER);
3357
        stmt.setString( 2, rtagId );
3358
        stmt.setString( 3, packageName );
3359
        stmt.setString( 4, packageExtension );
3360
        stmt.setString( 5, packageVersion );
3361
        stmt.setString( 6, packageLabel );
3362
        stmt.setString( 7, packageDepends );
3363
        stmt.setString( 8, isRipple );
3364
        stmt.setString( 9, "buildadm" );
3365
        stmt.executeUpdate();
3366
        int result = stmt.getInt( 1 );
3367
 
3368
        if ( result <= 0 && result != -2 )
3369
        {
3370
          // -2 if already released
3371
          // flag build failure
3372
          mLogger.fatal("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
868 mhunt 3373
          throw new Exception("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
814 mhunt 3374
        }
844 dpurdie 3375
        stmt.close();
814 mhunt 3376
        mConnection.commit();
3377
        disconnect();
3378
      }
3379
      catch( SQLException e )
3380
      {
3381
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3382
        {
3383
          mLogger.error("autoMakeRelease database access error only");
3384
          throw new SQLException();
3385
        }
3386
        else
3387
        {
3388
          mLogger.fatal("autoMakeRelease show stopper");
868 mhunt 3389
          throw new Exception("autoMakeRelease show stopper");
814 mhunt 3390
        }
3391
      }
3392
    }
3393
  }
3394
 
3395
  /**handles database connection/disconnection
834 mhunt 3396
   * executes the insertPackageMetrics stored procedure with the passed parameters
3397
   */
3398
  public void insertPackageMetrics(String rtagId, String packageName, 
3399
                              		 String packageExtension, String metrics) throws SQLException, Exception
3400
  {
3401
    mLogger.debug("insertPackageMetrics " + packageName);
3402
    if ( mUseDatabase )
3403
    {
3404
      try
3405
      {
3406
        connect();
3407
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.INSERT_PACKAGE_METRICS(?,?,?,?); end;" );
3408
        stmt.registerOutParameter( 1, Types.INTEGER);
3409
        stmt.setString( 2, rtagId );
3410
        stmt.setString( 3, packageName );
3411
        stmt.setString( 4, packageExtension );
3412
        stmt.setString( 5, metrics );
3413
        stmt.executeUpdate();
3414
        int result = stmt.getInt( 1 );
3415
 
836 mhunt 3416
        if ( result != 0 )
834 mhunt 3417
        {
3418
          // flag build failure
3419
          mLogger.fatal("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
868 mhunt 3420
          throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
834 mhunt 3421
        }
844 dpurdie 3422
        stmt.close();
834 mhunt 3423
        mConnection.commit();
3424
        disconnect();
3425
      }
3426
      catch( SQLException e )
3427
      {
3428
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3429
        {
3430
          mLogger.error("insertPackageMetrics database access error only");
3431
          throw new SQLException();
3432
        }
3433
        else
3434
        {
3435
          mLogger.fatal("insertPackageMetrics show stopper");
868 mhunt 3436
          throw new Exception("insertPackageMetrics show stopper");
834 mhunt 3437
        }
3438
      }
3439
    }
3440
  }
3441
 
3442
  /**handles database connection/disconnection
866 mhunt 3443
   * executes the Exclude_Indirect_From_Build stored procedure with the passed parameters
814 mhunt 3444
   */
3445
  public void excludeFromBuild(String packageVersionId, 
866 mhunt 3446
                               String packageVersion, String rtagId, String rootPvId,
3447
                               String rootCause, String rootFile) throws SQLException, Exception
814 mhunt 3448
  {
3449
    mLogger.debug("excludeFromBuild " + packageVersionId);
3450
    if ( mUseDatabase )
3451
    {
3452
      try
3453
      {
3454
        connect();
866 mhunt 3455
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
814 mhunt 3456
        stmt.registerOutParameter( 1, Types.INTEGER);
3457
        stmt.setString( 2, packageVersionId );
3458
        stmt.setString( 3, packageVersion );
3459
        stmt.setString( 4, rtagId );
3460
        stmt.setString( 5, "buildadm" );
866 mhunt 3461
        stmt.setString( 6, rootPvId);
3462
        stmt.setString( 7, rootCause);
3463
        stmt.setString( 8, rootFile);
814 mhunt 3464
        stmt.executeUpdate();
3465
        int result = stmt.getInt( 1 );
3466
 
3467
        if ( result != 0 )
3468
        {
3469
          // flag build failure
866 mhunt 3470
          mLogger.fatal( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
868 mhunt 3471
          throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
814 mhunt 3472
        }
844 dpurdie 3473
        stmt.close();
814 mhunt 3474
        mConnection.commit();
3475
        disconnect();
3476
      }
3477
      catch( SQLException e )
3478
      {
3479
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3480
        {
3481
          mLogger.error("excludeFromBuild database access error only");
3482
          throw new SQLException();
3483
        }
3484
        else
3485
        {
3486
          mLogger.fatal("excludeFromBuild show stopper");
868 mhunt 3487
          throw new Exception("excludeFromBuild show stopper");
814 mhunt 3488
        }
3489
      }
3490
    }
3491
  }
3492
 
866 mhunt 3493
  /**removes an excluded package from the do_not_ripple table
3494
   */
3495
  public void includeToBuild(String packageVersionId, String rtagId) throws SQLException, Exception
3496
  {
3497
    mLogger.debug("includeToBuild " + packageVersionId);
3498
    if ( mUseDatabase )
3499
    {
3500
      try
3501
      {
3502
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.do_not_ripple where rtag_id=" + rtagId + " and pv_id=" + packageVersionId);
3503
        stmt.executeUpdate();
3504
        stmt.close();
3505
        mConnection.commit();
3506
      }
3507
      catch( SQLException e )
3508
      {
3509
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3510
        {
3511
          mLogger.error("includeToBuild database access error only");
3512
          throw new SQLException();
3513
        }
3514
        else
3515
        {
3516
          mLogger.fatal("includeToBuild show stopper");
868 mhunt 3517
          throw new Exception("includeToBuild show stopper");
866 mhunt 3518
        }
3519
      }
3520
    }
3521
  }
3522
 
814 mhunt 3523
  /**Representation of a row in the RELEASE_CONFIG table
3524
   */
3525
  private class ReleaseConfig
3526
  {
3527
    /**rtag_id column value
3528
     * @attribute
3529
     */
3530
    private int mRtag_id;
3531
 
3532
    /**rcon_id column value
3533
     * @attribute
3534
     */
3535
    private int mRcon_id;
3536
 
3537
    /**daemon_mode column value
3538
     * @attribute
3539
     */
3540
    private char mDaemon_mode;
3541
 
3542
    /**gbebuildfilter column value
3543
     * @attribute
3544
     */
3545
    private String mGbebuildfilter;
3546
 
3547
    /**constructor
3548
     */
3549
    ReleaseConfig(int rtag_id, int rcon_id, char daemon_mode, 
3550
                  String gbebuildfilter)
3551
    {
3552
      mLogger.debug("ReleaseConfig rtag_id " + rtag_id + " rcon_id " + rcon_id + " daemon_mode " + daemon_mode + " gbebuildfilter " + gbebuildfilter );
3553
      mRtag_id = rtag_id;
3554
      mRcon_id = rcon_id;
3555
      mDaemon_mode = daemon_mode;
3556
      mGbebuildfilter = gbebuildfilter;
3557
    }
3558
 
3559
    /**accessor method
3560
     */
3561
    int get_rtag_id()
3562
    {
3563
      mLogger.debug("get_rtag_id");
3564
      mLogger.info("get_rtag_id returned " + mRtag_id);
3565
      return mRtag_id;
3566
    }
3567
 
3568
    /**accessor method
3569
     */
3570
    int get_rcon_id()
3571
    {
3572
      mLogger.debug("get_rcon_id");
3573
      mLogger.info("get_rcon_id returned " + mRcon_id);
3574
      return mRcon_id;
3575
    }
3576
 
3577
    /**accessor method
3578
     */
3579
    char get_daemon_mode()
3580
    {
3581
      mLogger.debug("get_daemon_mode");
3582
      mLogger.info("get_daemon_mode returned " + mDaemon_mode);
3583
      return mDaemon_mode;
3584
    }
3585
 
3586
    /**accessor method
3587
     */
3588
    String get_gbebuildfilter()
3589
    {
3590
      mLogger.debug("get_gbebuildfilter");
3591
      mLogger.info("get_gbebuildfilter returned " + mGbebuildfilter);
3592
      return mGbebuildfilter;
3593
    }
3594
  }
3595
 
3596
  /**Representation of a row in the RUN_LEVEL table
3597
   */
3598
  private class RunLevel
3599
  {
3600
    /**rcon_id column value
3601
     * @attribute
3602
     */
3603
    private int mRcon_id;
3604
 
3605
    /**current_build_files column value
3606
     * @attribute
3607
     */
3608
    private String mCurrent_build_file;
3609
 
3610
    /**current_run_level column value
3611
     * @attribute
3612
     */
3613
    private int mCurrent_run_level;
3614
 
3615
    /**pause column value
3616
     * @attribute
3617
     */
3618
    private boolean mPause;
3619
 
3620
    /**constructor
3621
     */
3622
    RunLevel(int rcon_id, String current_build_file, int current_run_level, 
3623
             boolean pause)
3624
    {
3625
      mLogger.debug("RunLevel");
3626
      mRcon_id = rcon_id;
3627
      mCurrent_build_file = current_build_file;
3628
      mCurrent_run_level = current_run_level;
3629
      mPause = pause;
3630
    }
3631
 
3632
    /**accessor method
3633
     */
3634
    int get_rcon_id()
3635
    {
3636
      mLogger.debug("get_rcon_id");
3637
      mLogger.info("get_rcon_id returned " + mRcon_id);
3638
      return mRcon_id;
3639
    }
3640
 
3641
    /**accessor method
3642
     */
3643
    String get_current_build_file()
3644
    {
3645
      mLogger.debug("get_current_build_file");
3646
      mLogger.info("get_current_build_file returned " + mCurrent_build_file);
3647
      return mCurrent_build_file;
3648
    }
3649
 
3650
    /**accessor method
3651
     */
3652
    int get_current_run_level()
3653
    {
3654
      mLogger.debug("get_current_run_level");
3655
      mLogger.info("get_current_run_level returned " + mCurrent_run_level);
3656
      return mCurrent_run_level;
3657
    }
3658
 
3659
    /**accessor method
3660
     */
3661
    boolean get_pause()
3662
    {
3663
      mLogger.debug("get_pause");
3664
      mLogger.debug("get_pause returned " + mPause);      
3665
      return mPause;
3666
    }
3667
 
3668
  }
3669
 
3670
  /**constructor
3671
   */
3672
  public ReleaseManager(final String connectionString, final String username, 
3673
                        final String password)
3674
  {
3675
    mLogger.debug("ReleaseManager " + connectionString);
3676
    mConnectionString = connectionString;
3677
    mUsername = username;
3678
    mPassword = password;
3679
  }
3680
 
3681
  /**constructor used when schema information is unknown eg location, username, password
3682
   */
3683
  public ReleaseManager()
3684
  {
3685
    // inherit mConnectionString, mUsername, mPassword
3686
     mLogger.debug("ReleaseManager");
3687
  }
3688
 
3689
  /**connect to oracle
3690
   */
3691
  public void connect() throws SQLException, Exception
3692
  {
3693
    mLogger.debug("connect");
850 mhunt 3694
    mSession.lock();
814 mhunt 3695
 
3696
    if ( !mUseDatabase )
3697
    {
3698
      mLogger.info("connect !mUseDatabase");
3699
    }
3700
    else
3701
    {
3702
      if ( !mRegistered )
3703
      {
3704
        try
3705
        {
3706
          // the JDBC driver is registered only once per database that needs to be accessed
3707
          mLogger.debug("connect registering driver");
3708
          DriverManager.registerDriver( new OracleDriver() );
3709
          mRegistered = true;
3710
        }
3711
        catch(SQLException e)
3712
        {
3713
          mLogger.fatal("connect failed to register the oracle jdbc driver with the driver manager");
868 mhunt 3714
          throw new Exception("connect failed to register the oracle jdbc driver with the driver manager");
814 mhunt 3715
        }
3716
      }
3717
 
838 mhunt 3718
      // DEVI 46868
3719
      // loop indefinitely until a connection attempt succeeds
3720
      // unless the failure is on the first attempt
3721
      boolean problemConnecting;
3722
 
3723
      do
814 mhunt 3724
      {
850 mhunt 3725
        mLogger.warn("connect check connection");
838 mhunt 3726
        problemConnecting = false;
3727
 
3728
        try
836 mhunt 3729
        {
850 mhunt 3730
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
838 mhunt 3731
          {
850 mhunt 3732
            mLogger.warn("connect calling getConnection");
838 mhunt 3733
            mConnection = DriverManager.getConnection(mConnectionString, mUsername, mPassword);
3734
          }
836 mhunt 3735
        }
838 mhunt 3736
        catch(SQLException e)
3737
        {
850 mhunt 3738
          mLogger.warn("connect determined problem connecting");
838 mhunt 3739
          problemConnecting = true;
3740
          try
3741
          {
3742
            // sleep 30 secs
844 dpurdie 3743
            mLogger.warn("connect getConnection failed. sleep 30secs");
838 mhunt 3744
            Thread.sleep(30000);
3745
          }
3746
          catch (InterruptedException f)
3747
          {
3748
            mLogger.warn("connect caught InterruptedException");
3749
          }
3750
 
844 dpurdie 3751
 
838 mhunt 3752
          if ( mConnection == null )
3753
          {
3754
            // failed on first connection attempt - unlikely due to database loading - likely bad connection parameters
3755
            throw new SQLException();
3756
          }
3757
        }
3758
      } while ( problemConnecting );
814 mhunt 3759
    }
844 dpurdie 3760
 
814 mhunt 3761
  }
3762
 
3763
  /**disconnect from oracle
3764
   */
836 mhunt 3765
  public void disconnect() throws Exception
814 mhunt 3766
  {
3767
    mLogger.debug("disconnect");
838 mhunt 3768
/* DEVI 46868 
3769
 * never disconnect, thus the only time a connection attempt is made
3770
 * is when the server has (timed out) disconnected the session
3771
 *  if ( mUseDatabase )
814 mhunt 3772
    {
3773
      try
3774
      {
3775
        mConnection.close();
3776
      }
3777
      catch(SQLException e)
3778
      {
3779
        mLogger.error("disconnect caught Exception");
836 mhunt 3780
        throw new Exception();
814 mhunt 3781
      }
838 mhunt 3782
    }*/
850 mhunt 3783
    mSession.unlock();
814 mhunt 3784
  }
3785
 
3786
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id of the first element
3787
   */
3788
  public boolean getFirstReleaseConfig(MutableInt rcon_id)
3789
  {
3790
    mLogger.debug("getFirstReleaseConfig 1");
3791
    boolean retVal = true;
3792
 
3793
    try
3794
    {
3795
      mReleaseConfigIndex = 0;
864 mhunt 3796
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3797
      rcon_id.value = rc.get_rcon_id();
3798
    }
3799
    catch( ArrayIndexOutOfBoundsException e )
3800
    {
3801
      retVal = false;
3802
    }
3803
 
3804
    mLogger.info("getFirstReleaseConfig 1 returning " + retVal);
3805
    return retVal;
3806
  }
3807
 
3808
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the first element
3809
   */
3810
  public boolean getFirstReleaseConfig(MutableInt rtag_id, 
3811
                                       MutableInt rcon_id, 
3812
                                       MutableChar daemon_mode, 
3813
                                       MutableString gbebuildfilter)
3814
  {
3815
    mLogger.debug("getFirstReleaseConfig 2");
3816
    boolean retVal = true;
3817
 
3818
    try
3819
    {
3820
      mReleaseConfigIndex = 0;
864 mhunt 3821
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3822
      rtag_id.value = rc.get_rtag_id();
3823
      rcon_id.value = rc.get_rcon_id();
3824
      daemon_mode.value = rc.get_daemon_mode();
3825
      gbebuildfilter.value = rc.get_gbebuildfilter();
3826
    }
3827
    catch( ArrayIndexOutOfBoundsException e )
3828
    {
3829
      retVal = false;
3830
    }
3831
 
3832
    mLogger.info("getFirstReleaseConfig 2 returning " + retVal);
3833
    return retVal;
3834
  }
3835
 
3836
  /**returns true if the mRunLevelCollection is not empty and returns the rcon_id and current_run_level of the first element
3837
   */
3838
  public boolean getFirstRunLevel(MutableInt rcon_id, 
3839
                                  MutableInt current_run_level)
3840
  {
3841
    mLogger.debug("getFirstRunLevel");
3842
    boolean retVal = true;
3843
 
3844
    try
3845
    {
3846
      mRunLevelIndex = 0;
864 mhunt 3847
      RunLevel rl = mRunLevelCollection.get( mRunLevelIndex );
814 mhunt 3848
      rcon_id.value = rl.get_rcon_id();
3849
      current_run_level.value = rl.get_current_run_level();
3850
    }
3851
    catch( ArrayIndexOutOfBoundsException e )
3852
    {
3853
      retVal = false;
3854
    }
3855
 
3856
    mLogger.info("getFirstRunLevel returning " + retVal);
3857
    return retVal;
3858
  }
3859
 
3860
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id of the next element
3861
   */
3862
  public boolean getNextReleaseConfig(MutableInt rcon_id)
3863
  {
3864
    mLogger.debug("getNextReleaseConfig 1");
3865
    boolean retVal = true;
3866
 
3867
    try
3868
    {
3869
      mReleaseConfigIndex++;
864 mhunt 3870
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3871
      rcon_id.value = rc.get_rcon_id();
3872
    }
3873
    catch( ArrayIndexOutOfBoundsException e )
3874
    {
3875
      retVal = false;
3876
    }
3877
 
3878
    mLogger.info("getNextReleaseConfig 1 returning " + retVal);
3879
    return retVal;
3880
  }
3881
 
3882
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the next element
3883
   */
3884
  public boolean getNextReleaseConfig(MutableInt rtag_id, 
3885
                                      MutableInt rcon_id, 
3886
                                      MutableChar daemon_mode, 
3887
                                      MutableString gbebuildfilter)
3888
  {
3889
    mLogger.debug("getNextReleaseConfig 2");
3890
    boolean retVal = true;
3891
 
3892
    try
3893
    {
3894
      mReleaseConfigIndex++;
864 mhunt 3895
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3896
      rtag_id.value = rc.get_rtag_id();
3897
      rcon_id.value = rc.get_rcon_id();
3898
      daemon_mode.value = rc.get_daemon_mode();
3899
      gbebuildfilter.value = rc.get_gbebuildfilter();
3900
    }
3901
    catch( ArrayIndexOutOfBoundsException e )
3902
    {
3903
      retVal = false;
3904
    }
3905
 
3906
    mLogger.info("getNextReleaseConfig 2 returning " + retVal);
3907
    return retVal;
3908
  }
3909
 
3910
  /**returns true if the mRunLevelCollection contains a next element and returns the rcon_id and current_run_level of the next element
3911
   */
3912
  public boolean getNextRunLevel(MutableInt rcon_id, 
3913
                                 MutableInt current_run_level)
3914
  {
3915
    mLogger.debug("getNextRunLevel");
3916
    boolean retVal = true;
3917
 
3918
    try
3919
    {
3920
      mRunLevelIndex++;
864 mhunt 3921
      RunLevel rl = mRunLevelCollection.get( mRunLevelIndex );
814 mhunt 3922
      rcon_id.value = rl.get_rcon_id();
3923
      current_run_level.value = rl.get_current_run_level();
3924
    }
3925
    catch( ArrayIndexOutOfBoundsException e )
3926
    {
3927
      retVal = false;
3928
    }
3929
 
3930
    mLogger.info("getNextRunLevel returning " + retVal);
3931
    return retVal;
3932
  }
3933
 
3934
  /**queries the RUN_LEVEL table using the rcon_id primary key
3935
   * returns false if the query returns a result set containing one row with a non NULL pause column
3936
   * (indicating intent to pause the thread)
3937
   * refer to sequence diagram allowed to proceed
3938
   */
3939
  public boolean queryDirectedRunLevel(final int rcon_id) throws SQLException, Exception
3940
  {
3941
    mLogger.debug("queryDirectedRunLevel " + rcon_id);
3942
    boolean retVal = true;
3943
 
3944
    if ( mUseDatabase )
3945
    {
3946
      try
3947
      {
3948
        CallableStatement stmt = mConnection.prepareCall("select pause from release_manager.run_level where rcon_id=" + rcon_id);
3949
        ResultSet rset = stmt.executeQuery();
3950
        int rsetSize = 0;
3951
 
3952
        while( rset.next() )
3953
        {
3954
          rsetSize++;
3955
          rset.getInt("pause");
3956
 
3957
          if ( !rset.wasNull() )
3958
          {
3959
            retVal = false;
3960
          }
3961
        }
830 mhunt 3962
 
3963
        rset.close();
3964
        stmt.close();
814 mhunt 3965
 
3966
        if ( rsetSize > 1 )
3967
        {
3968
          mLogger.fatal("queryDirectedRunLevel rsetSize > 1");
3969
          // show stopper
868 mhunt 3970
          throw new Exception("queryDirectedRunLevel rsetSize > 1");
814 mhunt 3971
        }
3972
      }
3973
      catch ( SQLException e )
3974
      {
3975
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3976
        {
3977
          mLogger.error("queryDirectedRunLevel database access error only");
3978
          throw new SQLException();
3979
        }
3980
        else
3981
        {
3982
          mLogger.fatal("queryDirectedRunLevel show stopper");
868 mhunt 3983
          throw new Exception("queryDirectedRunLevel show stopper");
814 mhunt 3984
        }
3985
      }
3986
    }
3987
 
3988
    mLogger.info("queryDirectedRunLevel returning " + retVal);
3989
    return retVal;
3990
  }
3991
 
3992
  /**queries the RELEASE_CONFIG table using the rcon_id primary key, rtag_id, daemon_hostname, daemon_mode, gbebuildfilter
3993
   * return true if the query contains a result set containing one row
3994
   * (indicating the rcon_id is still configured and its configuration is unchanged)
3995
   * refer to sequence diagram allowed to proceed
3996
   */
3997
  public boolean queryReleaseConfig(final int rtag_id, final int rcon_id, 
3998
                                    final String daemon_hostname, 
3999
                                    final char daemon_mode, 
4000
                                    final String gbebuildfilter) throws SQLException, Exception
4001
  {
4002
    mLogger.debug("queryReleaseConfig 1");
4003
    boolean retVal = false;
4004
 
4005
    if ( !mUseDatabase )
4006
    {
4007
      mLogger.info("queryReleaseConfig 1 !mUseDatabase");
4008
 
4009
      if ( mConnectionString.compareTo("unit test exit") != 0 )
4010
      {
4011
        retVal = true;
4012
      }
4013
    }
4014
    else
4015
    {
4016
      try
4017
      {
856 mhunt 4018
        String sql = new String("select rc.gbe_buildfilter from release_manager.release_config rc, release_manager.release_tags rt where rc.rtag_id=" + rtag_id + " and rc.rcon_id=" + rcon_id + " and rc.daemon_hostname='" + daemon_hostname + "' and rc.daemon_mode='" + daemon_mode + "' and rt.rtag_id=rc.rtag_id and (rt.official = 'N' or rt.official='R' or rt.official='C')" );
814 mhunt 4019
        CallableStatement stmt = mConnection.prepareCall( sql );
4020
        ResultSet rset = stmt.executeQuery();
4021
        int rsetSize = 0;
4022
 
4023
        while( rset.next() )
4024
        {
4025
          rsetSize++;
4026
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4027
 
4028
          if ( gbe_buildfilter == null )
4029
          {
4030
            mLogger.info("queryReleaseConfig 1 gbe_buildfilter == null");
4031
            if ( gbebuildfilter.length() == 0 )
4032
            {
4033
              retVal = true;
4034
            }
4035
          }
4036
          else
4037
          {
4038
            if ( gbebuildfilter.compareTo( gbe_buildfilter ) == 0 )
4039
            {
4040
              retVal = true;
4041
            }
4042
          }
4043
        }
830 mhunt 4044
 
4045
        rset.close();
4046
        stmt.close();
814 mhunt 4047
 
4048
        if ( rsetSize > 1 )
4049
        {
4050
          mLogger.fatal("queryReleaseConfig 1 rsetSize > 1");
4051
          // show stopper
868 mhunt 4052
          throw new Exception("queryReleaseConfig 1 rsetSize > 1");
814 mhunt 4053
        }
4054
      }
4055
      catch ( SQLException e )
4056
      {
4057
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4058
        {
4059
          mLogger.error("queryReleaseConfig 1 database access error only");
4060
          throw new SQLException();
4061
        }
4062
        else
4063
        {
4064
          mLogger.fatal("queryReleaseConfig 1 show stopper");
868 mhunt 4065
          throw new Exception("queryReleaseConfig 1 show stopper");
814 mhunt 4066
        }
4067
      }
4068
    }
4069
 
4070
    mLogger.info("queryReleaseConfig 1 returning " + retVal);
4071
    return retVal;
4072
  }
4073
 
4074
  /**removes all elements from the mReleaseConfigCollection
4075
   * handles database connection and disconnection
4076
   * queries the RELEASE_CONFIG table using the rtag_id
4077
   * populates the mReleaseConfigCollection with the query result set
4078
   * partially implements the sequence diagrams coordinate slave threads generate build files
4079
   */
4080
  public void queryReleaseConfig(final int rtag_id) throws SQLException, Exception
4081
  {
4082
    mLogger.debug("queryReleaseConfig 2");
4083
    mReleaseConfigCollection.removeAllElements();
4084
 
4085
    if ( !mUseDatabase )
4086
    {
4087
      mLogger.info("queryReleaseConfig 2 !mUseDatabase");
4088
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unittestbuildfilter");
4089
      mReleaseConfigCollection.add(releaseConfig);
4090
      releaseConfig = new ReleaseConfig(1,2,'S',"anotherunittestbuildfilter");
4091
      mReleaseConfigCollection.add(releaseConfig);
4092
    }
4093
    else
4094
    {
4095
      try
4096
      {
4097
        connect();
4098
        CallableStatement stmt = mConnection.prepareCall("select rcon_id, daemon_mode, gbe_buildfilter from release_manager.release_config where rtag_id=" + rtag_id );
4099
        ResultSet rset = stmt.executeQuery();
4100
 
4101
        while( rset.next() )
4102
        {
4103
          int rcon_id = rset.getInt("rcon_id");
4104
 
4105
          if ( rset.wasNull() )
4106
          {
4107
            mLogger.fatal("queryReleaseConfig 2 null rcon_id " + rtag_id);
4108
            // show stopper
868 mhunt 4109
            throw new Exception("queryReleaseConfig 2 null rcon_id " + rtag_id);
814 mhunt 4110
          }
4111
 
4112
          char dm = 'S';          
4113
          String daemon_mode = rset.getString("daemon_mode");
4114
 
4115
          if ( daemon_mode != null )
4116
          {
4117
            mLogger.info("queryReleaseConfig 2 daemon_mode " + daemon_mode + ".");
4118
 
4119
            if ( daemon_mode.compareTo("M") == 0 )
4120
            {
4121
              dm = 'M';
4122
            }
4123
          }
4124
 
4125
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4126
 
4127
          if ( gbe_buildfilter == null )
4128
          {
4129
            gbe_buildfilter = new String("");
4130
          }
4131
 
4132
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4133
          mReleaseConfigCollection.add(releaseConfig);
4134
        }
4135
 
830 mhunt 4136
 
4137
        rset.close();
4138
        stmt.close();
814 mhunt 4139
        disconnect();
4140
      }
4141
      catch ( SQLException e )
4142
      {
4143
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4144
        {
4145
          mLogger.error("queryReleaseConfig 2 daemon_mode database access error only");
4146
          throw new SQLException();
4147
        }
4148
        else
4149
        {
4150
          mLogger.fatal("queryReleaseConfig 2 show stopper");
868 mhunt 4151
          throw new Exception("queryReleaseConfig 2 show stopper");
814 mhunt 4152
        }
4153
      }
4154
    }
4155
  }
4156
 
4157
  /**removes all elements from the mReleaseConfigCollection
4158
   * handles database connection and disconnection
4159
   * queries the RELEASE_CONFIG table using the daemon_hostname
4160
   * populates the mReleaseConfigCollection with the query result set
4161
   * partially implements the sequence diagram spawn thread
4162
   */
4163
  public void queryReleaseConfig(final String hostname) throws SQLException, Exception
4164
  {
4165
    mLogger.debug("queryReleaseConfig 3 " + hostname);
4166
    mReleaseConfigCollection.removeAllElements();
4167
 
4168
    if ( mConnectionString.compareTo("unit test spawn thread") == 0)
4169
    {
4170
      mLogger.info("queryReleaseConfig 3 unit test spawn thread");
4171
      // specifying a gbebuildfilter of unit test is designed to invoke a benign thread for unit test purposes
4172
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unit test spawn thread");
4173
      mReleaseConfigCollection.add(releaseConfig);
4174
      releaseConfig = new ReleaseConfig(2,2,'S',"unit test spawn thread");
4175
      mReleaseConfigCollection.add(releaseConfig);
4176
    }
4177
    else
4178
    {
4179
      try
4180
      {
4181
        connect();
856 mhunt 4182
        CallableStatement stmt = mConnection.prepareCall("select rc.rtag_id, rc.rcon_id, rc.daemon_mode, rc.gbe_buildfilter from release_manager.release_config rc, release_manager.release_tags rt where rc.daemon_hostname='" + hostname + "' and rt.rtag_id=rc.rtag_id and (rt.official = 'N' or rt.official='R' or rt.official='C')" );
814 mhunt 4183
        ResultSet rset = stmt.executeQuery();
4184
 
4185
        while( rset.next() )
4186
        {
4187
          int rtag_id = rset.getInt("rtag_id");
4188
 
4189
          if ( rset.wasNull() )
4190
          {
4191
            mLogger.fatal("queryReleaseConfig 3 null rtag_id");
4192
            // show stopper
868 mhunt 4193
            throw new Exception("queryReleaseConfig 3 null rtag_id");
814 mhunt 4194
          }
4195
 
4196
          int rcon_id = rset.getInt("rcon_id");
4197
 
4198
          if ( rset.wasNull() )
4199
          {
4200
            mLogger.fatal("queryReleaseConfig 3 null rcon_id");
4201
            // show stopper
868 mhunt 4202
            throw new Exception("queryReleaseConfig 3 null rcon_id");
814 mhunt 4203
          }
4204
 
4205
          char dm = 'S';          
4206
          String daemon_mode = rset.getString("daemon_mode");
4207
 
4208
          if ( daemon_mode != null )
4209
          {
4210
            mLogger.info("queryReleaseConfig 3 daemon_mode " + daemon_mode + ".");
4211
 
4212
            if ( daemon_mode.compareTo("M") == 0 )
4213
            {
4214
              dm = 'M';
4215
            }
4216
          }
4217
 
4218
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4219
 
4220
          if ( gbe_buildfilter == null )
4221
          {
4222
            gbe_buildfilter = new String("");
4223
          }
4224
 
4225
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4226
          mReleaseConfigCollection.add(releaseConfig);
4227
        }
4228
 
830 mhunt 4229
        rset.close();
4230
        stmt.close();
814 mhunt 4231
        disconnect();
4232
      }
4233
      catch ( SQLException e )
4234
      {
4235
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4236
        {
4237
          mLogger.error("queryReleaseConfig 3 database access error only");
4238
          throw new SQLException();
4239
        }
4240
        else
4241
        {
4242
          mLogger.fatal("queryReleaseConfig 3 show stopper");
868 mhunt 4243
          throw new Exception("queryReleaseConfig 3 show stopper");
814 mhunt 4244
        }
4245
      }
4246
    }
4247
  }
4248
 
4249
  /**queries the RUN_LEVEL table using the rcon_id primary key
4250
   * handles database connection and disconnection
4251
   * polls indefinitely until CURRENT_BUILD_FILES column is non NULL
4252
   * returns the current_build_files
4253
   * implements the sequence diagram consume build files
4254
   */
4255
  public void queryRunLevel(int rcon_id, MutableString currentBuildFiles) throws SQLException, Exception
4256
  {
4257
    mLogger.debug("queryRunLevel 1 rcon_id " + rcon_id);
4258
    if ( !mUseDatabase )
4259
    {
4260
      mLogger.info("queryRunLevel 1 !mUseDatabase");
4261
      currentBuildFiles.value = "unit test build file content";
4262
    }
4263
    else
4264
    {
4265
      try
4266
      {
4267
        connect();
4268
        CallableStatement stmt = mConnection.prepareCall("select current_build_files from release_manager.run_level where rcon_id=" + rcon_id);
4269
        ResultSet rset = stmt.executeQuery();
4270
        int rsetSize = 0;
4271
 
4272
        while( rset.next() )
4273
        {
4274
          rsetSize++;
4275
          currentBuildFiles.value = rset.getString("current_build_files");
4276
          if (rset.wasNull())
4277
          {
4278
            currentBuildFiles.value = "";
4279
          }
4280
        }
4281
 
4282
        if ( rsetSize > 1 )
4283
        {
4284
          mLogger.fatal("queryRunLevel 1 rsetSize > 1");
4285
          // show stopper
868 mhunt 4286
          throw new Exception("queryRunLevel 1 rsetSize > 1");
814 mhunt 4287
        }
4288
 
830 mhunt 4289
        rset.close();
4290
        stmt.close();
814 mhunt 4291
        disconnect();
4292
      }
4293
      catch ( SQLException e )
4294
      {
4295
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4296
        {
4297
          mLogger.error("queryRunLevel 1 database access error only");
4298
          throw new SQLException();
4299
        }
4300
        else
4301
        {
4302
          mLogger.fatal("queryRunLevel 1 show stopper");
868 mhunt 4303
          throw new Exception("queryRunLevel 1 show stopper");
814 mhunt 4304
        }
4305
      }
4306
    }
4307
  }
4308
 
4309
  /**removes all elements from the mRunLevelCollection
4310
   * handles database connection and disconnection
4311
   *   select rl.rcon_id, rl.current_run_level from release_config rc, run_level rl
4312
   *   where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id;
4313
   * populates the mRunLevelCollection with the query result set
4314
   * refer to sequence diagram coordinate slave threads
4315
   */
4316
  public void queryRunLevel(final int rtag_id) throws SQLException, Exception
4317
  {
4318
    mLogger.debug("queryRunLevel 2 rtag_id " + rtag_id);
4319
    if ( mConnectionString.compareTo("unit test coordinate slave threads") == 0)
4320
    {
4321
      mLogger.info("queryRunLevel 2 unit test coordinate slave threads");
4322
 
4323
      if ( mRunLevelCollection.size() == 0)
4324
      {
4325
        // first time not all slave threads are waiting
4326
        RunLevel runLevel = new RunLevel(1, "", DB_WAITING, false);
4327
        mRunLevelCollection.add(runLevel);
4328
        runLevel = new RunLevel(2, "", DB_IDLE, false);
4329
        mRunLevelCollection.add(runLevel);
4330
      }
4331
      else
4332
      {
4333
        // subsequent times all slave threads are waiting
4334
        mRunLevelCollection.removeAllElements();
4335
        RunLevel runLevel = new RunLevel(1, "", DB_WAITING, false);
4336
        mRunLevelCollection.add(runLevel);
4337
        runLevel = new RunLevel(2, "", DB_WAITING, false);
4338
        mRunLevelCollection.add(runLevel);
4339
      }
4340
    }
4341
 
4342
    if ( mUseDatabase )
4343
    {
4344
      mRunLevelCollection.removeAllElements();
4345
 
4346
      try
4347
      {
4348
        connect();
4349
        CallableStatement stmt = mConnection.prepareCall(
4350
        "select rl.rcon_id, rl.current_run_level from release_config rc, run_level rl " +
4351
        "where rc.rtag_id=" +rtag_id + " and rl.rcon_id=rc.rcon_id");
4352
        ResultSet rset = stmt.executeQuery();
4353
        int rsetSize = 0;
4354
        int rcon_id = 0;
4355
        int current_run_level = 0;
4356
 
4357
        while( rset.next() )
4358
        {
4359
          rsetSize++;
4360
          rcon_id = rset.getInt("rcon_id");
4361
 
4362
          if ( rset.wasNull() )
4363
          {
4364
            mLogger.fatal("queryRunLevel 2 null rcon_id");
4365
            // show stopper
868 mhunt 4366
            throw new Exception("queryRunLevel 2 null rcon_id");
814 mhunt 4367
          }
4368
 
4369
          current_run_level = rset.getInt("current_run_level");
4370
 
4371
          if ( rset.wasNull() )
4372
          {
4373
            mLogger.fatal("queryRunLevel 2 null current_run_level");
4374
            // show stopper
868 mhunt 4375
            throw new Exception("queryRunLevel 2 null current_run_level");
814 mhunt 4376
          }
4377
 
4378
          RunLevel runLevel = new RunLevel(rcon_id, "", current_run_level, false);
4379
          mRunLevelCollection.add(runLevel);
4380
        }
4381
 
4382
        if ( rsetSize == 0 )
4383
        {
4384
          mLogger.fatal("queryRunLevel 2 rsetSize == 0");
4385
          // show stopper
868 mhunt 4386
          throw new Exception("queryRunLevel 2 rsetSize == 0");
814 mhunt 4387
        }
4388
 
830 mhunt 4389
        rset.close();
4390
        stmt.close();
814 mhunt 4391
        disconnect();
4392
      }
4393
      catch ( SQLException e )
4394
      {
4395
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4396
        {
4397
          mLogger.error("queryRunLevel 2 database access error only");
4398
          throw new SQLException();
4399
        }
4400
        else
4401
        {
4402
          mLogger.fatal("queryRunLevel 2 show stopper");
868 mhunt 4403
          throw new Exception("queryRunLevel 2 show stopper");
814 mhunt 4404
        }
4405
      }
4406
 
4407
 
4408
    }
4409
  }
4410
 
818 mhunt 4411
  /**removes all elements from the mRunLevelCollection
4412
   * handles database connection and disconnection
4413
   *   select rcon_id, current_run_level from run_level
4414
   *   where rcon_id=<rcon_id>;
4415
   * populates the mRunLevelCollection with the query result set
4416
   */
4417
  public void querySingleRunLevel(final int rcon_id) throws SQLException, Exception
4418
  {
4419
    mLogger.debug("querySingleRunLevel rcon_id " + rcon_id);
4420
    if ( !mUseDatabase )
4421
    {
4422
      mLogger.info("querySingleRunLevel !mUseDatabase");
4423
 
4424
      mRunLevelCollection.removeAllElements();
4425
      RunLevel runLevel = new RunLevel(rcon_id, "", DB_ACTIVE, false);
4426
      mRunLevelCollection.add(runLevel);
4427
    }
4428
    else
4429
    {
4430
      mRunLevelCollection.removeAllElements();
4431
 
4432
      try
4433
      {
4434
        connect();
4435
        CallableStatement stmt = mConnection.prepareCall(
4436
        "select rcon_id, current_run_level from run_level " +
4437
        "where rcon_id=" +rcon_id);
4438
        ResultSet rset = stmt.executeQuery();
4439
        int rsetSize = 0;
4440
        int current_run_level = 0;
4441
 
4442
        while( rset.next() )
4443
        {
4444
          rsetSize++;
4445
          current_run_level = rset.getInt("current_run_level");
4446
 
4447
          if ( rset.wasNull() )
4448
          {
4449
            mLogger.fatal("querySingleRunLevel null current_run_level");
4450
            // show stopper
868 mhunt 4451
            throw new Exception("querySingleRunLevel null current_run_level");
818 mhunt 4452
          }
4453
 
4454
          RunLevel runLevel = new RunLevel(rcon_id, "", current_run_level, false);
4455
          mRunLevelCollection.add(runLevel);
4456
        }
4457
 
4458
        if ( rsetSize != 1 )
4459
        {
4460
          mLogger.fatal("querySingleRunLevel rsetSize != 1");
4461
          // show stopper
868 mhunt 4462
          throw new Exception("querySingleRunLevel rsetSize != 1");
818 mhunt 4463
        }
4464
 
830 mhunt 4465
        rset.close();
4466
        stmt.close();
818 mhunt 4467
        disconnect();
4468
      }
4469
      catch ( SQLException e )
4470
      {
4471
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4472
        {
4473
          mLogger.error("querySingleRunLevel database access error only");
4474
          throw new SQLException();
4475
        }
4476
        else
4477
        {
4478
          mLogger.fatal("querySingleRunLevel show stopper");
868 mhunt 4479
          throw new Exception("querySingleRunLevel show stopper");
818 mhunt 4480
        }
4481
      }
4482
    }
4483
  }
4484
 
814 mhunt 4485
  /**queries the RUN_LEVEL_SCHEDULE table
4486
   * returns false if a row in the query result set indicates build service downtime is scheduled
4487
   * returns false if a row in the query result set has a non NULL indefinite_pause
4488
   * refer to the sequence diagram allowed to proceed
4489
   */
4490
  public boolean queryRunLevelSchedule(Date resumeTime) throws SQLException, Exception
4491
  {
4492
    mLogger.debug("queryRunLevelSchedule");
4493
    boolean retVal = true;
4494
 
4495
    if ( !mUseDatabase )
4496
    {
4497
      mLogger.info("queryRunLevelSchedule !mUseDatabase");
4498
 
4499
      if ( mConnectionString.compareTo("unit test not allowed to proceed") == 0 )
4500
      {
4501
        // schedule a 100ms max wait
4502
        resumeTime.setTime( resumeTime.getTime() + 100 );
4503
        retVal = false;
4504
      }
4505
    }
4506
    else
4507
    {
4508
      try
4509
      {
4510
        CallableStatement stmt = mConnection.prepareCall("select scheduled_pause, scheduled_resume, repeat, indefinite_pause from release_manager.run_level_schedule");
4511
        ResultSet rset = stmt.executeQuery();
4512
        Date now = new Date();
844 dpurdie 4513
 
4514
 
4515
        //
846 dpurdie 4516
        //  Scan the database information and determine if there is any reason
844 dpurdie 4517
        //  to pause. Terminate the loop on the first excuse to pause
4518
        //  as indefinite pause may have multiple (lots) of entries in the data
4519
        //  base.
4520
        //
4521
        while( retVal == true && rset.next() )
814 mhunt 4522
        {
846 dpurdie 4523
          //
4524
          //  Examine the current row from the data base
4525
          //  Expect one of two forms:
4526
          //    1) scheduled_pause
4527
          //       Must also have a scheduled_resume and a repeat
4528
          //    2) indefinite_pause
4529
          //
4530
 
4531
          //  Look for scheduled_pause style of entry
4532
          //
814 mhunt 4533
          Timestamp sp = rset.getTimestamp("scheduled_pause");
4534
          if ( sp != null )
4535
          {
4536
            Date scheduled_pause = new Date( sp.getTime() );
4537
            Timestamp sr = rset.getTimestamp("scheduled_resume");
4538
 
4539
            if ( sr != null )
4540
            {
4541
              Date scheduled_resume = new Date( sr.getTime() );
4542
              int repeat = rset.getInt("repeat");
4543
              mLogger.info("queryRunLevelSchedule repeat " + repeat);
846 dpurdie 4544
 
4545
              //
4546
              //  Have scheduled_pause and scheduled_resume
4547
              //  Examine the repeat field and determine how these are used
4548
              //  Supported repeat:
4549
              //      Once Only
4550
              //      Daily           Year, Month and Day information is ignored
4551
              //      Weekly          Only day of week is utilised
4552
              //
814 mhunt 4553
              if ( !rset.wasNull() )
4554
              {
4555
                switch( repeat )
4556
                {
4557
                  case 0:
4558
                  {
4559
                    // one off
4560
                    if ( scheduled_pause.before(now) && scheduled_resume.after(now) )
4561
                    {
4562
                      mLogger.warn("queryRunLevelSchedule one off scheduled downtime");
838 mhunt 4563
                      resumeTime = scheduled_resume;
814 mhunt 4564
                      retVal = false;
4565
                    }
4566
                    break;
4567
                  }
4568
                  case 1:
4569
                  {
846 dpurdie 4570
                    //  daily
4571
                    //  Create start and end fimes, then massage some fields
4572
                    //  to reflect todays date
4573
                    //
814 mhunt 4574
                    GregorianCalendar startOfDowntime = new GregorianCalendar();
4575
                    startOfDowntime.setTime(scheduled_pause);
4576
                    GregorianCalendar endOfDowntime = new GregorianCalendar();
4577
                    endOfDowntime.setTime(scheduled_resume);
4578
                    GregorianCalendar clock = new GregorianCalendar();
4579
                    clock.setTime(now);
846 dpurdie 4580
 
4581
                    // Force date fields to todays date
4582
                    endOfDowntime.set  ( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4583
                    startOfDowntime.set( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4584
 
814 mhunt 4585
                    if ( startOfDowntime.before(clock) && endOfDowntime.after(clock) )
4586
                    {
4587
                      mLogger.warn("queryRunLevelSchedule daily scheduled downtime");
838 mhunt 4588
                      resumeTime.setTime(endOfDowntime.getTimeInMillis());
814 mhunt 4589
                      retVal = false;
4590
                    }
4591
                    break;
4592
                  }
4593
                  case 7:
4594
                  {
4595
                    // weekly
846 dpurdie 4596
                    // Create start and end times, then massage some fields
4597
                    // to reflect todays date
4598
                    //
814 mhunt 4599
                    GregorianCalendar startOfDowntime = new GregorianCalendar();
4600
                    startOfDowntime.setTime(scheduled_pause);
4601
                    GregorianCalendar endOfDowntime = new GregorianCalendar();
4602
                    endOfDowntime.setTime(scheduled_resume);
4603
                    GregorianCalendar clock = new GregorianCalendar();
4604
                    clock.setTime(now);
846 dpurdie 4605
 
4606
                    // Only interested in one day of the week
814 mhunt 4607
                    if ( startOfDowntime.get(Calendar.DAY_OF_WEEK) == clock.get(Calendar.DAY_OF_WEEK) )
4608
                    {
846 dpurdie 4609
                      endOfDowntime.set  ( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4610
                      startOfDowntime.set( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
814 mhunt 4611
 
4612
                      if ( startOfDowntime.before(clock) && endOfDowntime.after(clock) )
4613
                      {
4614
                        mLogger.warn("queryRunLevelSchedule weekly scheduled downtime");
838 mhunt 4615
                        resumeTime.setTime(endOfDowntime.getTimeInMillis());
814 mhunt 4616
                        retVal = false;
4617
                      }
4618
                    }
4619
                    break;
4620
                  }
4621
                }
4622
              }
4623
            }
4624
          }
4625
 
846 dpurdie 4626
          //
4627
          //  Look for indefinite_pause style of entry
4628
          //  Note: due to an implemenation error there may be many
4629
          //        rows that match. We only need one. The scan will
4630
          //        be termineted if we find any
4631
          //  
4632
          //
836 mhunt 4633
          String ip = rset.getString("indefinite_pause");
4634
          if ( ip != null )
814 mhunt 4635
          {
4636
            // indefinite pause is non null
4637
            mLogger.warn("queryRunLevelSchedule indefinite pause");
838 mhunt 4638
            GregorianCalendar clock = new GregorianCalendar();
4639
            clock.setTime(now);
4640
            // wait a minute
4641
            resumeTime.setTime(clock.getTimeInMillis() + 60000);
814 mhunt 4642
            retVal = false;
4643
          }
4644
        }
830 mhunt 4645
 
4646
        rset.close();
4647
        stmt.close();
814 mhunt 4648
      }
4649
      catch ( SQLException e )
4650
      {
4651
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4652
        {
4653
          mLogger.error("queryRunLevelSchedule database access error only");
4654
          throw new SQLException();
4655
        }
4656
        else
4657
        {
4658
          mLogger.fatal("queryRunLevelSchedule show stopper");
868 mhunt 4659
          throw new Exception("queryRunLevelSchedule show stopper");
814 mhunt 4660
        }
4661
      }
4662
    }
4663
 
4664
    mLogger.info("queryRunLevelSchedule returning " + retVal);
4665
    return retVal;
4666
  }
4667
 
4668
  /**persists the runLevel in the RUN_LEVEL table for the rcon_id primary key
4669
   * refer to sequence diagrams generate build files, allowed to proceed, not allowed to proceed, exit, check environment
4670
   */
4671
  public void updateCurrentRunLevel(final int rcon_id, final int runLevel) throws SQLException, Exception
4672
  {
4673
    mLogger.debug("updateCurrentRunLevel");
4674
    if ( !mUseDatabase )
4675
    {
4676
      mLogger.info("updateCurrentRunLevel !mUseDatabase");
4677
      Integer i = new Integer(runLevel);
4678
      mPersistedRunLevelCollection.add(i);
4679
    }
4680
    else
4681
    {
4682
      try
4683
      {
4684
        connect();
4685
        boolean update = false;
4686
        {
4687
          // check if the rcon_id exists in the table
4688
          CallableStatement stmt = mConnection.prepareCall("select rcon_id from release_manager.run_level where rcon_id=" + rcon_id);
4689
          ResultSet rset = stmt.executeQuery();
4690
 
4691
          while( rset.next() )
4692
          {
4693
            update = true;
4694
          }
830 mhunt 4695
 
4696
          rset.close();
4697
          stmt.close();
814 mhunt 4698
        }
4699
 
4700
        if ( !update )
4701
        {
4702
          // check if the rcon_id is still configured
4703
          boolean configured = false;
4704
          {
4705
            CallableStatement stmt = mConnection.prepareCall("select rcon_id from release_manager.release_config where rcon_id=" + rcon_id);
4706
            ResultSet rset = stmt.executeQuery();
4707
 
4708
            while( rset.next() )
4709
            {
4710
              configured = true;
4711
            }
830 mhunt 4712
 
4713
            rset.close();
4714
            stmt.close();
814 mhunt 4715
          }
864 mhunt 4716
 
4717
          if (configured)
4718
          {
4719
            CallableStatement stmt = mConnection.prepareCall("insert into release_manager.run_level (rcon_id) values (" + rcon_id + ")" );
4720
            stmt.executeUpdate();
4721
            stmt.close();
4722
          }
814 mhunt 4723
        }
4724
 
4725
        {
4726
          CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + " where rcon_id=" + rcon_id);
4727
          stmt.executeUpdate();
830 mhunt 4728
          stmt.close();
814 mhunt 4729
        }
4730
        mConnection.commit();
4731
        disconnect();
4732
      }
4733
      catch( SQLException e )
4734
      {
4735
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4736
        {
868 mhunt 4737
          mLogger.fatal("updateCurrentRunLevel database access error only");
4738
          throw new Exception("updateCurrentRunLevel database access error only");
814 mhunt 4739
        }
4740
        else
4741
        {
4742
          mLogger.fatal("updateCurrentRunLevel show stopper");
868 mhunt 4743
          throw new Exception("updateCurrentRunLevel show stopper");
814 mhunt 4744
        }
4745
      }
4746
    }
4747
  }
4748
 
866 mhunt 4749
  public void queryBuildExclusions(Vector<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
4750
  {
4751
    mLogger.debug("queryBuildExclusions " + baseline);
4752
 
4753
    if ( !mUseDatabase )
4754
    {
4755
      mLogger.info("queryBuildExclusions !mUseDatabase");
4756
    }
4757
    else
4758
    {
4759
      try
4760
      {
4761
        CallableStatement stmt = mConnection.prepareCall("select pv_id, root_pv_id, root_cause from release_manager.do_not_ripple where rtag_id=" + baseline);
4762
        ResultSet rset = stmt.executeQuery();
4763
 
4764
        while( rset.next() )
4765
        {
4766
          int pvId = rset.getInt("pv_id");
4767
 
4768
          if ( rset.wasNull() )
4769
          {
4770
            mLogger.fatal("queryBuildExclusions rset null pv_id");
4771
            // show stopper
868 mhunt 4772
            throw new Exception("queryBuildExclusions rset null pv_id");
866 mhunt 4773
          }
4774
 
4775
          int rootPvId = rset.getInt("root_pv_id");
4776
 
4777
          if ( rset.wasNull() )
4778
          {
4779
            // quite acceptable
4780
            rootPvId = -1;
4781
          }
4782
 
4783
          // again, a null root_cause is quite acceptable
4784
          String rootCause = rset.getString("root_cause");
4785
 
4786
          BuildExclusion buildExclusion = new BuildExclusion(pvId, rootPvId, rootCause);
4787
          buildExclusionCollection.add(buildExclusion);
4788
        }
4789
 
4790
        rset.close();
4791
        stmt.close();
4792
      }
4793
      catch ( SQLException e )
4794
      {
4795
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4796
        {
4797
          mLogger.error("queryBuildExclusions database access error only");
4798
          throw new SQLException();
4799
        }
4800
        else
4801
        {
4802
          mLogger.fatal("queryBuildExclusions show stopper");
868 mhunt 4803
          throw new Exception("queryBuildExclusions show stopper");
866 mhunt 4804
        }
4805
      }
4806
    }
4807
  }
814 mhunt 4808
}