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