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
876 mhunt 1364
          // devi 48629 support multiple wips on the same package and build in the order they were released
814 mhunt 1365
          CallableStatement stmt1 = mConnection.prepareCall(
876 mhunt 1366
          "select pl.pv_id, p.pkg_id, p.pkg_name, pv.v_ext, pv.pkg_label, pv.src_path, pv.change_type, pv.modified_stamp " +
814 mhunt 1367
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.packages p " +
1368
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1369
          "and pv.pv_id=pl.pv_id and p.pkg_id=pv.pkg_id " +
876 mhunt 1370
          "order by pv.modified_stamp"
814 mhunt 1371
          );
1372
          ResultSet rset1 = stmt1.executeQuery();
1373
 
1374
          while( rset1.next() )
1375
          {
1376
            int pv_id = rset1.getInt("pv_id");
1377
 
1378
            if ( rset1.wasNull() )
1379
            {
1380
              mLogger.fatal("queryPackageVersions rset1 null pv_id");
1381
              // show stopper
868 mhunt 1382
              throw new Exception("queryPackageVersions rset1 null pv_id");
814 mhunt 1383
            }
1384
 
1385
            int pkg_id = rset1.getInt("pkg_id");
1386
 
1387
            if ( rset1.wasNull() )
1388
            {
1389
              mLogger.fatal("queryPackageVersions rset1 null pkg_id " + pv_id);
1390
              // show stopper
868 mhunt 1391
              throw new Exception("queryPackageVersions rset1 null pkg_id " + pv_id);
814 mhunt 1392
            }
1393
 
1394
            String pkg_name = rset1.getString("pkg_name");
1395
 
1396
            if ( pkg_name == null )
1397
            {
1398
              mLogger.fatal("queryPackageVersions rset1 null pkg_name " + pv_id);
1399
              // show stopper
868 mhunt 1400
              throw new Exception("queryPackageVersions rset1 null pkg_name " + pv_id);
814 mhunt 1401
            }
1402
 
1403
            String v_ext = rset1.getString("v_ext");
1404
 
1405
            if ( v_ext == null )
1406
            {
1407
              v_ext = "";
1408
            }
1409
 
1410
            String pkg_label = rset1.getString("pkg_label");
1411
 
1412
            if ( pkg_label == null )
1413
            {
1414
              pkg_label = "NA";
1415
            }
1416
 
1417
            String src_path = rset1.getString("src_path");
1418
 
1419
            if ( src_path == null )
1420
            {
1421
              src_path = "NA";
1422
            }
1423
 
1424
            String change_type = rset1.getString("change_type");
1425
 
1426
            if ( change_type == null )
1427
            {
1428
              change_type = "P";
1429
            }
1430
 
1431
            char ct = 'x';
1432
 
1433
            if ( change_type.compareTo("M") == 0 )
1434
            {
1435
              ct = 'M';
1436
            }
1437
            else if ( change_type.compareTo("N") == 0 )
1438
            {
1439
              ct = 'N';
1440
            }
1441
            else if ( change_type.compareTo("P") == 0 )
1442
            {
1443
              ct = 'P';
1444
            }
1445
 
1446
            if ( ct != 'x' )
1447
            {
1448
              Package p = new Package(pv_id, pkg_name, v_ext, pkg_name + v_ext, pkg_label, src_path, ct);
1449
              p.mPid = pkg_id;
1450
              p.mDirectlyPlanned = true;
878 mhunt 1451
              Package plannedPackage = findPackage(p.mAlias, packageCollection);
1452
 
1453
              if ( plannedPackage == NULL_PACKAGE )
1454
              {
1455
                mLogger.info("queryPackageVersions rset1 no previous planned package " + pv_id);
1456
                packageCollection.add(p);
1457
              }
814 mhunt 1458
            }
1459
          }
830 mhunt 1460
 
1461
          rset1.close();
1462
          stmt1.close();
814 mhunt 1463
 
1464
          // get planned package dependency info
1465
          CallableStatement stmt2 = mConnection.prepareCall(
878 mhunt 1466
          "select pl.pv_id, p.pkg_name, dpv.v_ext, pv.modified_stamp " +
814 mhunt 1467
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p " +
1468
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1469
          "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 " +
878 mhunt 1470
          "order by pv.modified_stamp"
814 mhunt 1471
          );
1472
          ResultSet rset2 = stmt2.executeQuery();
1473
 
1474
          while( rset2.next() )
1475
          {
1476
            boolean ignore = false;
1477
 
1478
            int pv_id = rset2.getInt("pv_id");
1479
 
1480
            if ( rset2.wasNull() )
1481
            {
1482
              mLogger.fatal("queryPackageVersions rset2 null pv_id");
1483
              // show stopper
868 mhunt 1484
              throw new Exception("queryPackageVersions rset2 null pv_id");
814 mhunt 1485
            }
1486
 
1487
            Package p = findPackage(pv_id, packageCollection);
1488
 
1489
            if ( p == NULL_PACKAGE )
1490
            {
878 mhunt 1491
              mLogger.info("queryPackageVersions rset2 package superceded by planned " + pv_id);
814 mhunt 1492
              ignore = true;
1493
            }
1494
 
1495
            String pkg_name = rset2.getString("pkg_name");
1496
 
1497
            if ( pkg_name == null )
1498
            {
1499
              mLogger.fatal("queryPackageVersions rset2 null pkg_name " + pv_id);
1500
              // show stopper
868 mhunt 1501
              throw new Exception("queryPackageVersions rset2 null pkg_name " + pv_id);
814 mhunt 1502
            }
1503
 
1504
            String v_ext = rset2.getString("v_ext");
1505
 
1506
            if ( v_ext == null )
1507
            {
1508
              v_ext = "";
1509
            }
1510
 
1511
            if ( !ignore )
1512
            {
1513
              p.mDependencyCollection.add(pkg_name + v_ext);
1514
              p.mDependencyIDCollection.add(-1);
1515
            }
1516
          }
1517
 
830 mhunt 1518
          rset2.close();
1519
          stmt2.close();
1520
 
814 mhunt 1521
          // get planned package build info
1522
          CallableStatement stmt3 = mConnection.prepareCall(
878 mhunt 1523
          "select pl.pv_id, bm.bm_name, bsa.bsa_name, pv.modified_stamp " +
814 mhunt 1524
          "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 " +
1525
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1526
          "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 " +
878 mhunt 1527
          "order by pv.modified_stamp"
814 mhunt 1528
          );
1529
          ResultSet rset3 = stmt3.executeQuery();
1530
 
1531
          while( rset3.next() )
1532
          {
1533
            boolean ignore = false;
1534
            int pv_id = rset3.getInt("pv_id");
1535
 
1536
            if ( rset3.wasNull() )
1537
            {
1538
              mLogger.fatal("queryPackageVersions rset3 null pv_id");
1539
              // show stopper
868 mhunt 1540
              throw new Exception("queryPackageVersions rset3 null pv_id");
814 mhunt 1541
            }
1542
 
1543
            Package p = findPackage(pv_id, packageCollection);
1544
 
1545
            if ( p == NULL_PACKAGE )
1546
            {
878 mhunt 1547
              mLogger.info("queryPackageVersions rset3 package superceded by planned " + pv_id);
814 mhunt 1548
              ignore = true;
1549
            }
1550
 
1551
            String bm_name = rset3.getString("bm_name");
1552
 
1553
            if ( bm_name == null )
1554
            {
1555
              mLogger.fatal("queryPackageVersions rset3 null bm_name " + pv_id);
1556
              // show stopper
868 mhunt 1557
              throw new Exception("queryPackageVersions rset3 null bm_name " + pv_id);
814 mhunt 1558
            }
1559
 
1560
            String bsa_name = rset3.getString("bsa_name");
1561
 
1562
            if ( bsa_name == null )
1563
            {
1564
              mLogger.fatal("queryPackageVersions rset3 null bsa_name " + pv_id);
1565
              // show stopper
868 mhunt 1566
              throw new Exception("queryPackageVersions rset3 null bsa_name " + pv_id);
814 mhunt 1567
            }
1568
 
1569
            if ( !ignore )
1570
            {
1571
              boolean supportedBuildStandard = true;
1572
              BuildStandard bs = new BuildStandard(rippleEngine);
1573
 
1574
              if ( bm_name.compareTo("Solaris") == 0 )
1575
              {
1576
                bs.setSolaris();
1577
              }
1578
              else if ( bm_name.compareTo("Win32") == 0 )
1579
              {
1580
                bs.setWin32();
1581
              }
1582
              else if ( bm_name.compareTo("Linux") == 0 )
1583
              {
1584
                bs.setLinux();
1585
              }
1586
              else if ( bm_name.compareTo("Generic") == 0 )
1587
              {
1588
                bs.setGeneric();
1589
              }
1590
              else
1591
              {
1592
                supportedBuildStandard = false;
1593
              }
1594
 
1595
              if ( bsa_name.compareTo("Production") == 0 )
1596
              {
1597
                bs.setProduction();
1598
              }
1599
              else if ( bsa_name.compareTo("Debug") == 0 )
1600
              {
1601
                bs.setDebug();
1602
              }
1603
              else if ( bsa_name.compareTo("Production and Debug") == 0 )
1604
              {
1605
                bs.setAll();
1606
              }
1607
              else if ( bsa_name.compareTo("Java 1.4") == 0 )
1608
              {
1609
                bs.set1_4();
1610
              }
1611
              else if ( bsa_name.compareTo("Java 1.5") == 0 )
1612
              {
1613
                bs.set1_5();
1614
              }
1615
              else if ( bsa_name.compareTo("Java 1.6") == 0 )
1616
              {
1617
                bs.set1_6();
1618
              }
1619
              else
1620
              {
1621
                supportedBuildStandard = false;
1622
              }
1623
 
1624
              if ( supportedBuildStandard )
1625
              {
1626
                p.mBuildStandardCollection.add(bs);
1627
              }
1628
            }
1629
          }
830 mhunt 1630
 
1631
          rset3.close();
1632
          stmt3.close();
814 mhunt 1633
 
1634
          // get planned package unit test info
1635
          CallableStatement stmt4 = mConnection.prepareCall(
878 mhunt 1636
          "select pl.pv_id, tt.test_type_name, pv.modified_stamp " +
814 mhunt 1637
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.unit_tests ut, release_manager.test_types tt " +
1638
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1639
          "and pv.pv_id = pl.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk " +
878 mhunt 1640
          "order by pv.modified_stamp"
814 mhunt 1641
          );
1642
          ResultSet rset4 = stmt4.executeQuery();
1643
 
1644
          while( rset4.next() )
1645
          {
1646
            boolean ignore = false;
1647
 
1648
            int pv_id = rset4.getInt("pv_id");
1649
 
1650
            if ( rset4.wasNull() )
1651
            {
1652
              mLogger.fatal("queryPackageVersions rset4 null pv_id");
1653
              // show stopper
868 mhunt 1654
              throw new Exception("queryPackageVersions rset4 null pv_id");
814 mhunt 1655
            }
1656
 
1657
            Package p = findPackage(pv_id, packageCollection);
1658
 
1659
            if ( p == NULL_PACKAGE )
1660
            {
878 mhunt 1661
              mLogger.info("queryPackageVersions rset4 package superceded by planned " + pv_id);
814 mhunt 1662
              ignore = true;
1663
            }
1664
 
1665
            String test_type_name = rset4.getString("test_type_name");
1666
 
1667
            if ( test_type_name == null )
1668
            {
1669
              mLogger.fatal("queryPackageVersions rset4 null test_type_name " + pv_id);
1670
              // show stopper
868 mhunt 1671
              throw new Exception("queryPackageVersions rset4 null test_type_name " + pv_id);
814 mhunt 1672
            }
1673
 
1674
            if ( !ignore )
1675
            {
1676
              if ( test_type_name.compareTo("Autobuild UTF") == 0 )
1677
              {
1678
                p.mHasAutomatedUnitTests = true;
1679
              }
1680
            }
1681
          }
830 mhunt 1682
 
1683
          rset4.close();
1684
          stmt4.close();
814 mhunt 1685
 
864 mhunt 1686
          // get planned package build failure info...
1687
          // global and project wide based
1688
          CallableStatement stmt50 = mConnection.prepareCall(
878 mhunt 1689
          "select pl.pv_id, pv.modified_stamp " +
864 mhunt 1690
          "from release_manager.planned pl, release_manager.release_tags rt, release_manager.package_versions pv " +
1691
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1692
          "and pv.pv_id = pl.pv_id " +
878 mhunt 1693
          "order by pv.modified_stamp"
864 mhunt 1694
          );
1695
          ResultSet rset50 = stmt50.executeQuery();
1696
 
1697
          while( rset50.next() )
1698
          {
1699
            int pv_id = rset50.getInt("pv_id");
1700
 
1701
            if ( rset50.wasNull() )
1702
            {
1703
              mLogger.fatal("queryPackageVersions rset50 null pv_id");
1704
              // show stopper
868 mhunt 1705
              throw new Exception("queryPackageVersions rset50 null pv_id");
864 mhunt 1706
            }
1707
 
1708
            Package p = findPackage(pv_id, packageCollection);
1709
 
1710
            if ( p == NULL_PACKAGE )
1711
            {
878 mhunt 1712
              mLogger.info("queryPackageVersions rset50 package superceded by planned " + pv_id);
864 mhunt 1713
            }
1714
            else
1715
            {
1716
              for (Iterator<String> it = globalAndProjectWideBuildFailureEmailCollection.iterator(); it.hasNext(); )
1717
              {
1718
                p.addEmail(it.next());
1719
              }
1720
            }
1721
          }
1722
 
1723
          rset50.close();
1724
          stmt50.close();
1725
 
1726
          // view based
814 mhunt 1727
          CallableStatement stmt5 = mConnection.prepareCall(
878 mhunt 1728
          "select pl.pv_id, u.user_email, pv.modified_stamp " +
814 mhunt 1729
          "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 " +
1730
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1731
          "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 " +
878 mhunt 1732
          "order by pv.modified_stamp"
814 mhunt 1733
          );
1734
          ResultSet rset5 = stmt5.executeQuery();
1735
 
1736
          while( rset5.next() )
1737
          {
1738
            int pv_id = rset5.getInt("pv_id");
1739
 
1740
            if ( rset5.wasNull() )
1741
            {
1742
              mLogger.fatal("queryPackageVersions rset5 null pv_id");
1743
              // show stopper
868 mhunt 1744
              throw new Exception("queryPackageVersions rset5 null pv_id");
814 mhunt 1745
            }
1746
 
1747
            Package p = findPackage(pv_id, packageCollection);
1748
 
1749
            if ( p == NULL_PACKAGE )
1750
            {
878 mhunt 1751
              mLogger.info("queryPackageVersions rset5 package superceded by planned " + pv_id);
814 mhunt 1752
            }
864 mhunt 1753
            else
1754
            {
1755
              String user_email = rset5.getString("user_email");
814 mhunt 1756
 
864 mhunt 1757
              if ( user_email != null )
1758
              {
1759
                p.addEmail(user_email);
1760
              }
1761
            }
1762
          }
1763
 
1764
          rset5.close();
1765
          stmt5.close();
1766
 
1767
          // package version
1768
          CallableStatement stmt51 = mConnection.prepareCall(
878 mhunt 1769
          "select pl.pv_id, u1.user_email, u2.user_email, u3.user_email, pv.modified_stamp " +
864 mhunt 1770
          "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 " +
1771
          "where pl.rtag_id=" + baseline + " and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A' " +
1772
          "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 " +
878 mhunt 1773
          "order by pv.modified_stamp"
864 mhunt 1774
          );
1775
          ResultSet rset51 = stmt51.executeQuery();
814 mhunt 1776
 
864 mhunt 1777
          while( rset51.next() )
1778
          {
1779
            int pv_id = rset51.getInt("pv_id");
1780
 
1781
            if ( rset51.wasNull() )
814 mhunt 1782
            {
864 mhunt 1783
              mLogger.fatal("queryPackageVersions rset51 null pv_id");
1784
              // show stopper
868 mhunt 1785
              throw new Exception("queryPackageVersions rset51 null pv_id");
814 mhunt 1786
            }
1787
 
864 mhunt 1788
            Package p = findPackage(pv_id, packageCollection);
1789
 
1790
            if ( p == NULL_PACKAGE )
814 mhunt 1791
            {
878 mhunt 1792
              mLogger.info("queryPackageVersions rset51 package superceded by planned " + pv_id);
814 mhunt 1793
            }
864 mhunt 1794
            else
1795
            {
1796
 
1797
              // walk the 3 columns of user_email in the resultset
1798
              // columns 2, 3 and 4, all of the same name, repectively
1799
              for(int column=2; column<5; column++ )
1800
              {
1801
                String user_email = rset51.getString(column);
1802
 
1803
                if ( user_email != null )
1804
                {
1805
                  p.addEmail(user_email);
1806
                }
1807
              }
1808
            }
814 mhunt 1809
          }
830 mhunt 1810
 
864 mhunt 1811
          rset51.close();
1812
          stmt51.close();
814 mhunt 1813
 
1814
          // get planned package advisory ripple info
1815
          CallableStatement stmt7 = mConnection.prepareCall(
878 mhunt 1816
          "select pl.pv_id, pv.modified_stamp " +
814 mhunt 1817
          "from release_manager.planned pl, release_manager.package_versions pv, release_manager.advisory_ripple ar " +
1818
          "where pl.rtag_id=" + baseline + " and pv.build_type='A' and pv.dlocked='A' " +
1819
          "and pv.pv_id = pl.pv_id and ar.rtag_id=pl.rtag_id and ar.pv_id=pl.pv_id " +
878 mhunt 1820
          "order by pv.modified_stamp"
814 mhunt 1821
          );
1822
          ResultSet rset7 = stmt7.executeQuery();
1823
 
1824
          while( rset7.next() )
1825
          {
1826
            boolean ignore = false;
1827
 
1828
            int pv_id = rset7.getInt("pv_id");
1829
 
1830
            if ( rset7.wasNull() )
1831
            {
1832
              mLogger.fatal("queryPackageVersions rset7 null pv_id");
1833
              // show stopper
868 mhunt 1834
              throw new Exception("queryPackageVersions rset7 null pv_id");
814 mhunt 1835
            }
1836
 
1837
            Package p = findPackage(pv_id, packageCollection);
1838
 
1839
            if ( p == NULL_PACKAGE )
1840
            {
878 mhunt 1841
              mLogger.info("queryPackageVersions rset7 package superceded by planned " + pv_id);
814 mhunt 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
            {
878 mhunt 2030
              mLogger.info("queryPackageVersions rset9 package superceded by planned " + pv_id);
814 mhunt 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
            {
878 mhunt 2086
              mLogger.info("queryPackageVersions rset10 package superceded by planned " + pv_id);
814 mhunt 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
            {
878 mhunt 2200
              mLogger.info("queryPackageVersions rset11 package superceded by planned " + pv_id);
814 mhunt 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
            {
878 mhunt 2251
              mLogger.info("queryPackageVersions rset120 package superceded by planned " + pv_id);
864 mhunt 2252
            }
2253
            else
2254
            {
2255
              for (Iterator<String> it = globalAndProjectWideBuildFailureEmailCollection.iterator(); it.hasNext(); )
2256
              {
2257
                p.addEmail(it.next());
2258
              }
2259
            }
2260
          }
2261
 
2262
          rset120.close();
2263
          stmt120.close();
2264
 
2265
          // view based
814 mhunt 2266
          CallableStatement stmt12 = mConnection.prepareCall(
2267
          "select rc.pv_id, u.user_email " +
2268
          "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 " +
2269
          "where rc.rtag_id=" + baseline + " and rt.rtag_id=rc.rtag_id " +
2270
          "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 " +
2271
          "order by rc.pv_id"
2272
          );
2273
          ResultSet rset12 = stmt12.executeQuery();
2274
 
2275
          while( rset12.next() )
2276
          {
2277
            int pv_id = rset12.getInt("pv_id");
2278
 
2279
            if ( rset12.wasNull() )
2280
            {
2281
              mLogger.fatal("queryPackageVersions rset12 null pv_id");
2282
              // show stopper
868 mhunt 2283
              throw new Exception("queryPackageVersions rset12 null pv_id");
814 mhunt 2284
            }
2285
 
2286
            Package p = findPackage(pv_id, packageCollection);
2287
 
2288
            if ( p == NULL_PACKAGE )
2289
            {
878 mhunt 2290
              mLogger.info("queryPackageVersions rset12 package superceded by planned " + pv_id);
814 mhunt 2291
            }
864 mhunt 2292
            else
814 mhunt 2293
            {
864 mhunt 2294
              String user_email = rset12.getString("user_email");
814 mhunt 2295
 
864 mhunt 2296
              if ( user_email != null )
2297
              {
2298
                p.addEmail(user_email);
2299
              }
814 mhunt 2300
            }
2301
          }
830 mhunt 2302
 
2303
          rset12.close();
2304
          stmt12.close();
814 mhunt 2305
 
2306
          // get released advisory ripple info
2307
          CallableStatement stmt14 = mConnection.prepareCall(
2308
          "select rc.pv_id " +
2309
          "from release_manager.release_content rc, release_manager.package_versions pv, release_manager.advisory_ripple ar " +
2310
          "where rc.rtag_id=" + baseline +
2311
          " and pv.pv_id = rc.pv_id and ar.rtag_id=rc.rtag_id and ar.pv_id=rc.pv_id " +
2312
          "order by rc.pv_id"
2313
          );
2314
          ResultSet rset14 = stmt14.executeQuery();
2315
 
2316
          while( rset14.next() )
2317
          {
2318
            boolean ignore = false;
2319
 
2320
            int pv_id = rset14.getInt("pv_id");
2321
 
2322
            if ( rset14.wasNull() )
2323
            {
2324
              mLogger.fatal("queryPackageVersions rset14 null pv_id");
2325
              // show stopper
868 mhunt 2326
              throw new Exception("queryPackageVersions rset14 null pv_id");
814 mhunt 2327
            }
2328
 
2329
            Package p = findPackage(pv_id, packageCollection);
2330
 
2331
            if ( p == NULL_PACKAGE )
2332
            {
878 mhunt 2333
              mLogger.info("queryPackageVersions rset14 package superceded by planned " + pv_id);
814 mhunt 2334
              ignore = true;
2335
            }
2336
 
2337
            if ( !ignore )
2338
            {
2339
              p.mAdvisoryRipple = true;
2340
            }
2341
          }
830 mhunt 2342
 
2343
          rset14.close();
2344
          stmt14.close();
814 mhunt 2345
        }
2346
        else
2347
        {
2348
          // get released product info
2349
          CallableStatement stmt = mConnection.prepareCall(
2350
          "select oc.prod_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_label, pv.src_path " +
2351
          "from bom_contents bc, operating_systems os, os_contents oc, release_manager.package_versions pv, release_manager.packages p " +
2352
          "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 " +
2353
          "order by oc.prod_id"
2354
          );
2355
          ResultSet rset = stmt.executeQuery();
2356
 
2357
          while( rset.next() )
2358
          {
2359
            int pv_id = rset.getInt("prod_id");
2360
 
2361
            if ( rset.wasNull() )
2362
            {
2363
              mLogger.fatal("queryPackageVersions rset null prod_id");
2364
              // show stopper
868 mhunt 2365
              throw new Exception("queryPackageVersions rset null prod_id");
814 mhunt 2366
            }
2367
 
2368
            String pkg_name = rset.getString("pkg_name");
2369
 
2370
            if ( pkg_name == null )
2371
            {
2372
              mLogger.fatal("queryPackageVersions rset null pkg_name " + pv_id);
2373
              // show stopper
868 mhunt 2374
              throw new Exception("queryPackageVersions rset null pkg_name " + pv_id);
814 mhunt 2375
            }
2376
 
2377
            String pkg_version = rset.getString("pkg_version");
2378
 
2379
            if ( pkg_version == null )
2380
            {
2381
              mLogger.fatal("queryPackageVersions rset null pkg_version " + pv_id);
2382
              // show stopper
868 mhunt 2383
              throw new Exception("queryPackageVersions rset null pkg_version " + pv_id);
814 mhunt 2384
            }
2385
 
2386
            String v_ext = rset.getString("v_ext");
2387
 
2388
            if ( v_ext == null )
2389
            {
2390
              v_ext = "";
2391
            }
2392
 
2393
            String pkg_label = rset.getString("pkg_label");
2394
 
2395
            if ( pkg_label == null )
2396
            {
2397
              pkg_label = "NA";
2398
            }
2399
 
2400
            String src_path = rset.getString("src_path");
2401
 
2402
            if ( src_path == null )
2403
            {
2404
              src_path = "NA";
2405
            }
2406
 
834 mhunt 2407
            Package p = findPackage(pv_id, packageCollection);
2408
 
2409
            if ( p == NULL_PACKAGE )
2410
            {
2411
	            Package q = new Package(pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, pkg_label, src_path, 'x');
2412
	            packageCollection.add(q);
2413
            }
814 mhunt 2414
          }
830 mhunt 2415
 
2416
          rset.close();
2417
          stmt.close();
814 mhunt 2418
        }
2419
      }
2420
      catch ( SQLException e )
2421
      {
2422
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2423
        {
2424
          mLogger.error("queryPackageVersions database access error only");
2425
          throw new SQLException();
2426
        }
2427
        else
2428
        {
2429
          mLogger.fatal("queryPackageVersions show stopper");
868 mhunt 2430
          throw new Exception("queryPackageVersions show stopper");
814 mhunt 2431
        }
2432
      }
2433
    }
2434
 
2435
    if (!daemonMode)
2436
    {
2437
      // use a ListIterator as it allows traverseDependencies to modify the packageCollection
864 mhunt 2438
      for (ListIterator<Package> it = packageCollection.listIterator(); it.hasNext(); )
814 mhunt 2439
      {
864 mhunt 2440
        Package p = it.next();
814 mhunt 2441
        traverseDependencies(packageCollection, p, false, it);
2442
      }
2443
 
864 mhunt 2444
      for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2445
      {
864 mhunt 2446
        Package p = it.next();
814 mhunt 2447
        queryBuildInfo(rippleEngine, p);
2448
      }
2449
    }
2450
 
2451
  }
2452
 
2453
  /**only used in daemon mode
2454
   *   select config from build_service_config where service='MAIL SERVER';
2455
   * returns the configured service
2456
   */
2457
  String queryMailServer() throws SQLException, Exception
2458
  {
2459
    mLogger.debug("queryMailServer");
2460
    String retVal = new String();
2461
 
2462
    if ( !mUseDatabase )
2463
    {
2464
      mLogger.info("queryMailServer !mUseDatabase");
2465
      // a highly likely mail server
2466
      retVal = "aupera03.aupera.erggroup.com";
2467
    }
2468
    else
2469
    {
2470
      try
2471
      {
2472
        CallableStatement stmt = mConnection.prepareCall("select config from release_manager.build_service_config where service='MAIL SERVER'");
2473
        ResultSet rset = stmt.executeQuery();
2474
 
2475
        while( rset.next() )
2476
        {
2477
          String config = rset.getString("config");
2478
 
2479
          if ( config != null )
2480
          {
2481
            retVal += config;
2482
          }
2483
        }
830 mhunt 2484
 
2485
        rset.close();
2486
        stmt.close();
814 mhunt 2487
      }
2488
      catch ( SQLException e )
2489
      {
2490
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2491
        {
2492
          mLogger.error("queryMailServer database access error only");
2493
          throw new SQLException();
2494
        }
2495
        else
2496
        {
2497
          mLogger.fatal("queryMailServer show stopper");
868 mhunt 2498
          throw new Exception("queryMailServer show stopper");
814 mhunt 2499
        }
2500
      }
2501
    }
2502
 
2503
    mLogger.info("queryMailServer returned " + retVal);
2504
    return retVal;
2505
  }
2506
 
2507
  /**only used in daemon mode
2508
   *   select config from build_service_config where service='BUILD FAILURE MAIL SENDER';
2509
   * returns the configured service
2510
   */
2511
  String queryMailSender() throws SQLException, Exception
2512
  {
2513
    mLogger.debug("queryMailSender");
2514
    String retVal = new String();
2515
 
2516
    if ( !mUseDatabase )
2517
    {
2518
      mLogger.info("queryMailSender !mUseDatabase");
2519
      // a highly likely mail sender
2520
      retVal = "buildadm@erggroup.com";
2521
    }
2522
    else
2523
    {
2524
      try
2525
      {
2526
        CallableStatement stmt = mConnection.prepareCall("select config from release_manager.build_service_config where service='BUILD FAILURE MAIL SENDER'");
2527
        ResultSet rset = stmt.executeQuery();
2528
 
2529
        while( rset.next() )
2530
        {
2531
          String config = rset.getString("config");
2532
 
2533
          if ( config != null )
2534
          {
2535
            retVal += config;
2536
          }
2537
        }
830 mhunt 2538
 
2539
        rset.close();
2540
        stmt.close();
814 mhunt 2541
      }
2542
      catch ( SQLException e )
2543
      {
2544
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2545
        {
2546
          mLogger.error("queryMailSender database access error only");
2547
          throw new SQLException();
2548
        }
2549
        else
2550
        {
2551
          mLogger.fatal("queryMailSender show stopper");
868 mhunt 2552
          throw new Exception("queryMailSender show stopper");
814 mhunt 2553
        }
2554
      }
2555
    }
2556
 
2557
    mLogger.debug("queryMailSender returned " + retVal);
2558
    return retVal;
2559
  }
2560
 
868 mhunt 2561
  /**only used in daemon mode
2562
   * select u.user_email from release_manager.build_service_config bsc, users u
2563
   * where bsc.service='GLOBAL EMAIL ADDRESS LIST' and u.full_name=bsc.config
2564
   * returns the configured global email addresses
2565
   */
2566
  String queryGlobalAddresses() throws SQLException, Exception
2567
  {
2568
    mLogger.debug("queryGlobalAddresses");
2569
    String retVal = new String();
2570
 
2571
    if ( !mUseDatabase )
2572
    {
2573
      mLogger.info("queryGlobalAddresses !mUseDatabase");
2574
      // a highly unlikely address
2575
      retVal = "buildadm@erggroup.com";
2576
    }
2577
    else
2578
    {
2579
      try
2580
      {
2581
        CallableStatement stmt = mConnection.prepareCall(
2582
        "select u.user_email from release_manager.build_service_config bsc, users u " +
2583
        "where bsc.service='GLOBAL EMAIL ADDRESS LIST' and u.full_name=bsc.config"
2584
        );
2585
        ResultSet rset = stmt.executeQuery();
2586
 
2587
        while( rset.next() )
2588
        {
2589
          String email = rset.getString("user_email");
2590
 
2591
          if ( email != null )
2592
          {
2593
            retVal += email;
2594
          }
2595
        }
2596
 
2597
        rset.close();
2598
        stmt.close();
2599
      }
2600
      catch ( SQLException e )
2601
      {
2602
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2603
        {
2604
          mLogger.error("queryGlobalAddresses database access error only");
2605
          throw new SQLException();
2606
        }
2607
        else
2608
        {
2609
          mLogger.fatal("queryGlobalAddresses show stopper");
2610
          throw new Exception("queryGlobalAddresses show stopper");
2611
        }
2612
      }
2613
    }
2614
 
2615
    mLogger.debug("queryGlobalAddresses returned " + retVal);
2616
    return retVal;
2617
  }
2618
 
814 mhunt 2619
  /**called only in escrow mode
2620
   * if checkCollection is true, checks the pv_id is in the packageCollection
2621
   * if checkCollection is false, or the pv_id is not in the collection
2622
   * 1 traverses the pv_id package dependencies
2623
   *   select dpv.pv_id, p.pkg_name, dpv.pkg_version, dpv.v_ext, dpv.pkg_label, dpv.src_path
2624
   *   from release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p
2625
   *   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
2626
   *   order by pv.pv_id;
2627
   * 2 for each dpv.pv_id in the resultset
2628
   *     call traverseDependencies( packageCollection, dpv.pv_id, true )
2629
   *     if the pv_id is not in the collection, add it
2630
   *   
2631
   */
864 mhunt 2632
  private void traverseDependencies(Vector<Package> packageCollection, Package pkg, 
814 mhunt 2633
                                     boolean checkCollection, 
864 mhunt 2634
                                     ListIterator<Package> listIterator) throws SQLException, Exception
814 mhunt 2635
  {
2636
    mLogger.debug("traverseDependencies " + checkCollection);
2637
    boolean pvIdInCollection = false;
2638
 
2639
    if ( checkCollection )
2640
    {
864 mhunt 2641
      for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2642
      {
864 mhunt 2643
        Package p = it.next();
814 mhunt 2644
 
2645
        if ( p.mId == pkg.mId )
2646
        {
2647
          pvIdInCollection = true;
2648
          break;
2649
        }
2650
      }
2651
    }
2652
 
2653
    if ( !pvIdInCollection )
2654
    {
864 mhunt 2655
      Vector<Package> resultset = new Vector<Package>();
814 mhunt 2656
 
2657
      if ( !mUseDatabase )
2658
      {
2659
        mLogger.info("traverseDependencies !mUseDatabase");
2660
 
2661
        if ( pkg.mId == 8 || pkg.mId == 10 || pkg.mId == 13 )
2662
        {
2663
          Package p = new Package(9, "CommonDependency", "1.0.0000.tim", ".tim", "CommonDependency.1.0.0000.tim", "CommonDependency_1.0.0000.tim", "\\vob\\CommonDependency", 'x');
2664
          resultset.add(p);
2665
          pkg.mDependencyCollection.add(p.mAlias);
2666
        }
2667
        else if ( pkg.mId == 9 )
2668
        {
2669
          Package p = new Package(7, "CotsWithFunnyVersion", "hoopla2_x.cots", ".cots", "CotsWithFunnyVersion.hoopla2_x.cots", "CotsWithFunnyVersion_hoopla2_x.cots", "\\vob\\CotsWithFunnyVersion", 'x');
2670
          resultset.add(p);
2671
          pkg.mDependencyCollection.add(p.mAlias);
2672
        }
2673
        else if ( pkg.mId == 11 )
2674
        {
2675
          Package p = new Package(14, "AdvisoryDependency", "1.0.0000.tim", ".tim", "AdvisoryDependency.1.0.0000.tim", "AdvisoryDependency_1.0.0000.tim", "\\vob\\AdvisoryDependency", 'x');
2676
          resultset.add(p);
2677
          pkg.mDependencyCollection.add(p.mAlias);
2678
        }
2679
      }
2680
      else
2681
      {
2682
        try
2683
        {
2684
          CallableStatement stmt = mConnection.prepareCall(
2685
          "select dpv.pv_id, p.pkg_name, dpv.pkg_version, dpv.v_ext, dpv.pkg_label, dpv.src_path " +
2686
          "from release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p " +
2687
          "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 " +
2688
          "order by pv.pv_id"
2689
          );
2690
          ResultSet rset = stmt.executeQuery();
2691
 
2692
          while( rset.next() )
2693
          {
2694
            int pv_id = rset.getInt("pv_id");
2695
 
2696
            if ( rset.wasNull() )
2697
            {
2698
              mLogger.fatal("traverseDependencies null pv_id");
2699
              // show stopper
868 mhunt 2700
              throw new Exception("traverseDependencies null pv_id");
814 mhunt 2701
            }
2702
 
2703
            String pkg_name = rset.getString("pkg_name");
2704
 
2705
            if ( pkg_name == null )
2706
            {
2707
              mLogger.fatal("traverseDependencies null pkg_name " + pv_id);
2708
              // show stopper
868 mhunt 2709
              throw new Exception("traverseDependencies null pkg_name " + pv_id);
814 mhunt 2710
            }
2711
 
2712
            String pkg_version = rset.getString("pkg_version");
2713
 
2714
            if ( pkg_version == null )
2715
            {
2716
              mLogger.fatal("traverseDependencies null pkg_version " + pv_id);
2717
              // show stopper
868 mhunt 2718
              throw new Exception("traverseDependencies null pkg_version " + pv_id);
814 mhunt 2719
            }
2720
 
2721
            String v_ext = rset.getString("v_ext");
2722
 
2723
            if ( v_ext == null )
2724
            {
2725
              v_ext = "";
2726
            }
2727
 
2728
            String pkg_label = rset.getString("pkg_label");
2729
 
2730
            if ( pkg_label == null )
2731
            {
2732
              pkg_label = "NA";
2733
            }
2734
 
2735
            String src_path = rset.getString("src_path");
2736
 
2737
            if ( src_path == null )
2738
            {
2739
              src_path = "NA";
2740
            }
2741
 
2742
            Package p = new Package(pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, pkg_label, src_path, 'x');
2743
            resultset.add(p);
2744
            pkg.mDependencyCollection.add(p.mAlias);
2745
          }
830 mhunt 2746
 
2747
          rset.close();
2748
          stmt.close();
814 mhunt 2749
        }
2750
        catch ( SQLException e )
2751
        {
2752
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2753
          {
2754
            mLogger.fatal("traverseDependencies database access error only");
2755
            throw new SQLException();
2756
          }
2757
          else
2758
          {
2759
            mLogger.fatal("traverseDependencies show stopper");
868 mhunt 2760
            throw new Exception("traverseDependencies show stopper");
814 mhunt 2761
          }
2762
        }
2763
      }
2764
 
864 mhunt 2765
      for (Iterator<Package> it = resultset.iterator(); it.hasNext(); )
814 mhunt 2766
      {
864 mhunt 2767
        Package r = it.next();
814 mhunt 2768
        traverseDependencies(packageCollection, r, true, listIterator);
2769
 
2770
        pvIdInCollection = false;
2771
 
864 mhunt 2772
        for (Iterator<Package> it2 = packageCollection.iterator(); it2.hasNext(); )
814 mhunt 2773
        {
864 mhunt 2774
          Package p = it2.next();
814 mhunt 2775
 
2776
          if ( p.mId == r.mId )
2777
          {
2778
            pvIdInCollection = true;
2779
            break;
2780
          }
2781
        }
2782
 
2783
        if (!pvIdInCollection)
2784
        {
2785
          // insert the Package immediately before the next Package returned by next
2786
          // this does not change the next Package (if any) to be returned by next
2787
          listIterator.add(r);
2788
        }
2789
 
2790
      }
2791
    }
2792
  }
2793
 
2794
  /**returns the Package with the matching mID or NULL_PACKAGE if no package has the mID
2795
   */
864 mhunt 2796
  private Package findPackage(int id, Vector<Package> packageCollection)
814 mhunt 2797
  {
2798
    mLogger.debug("findPackage 1 id " + id);
2799
    Package retVal = NULL_PACKAGE;
2800
 
864 mhunt 2801
    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 2802
    {
864 mhunt 2803
      Package p = it.next();
814 mhunt 2804
 
2805
      if ( p.mId == id )
2806
      {
2807
        retVal = p;
2808
        break;
2809
      }
2810
    }
2811
 
2812
    mLogger.debug("findPackage 1 returned " + retVal.mName);
2813
    return retVal;
2814
  }
2815
 
2816
  /**called only in escrow mode to add build info to the Package
2817
   * select bm.bm_name, bsa.bsa_name
2818
   * from release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa
2819
   * 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
2820
   * order by pv.pv_id;
2821
   */
2822
  private void queryBuildInfo(RippleEngine rippleEngine, Package p) throws SQLException, Exception
2823
  {
2824
    mLogger.debug("queryBuildInfo");
2825
    if ( !mUseDatabase )
2826
    {
2827
      mLogger.info("queryBuildInfo !mUseDatabase");
2828
 
2829
      if (p.mId == 7)
2830
      {
2831
        BuildStandard bs = new BuildStandard(rippleEngine);
2832
        bs.setSolaris();
2833
        bs.setDebug();
2834
        p.mBuildStandardCollection.add(bs);
2835
      }
2836
      else if (p.mId == 9)
2837
      {
2838
        BuildStandard bs = new BuildStandard(rippleEngine);
2839
        bs.setLinux();
2840
        bs.setDebug();
2841
        p.mBuildStandardCollection.add(bs);
2842
        bs = new BuildStandard(rippleEngine);
2843
        bs.setSolaris();
2844
        bs.setDebug();
2845
        p.mBuildStandardCollection.add(bs);
2846
        bs = new BuildStandard(rippleEngine);
2847
        bs.setWin32();
2848
        bs.setProduction();
2849
        p.mBuildStandardCollection.add(bs);
2850
      }
2851
      else if (p.mId == 10)
2852
      {
2853
        BuildStandard bs = new BuildStandard(rippleEngine);
2854
        bs.setSolaris();
2855
        bs.set1_4();
2856
        p.mBuildStandardCollection.add(bs);
2857
      }
2858
      else if (p.mId == 11)
2859
      {
2860
        BuildStandard bs = new BuildStandard(rippleEngine);
2861
        bs.setLinux();
2862
        bs.setAll();
2863
        p.mBuildStandardCollection.add(bs);
2864
      }
2865
      else if (p.mId == 12)
2866
      {
2867
        BuildStandard bs = new BuildStandard(rippleEngine);
2868
        bs.setWin32();
2869
        bs.set1_6();
2870
        p.mBuildStandardCollection.add(bs);
2871
      }
2872
      else if (p.mId == 13)
2873
      {
2874
        BuildStandard bs = new BuildStandard(rippleEngine);
2875
        bs.setGeneric();
2876
        bs.set1_4();
2877
        p.mBuildStandardCollection.add(bs);
2878
      }
2879
      else if (p.mId == 14)
2880
      {
2881
        BuildStandard bs = new BuildStandard(rippleEngine);
2882
        bs.setLinux();
2883
        bs.setDebug();
2884
        p.mBuildStandardCollection.add(bs);
2885
      }
2886
 
2887
    }
2888
    else
2889
    {
2890
      try
2891
      {
2892
        CallableStatement stmt = mConnection.prepareCall(
2893
        "select bm.bm_name, bsa.bsa_name " +
2894
        "from release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa " +
2895
        "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 " +
2896
        "order by pv.pv_id"
2897
        );
2898
        ResultSet rset = stmt.executeQuery();
2899
 
2900
        while( rset.next() )
2901
        {
2902
          boolean supportedBuildStandard = true;
2903
          BuildStandard bs = new BuildStandard(rippleEngine);
2904
          String bm_name = rset.getString("bm_name");
2905
 
2906
          if ( bm_name == null )
2907
          {
2908
            mLogger.fatal("queryBuildInfo null bm_name " + p.mId);
2909
            // show stopper
868 mhunt 2910
            throw new Exception("queryBuildInfo null bm_name " + p.mId);
814 mhunt 2911
          }
2912
          else if ( bm_name.compareTo("Solaris") == 0 )
2913
          {
2914
            bs.setSolaris();
2915
          }
2916
          else if ( bm_name.compareTo("Win32") == 0 )
2917
          {
2918
            bs.setWin32();
2919
          }
2920
          else if ( bm_name.compareTo("Linux") == 0 )
2921
          {
2922
            bs.setLinux();
2923
          }
2924
          else if ( bm_name.compareTo("Generic") == 0 )
2925
          {
2926
            bs.setGeneric();
2927
          }
2928
          else
2929
          {
2930
            supportedBuildStandard = false;
2931
          }
2932
 
2933
          String bsa_name = rset.getString("bsa_name");
2934
 
2935
          if ( bsa_name == null )
2936
          {
2937
            mLogger.fatal("queryBuildInfo null bsa_name " + p.mId);
2938
            // show stopper
868 mhunt 2939
            throw new Exception("queryBuildInfo null bsa_name " + p.mId);
814 mhunt 2940
          }
2941
          else if ( bsa_name.compareTo("Production") == 0 )
2942
          {
2943
            bs.setProduction();
2944
          }
2945
          else if ( bsa_name.compareTo("Debug") == 0 )
2946
          {
2947
            bs.setDebug();
2948
          }
2949
          else if ( bsa_name.compareTo("Production and Debug") == 0 )
2950
          {
2951
            bs.setAll();
2952
          }
2953
          else if ( bsa_name.compareTo("Java 1.4") == 0 )
2954
          {
2955
            bs.set1_4();
2956
          }
2957
          else if ( bsa_name.compareTo("Java 1.5") == 0 )
2958
          {
2959
            bs.set1_5();
2960
          }
2961
          else if ( bsa_name.compareTo("Java 1.6") == 0 )
2962
          {
2963
            bs.set1_6();
2964
          }
2965
          else
2966
          {
2967
            supportedBuildStandard = false;
2968
          }
2969
 
2970
          if ( supportedBuildStandard )
2971
          {
2972
            p.mBuildStandardCollection.add(bs);
2973
          }
2974
        }
830 mhunt 2975
 
2976
        rset.close();
2977
        stmt.close();
814 mhunt 2978
      }
2979
      catch ( SQLException e )
2980
      {
2981
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
2982
        {
2983
          mLogger.error("queryBuildInfo database access error only");
2984
          throw new SQLException();
2985
        }
2986
        else
2987
        {
2988
          mLogger.fatal("queryBuildInfo show stopper");
868 mhunt 2989
          throw new Exception("queryBuildInfo show stopper");
814 mhunt 2990
        }
2991
      }
2992
    }
2993
  }
2994
 
2995
  /**returns the Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
2996
   */
864 mhunt 2997
  private Package findPackage(String alias, Vector<Package> packageCollection)
814 mhunt 2998
  {
2999
    mLogger.debug("findPackage 2 alias " + alias);
3000
    Package retVal = NULL_PACKAGE;
3001
 
864 mhunt 3002
    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
814 mhunt 3003
    {
864 mhunt 3004
      Package p = it.next();
814 mhunt 3005
 
3006
      if ( p.mAlias.compareTo( alias ) == 0 )
3007
      {
3008
        retVal = p;
3009
        break;
3010
      }
3011
    }
844 dpurdie 3012
 
814 mhunt 3013
    mLogger.info("findPackage 2 returned " + retVal.mName);
3014
    return retVal;
3015
  }
3016
 
3017
  /**essentially locks the row in the BUILD_SERVICE_CONFIG table with a service of MUTEX
3018
   * for the duration of the connection
3019
   * this prevents other MasterThreads from generating build files in parallel
3020
   * and hence prevents planned version numbering contention
3021
   * select CONFIG from BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE
3022
   */
3023
  public void claimMutex() throws SQLException, Exception
3024
  {
3025
    mLogger.debug("claimMutex");
3026
    if ( mUseDatabase )
3027
    {
3028
      try
3029
      {
3030
        CallableStatement stmt = mConnection.prepareCall("select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE");
3031
        stmt.executeUpdate();
844 dpurdie 3032
        stmt.close();
814 mhunt 3033
      }
3034
      catch ( SQLException e )
3035
      {
3036
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3037
        {
3038
          mLogger.error("claimMutex database access error only");
3039
          throw new SQLException();
3040
        }
3041
        else
3042
        {
3043
          mLogger.fatal("claimMutex show stopper");
868 mhunt 3044
          throw new Exception("claimMutex show stopper");
814 mhunt 3045
        }
3046
      }
3047
    }
3048
  }
3049
 
3050
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3051
   * update run_level set current_build_files=null where rcon_id=<rcon_id>
3052
   * returns true if successful
3053
   */
3054
  public boolean clearBuildFile(int rcon_id) throws SQLException, Exception
3055
  {
3056
    mLogger.debug("clearBuildFile");
3057
    boolean retVal = false;
3058
 
3059
    try
3060
    {
3061
      connect();
3062
      CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_build_files=null where rcon_id=" + rcon_id);
3063
      stmt.executeUpdate();
844 dpurdie 3064
      stmt.close();
814 mhunt 3065
      mConnection.commit();
3066
      disconnect();
3067
      retVal = true;
3068
    }
3069
    catch ( SQLException e )
3070
    {
3071
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3072
      {
3073
        mLogger.error("clearBuildFile database access error only");
3074
        throw new SQLException();
3075
      }
3076
      else
3077
      {
3078
        mLogger.fatal("clearBuildFile show stopper");
868 mhunt 3079
        throw new Exception("clearBuildFile show stopper");
814 mhunt 3080
      }
3081
    }
3082
 
3083
    mLogger.info("clearBuildFile returned " + retVal);
3084
    return retVal;
3085
  }
3086
 
3087
  /**updates the CURRENT_BUILD_FILES for the rtag_id
3088
   * update (
3089
   * select current_build_files from run_level rl, release_config rc
3090
   * where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id
3091
   * ) set current_build_files=<buildFile>
3092
   * returns true if successful
3093
   */
3094
  public boolean publishBuildFile(int rtag_id, String buildFile) throws SQLException, Exception
3095
  {
3096
    mLogger.debug("publishBuildFile publishing a build file of length " + buildFile.length());
3097
    boolean retVal = false;
3098
 
3099
    try
3100
    {
3101
      connect();
3102
 
3103
      PreparedStatement stmt = mConnection.prepareStatement(
3104
      "update (" +
3105
      "select current_build_files from release_manager.run_level rl, release_manager.release_config rc " +
3106
      "where rc.rtag_id=? and rl.rcon_id=rc.rcon_id" +
3107
      ") set current_build_files=?");
3108
      stmt.setInt(1, rtag_id);
3109
      stmt.setString(2, buildFile);
3110
      stmt.executeUpdate();
3111
      mConnection.commit();
844 dpurdie 3112
      stmt.close();
814 mhunt 3113
      disconnect();
3114
      retVal = true;
3115
    }
3116
    catch ( SQLException e )
3117
    {
3118
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3119
      {
3120
        mLogger.error("publishBuildFile database access error only");
3121
        throw new SQLException();
3122
      }
3123
      else
3124
      {
3125
        mLogger.fatal("publishBuildFile show stopper");
868 mhunt 3126
        throw new Exception("publishBuildFile show stopper");
814 mhunt 3127
      }
3128
    }
3129
    catch ( Exception e )
3130
    {
3131
      // this catch and rethrow is historical
3132
      // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
3133
      mLogger.fatal("publishBuildFile caught Exception " + e.getMessage());
868 mhunt 3134
      throw new Exception("publishBuildFile caught Exception " + e.getMessage());
814 mhunt 3135
    }
3136
    mLogger.info("publishBuildFile returned " + retVal);
3137
    return retVal;
3138
  }
3139
 
3140
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3141
   * this is aimed at stopping all daemons dead
3142
   * it is raised when handling an unsupported exception case in either the main or slave daemons
3143
   * typically an SQLException other than a database connection related one
3144
   */
836 mhunt 3145
  public void indefinitePause() throws SQLException
814 mhunt 3146
  {
3147
    mLogger.debug("indefinitePause");
3148
    if ( mUseDatabase )
3149
    {
836 mhunt 3150
      try
3151
      {
814 mhunt 3152
      connect();
836 mhunt 3153
      CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
814 mhunt 3154
      stmt.executeUpdate();
844 dpurdie 3155
      stmt.close();
814 mhunt 3156
      mConnection.commit();
3157
      disconnect();
836 mhunt 3158
      }
3159
      catch( SQLException e )
3160
      {
3161
        // do not throw Exception
3162
        // this is part of Exception handling
3163
        mLogger.fatal( "indefinitePause caught SQLException " + e.getMessage() );
3164
      }
3165
      catch( Exception e )
3166
      {
3167
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3168
      }
814 mhunt 3169
    }
3170
  }
3171
 
3172
  /**only used in daemon mode to determine version existence in the database
3173
   *  1 select pkg_id from package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3174
   *  2 select pkg_id from planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3175
   * returns true if either resultset contains one record to indicate it already exists
3176
   */
3177
  boolean queryPackageVersions(int pkg_id, String pkg_version) throws SQLException, Exception
3178
  {
3179
    mLogger.debug("queryPackageVersions");
3180
    boolean retVal = false;
3181
 
3182
    if ( mUseDatabase )
3183
    {
3184
      try
3185
      {
3186
        mLogger.info("queryPackageVersions release_manager.package_versions");
3187
        CallableStatement stmt1 = mConnection.prepareCall("select pkg_id from release_manager.package_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3188
        ResultSet rset1 = stmt1.executeQuery();
3189
        int rsetSize = 0;
3190
 
3191
        while( rset1.next() )
3192
        {
3193
          rsetSize++;
3194
        }
830 mhunt 3195
 
3196
        rset1.close();
3197
        stmt1.close();
814 mhunt 3198
 
3199
        if ( rsetSize > 1 )
3200
        {
3201
          mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3202
          // show stopper
868 mhunt 3203
          throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3204
        }
3205
 
3206
        if ( rsetSize == 1 )
3207
        {
3208
          retVal = true;
3209
        }
3210
        else
3211
        {
3212
          mLogger.info("queryPackageVersions release_manager.planned_versions");
3213
          CallableStatement stmt2 = mConnection.prepareCall("select pkg_id from release_manager.planned_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3214
          ResultSet rset2 = stmt2.executeQuery();
3215
          rsetSize = 0;
3216
 
3217
          while( rset2.next() )
3218
          {
3219
            rsetSize++;
3220
          }
830 mhunt 3221
 
3222
          rset2.close();
3223
          stmt2.close();
814 mhunt 3224
 
3225
          if ( rsetSize > 1 )
3226
          {
3227
            mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3228
            // show stopper
868 mhunt 3229
            throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3230
          }
3231
 
3232
          if ( rsetSize == 1 )
3233
          {
3234
            retVal = true;
3235
          }
3236
          else
3237
          {
3238
            mLogger.info("queryPackageVersions archive_manager.package_versions");
3239
            CallableStatement stmt3 = mConnection.prepareCall("select pkg_id from archive_manager.package_versions where pkg_id=" + pkg_id + " and pkg_version='" + pkg_version + "'");
3240
            ResultSet rset3 = stmt3.executeQuery();
3241
            rsetSize = 0;
3242
 
3243
            while( rset3.next() )
3244
            {
3245
              rsetSize++;
3246
            }
830 mhunt 3247
 
3248
            rset3.close();
3249
            stmt3.close();
814 mhunt 3250
 
3251
            if ( rsetSize > 1 )
3252
            {
3253
              mLogger.fatal("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3254
              // show stopper
868 mhunt 3255
              throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
814 mhunt 3256
            }
3257
 
3258
            if ( rsetSize == 1 )
3259
            {
3260
              retVal = true;
3261
            }
3262
          }
3263
        }
3264
      }
3265
      catch ( SQLException e )
3266
      {
3267
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3268
        {
3269
          mLogger.error("queryPackageVersions database access error only");
3270
          throw new SQLException();
3271
        }
3272
        else
3273
        {
3274
          mLogger.fatal("queryPackageVersions show stopper");
868 mhunt 3275
          throw new Exception("queryPackageVersions show stopper");
814 mhunt 3276
        }
3277
      }
3278
    }
3279
 
3280
    mLogger.info("queryPackageVersions returned " + retVal);
3281
    return retVal;
3282
  }
3283
 
3284
  /**only used in daemon mode
3285
   *  insert into planned_versions (pkg_id, pkg_version) values (<pkg_id>, <pkg_version>);
3286
   *  update
3287
   *  (
3288
   *  select current_pkg_id_being_built from run_level rl, release_config rc
3289
   *  where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id
3290
   *  )
3291
   *  set current_pkg_id_being_built=<pkg_id>
3292
   */
3293
  void claimVersion(int pkg_id, String pkg_version, int rtag_id) throws SQLException, Exception
3294
  {
3295
    mLogger.debug("claimVersion " + pkg_id + " " + pkg_version);
3296
    if ( mUseDatabase )
3297
    {
3298
      try
3299
      {
3300
        CallableStatement stmt3 = mConnection.prepareCall("insert into release_manager.planned_versions (pkg_id, pkg_version) values (" + pkg_id + ", '" + pkg_version + "')");
3301
        stmt3.executeUpdate();
844 dpurdie 3302
        stmt3.close();
814 mhunt 3303
        CallableStatement stmt4 = mConnection.prepareCall(
3304
        "update " +
3305
        "(" +
3306
        "select current_pkg_id_being_built from release_manager.run_level rl, release_manager.release_config rc " +
3307
        "where rc.rtag_id=" + rtag_id + " and rl.rcon_id=rc.rcon_id" +
3308
        ")" +
3309
        "set current_pkg_id_being_built=" + pkg_id);
3310
        stmt4.executeUpdate();
844 dpurdie 3311
        stmt4.close();
814 mhunt 3312
        mConnection.commit();
3313
      }
3314
      catch ( SQLException e )
3315
      {
3316
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3317
        {
3318
          mLogger.error("claimVersion database access error only");
3319
          throw new SQLException();
3320
        }
3321
        else
3322
        {
3323
          mLogger.fatal("claimVersion show stopper");
868 mhunt 3324
          throw new Exception("claimVersion show stopper");
814 mhunt 3325
        }
3326
      }
3327
    }
3328
  }
3329
 
818 mhunt 3330
  /**only used in daemon mode
3331
   *  update
3332
   *  (
3333
   *  select current_pkg_id_being_built from run_level
3334
   *  where rcon_id=<rcon_id>
3335
   *  )
3336
   *  set current_pkg_id_being_built=null
3337
   */
3338
  public void clearCurrentPackageBeingBuilt(int rcon_id) throws SQLException, Exception
3339
  {
3340
    mLogger.debug("clearCurrentPackageBeingBuilt " + rcon_id);
3341
    if ( mUseDatabase )
3342
    {
3343
      try
3344
      {
820 mhunt 3345
        connect();
818 mhunt 3346
        CallableStatement stmt4 = mConnection.prepareCall(
3347
        "update " +
3348
        "(" +
3349
        "select current_pkg_id_being_built from run_level " +
3350
        "where rcon_id=" + rcon_id +
3351
        ")" +
3352
        "set current_pkg_id_being_built=null" );
3353
        stmt4.executeUpdate();
844 dpurdie 3354
        stmt4.close();
818 mhunt 3355
        mConnection.commit();
820 mhunt 3356
        disconnect();
818 mhunt 3357
      }
3358
      catch ( SQLException e )
3359
      {
3360
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3361
        {
3362
          mLogger.error("clearCurrentPackageBeingBuilt database access error only");
3363
          throw new SQLException();
3364
        }
3365
        else
3366
        {
3367
          mLogger.fatal("clearCurrentPackageBeingBuilt show stopper");
868 mhunt 3368
          throw new Exception("clearCurrentPackageBeingBuilt show stopper");
818 mhunt 3369
        }
3370
      }
3371
    }
3372
  }
3373
 
814 mhunt 3374
  /**handles database connection/disconnection
3375
   * executes the AutoMakeRelease stored procedure with the passed parameters
3376
   */
3377
  public void autoMakeRelease(String rtagId, String packageName, 
3378
                              String packageExtension, 
3379
                              String packageVersion, String packageLabel, 
3380
                              String packageDepends, String isRipple) throws SQLException, Exception
3381
  {
3382
    mLogger.debug("autoMakeRelease " + packageName);
3383
    if ( mUseDatabase )
3384
    {
3385
      try
3386
      {
3387
        connect();
3388
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.AUTO_MAKE_RELEASE(?,?,?,?,?,?,?,?); end;" );
3389
        stmt.registerOutParameter( 1, Types.INTEGER);
3390
        stmt.setString( 2, rtagId );
3391
        stmt.setString( 3, packageName );
3392
        stmt.setString( 4, packageExtension );
3393
        stmt.setString( 5, packageVersion );
3394
        stmt.setString( 6, packageLabel );
3395
        stmt.setString( 7, packageDepends );
3396
        stmt.setString( 8, isRipple );
3397
        stmt.setString( 9, "buildadm" );
3398
        stmt.executeUpdate();
3399
        int result = stmt.getInt( 1 );
3400
 
3401
        if ( result <= 0 && result != -2 )
3402
        {
3403
          // -2 if already released
3404
          // flag build failure
3405
          mLogger.fatal("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
868 mhunt 3406
          throw new Exception("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
814 mhunt 3407
        }
844 dpurdie 3408
        stmt.close();
814 mhunt 3409
        mConnection.commit();
3410
        disconnect();
3411
      }
3412
      catch( SQLException e )
3413
      {
3414
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3415
        {
3416
          mLogger.error("autoMakeRelease database access error only");
3417
          throw new SQLException();
3418
        }
3419
        else
3420
        {
3421
          mLogger.fatal("autoMakeRelease show stopper");
868 mhunt 3422
          throw new Exception("autoMakeRelease show stopper");
814 mhunt 3423
        }
3424
      }
3425
    }
3426
  }
3427
 
3428
  /**handles database connection/disconnection
834 mhunt 3429
   * executes the insertPackageMetrics stored procedure with the passed parameters
3430
   */
3431
  public void insertPackageMetrics(String rtagId, String packageName, 
3432
                              		 String packageExtension, String metrics) throws SQLException, Exception
3433
  {
3434
    mLogger.debug("insertPackageMetrics " + packageName);
3435
    if ( mUseDatabase )
3436
    {
3437
      try
3438
      {
3439
        connect();
3440
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.INSERT_PACKAGE_METRICS(?,?,?,?); end;" );
3441
        stmt.registerOutParameter( 1, Types.INTEGER);
3442
        stmt.setString( 2, rtagId );
3443
        stmt.setString( 3, packageName );
3444
        stmt.setString( 4, packageExtension );
3445
        stmt.setString( 5, metrics );
3446
        stmt.executeUpdate();
3447
        int result = stmt.getInt( 1 );
3448
 
836 mhunt 3449
        if ( result != 0 )
834 mhunt 3450
        {
3451
          // flag build failure
3452
          mLogger.fatal("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
868 mhunt 3453
          throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
834 mhunt 3454
        }
844 dpurdie 3455
        stmt.close();
834 mhunt 3456
        mConnection.commit();
3457
        disconnect();
3458
      }
3459
      catch( SQLException e )
3460
      {
3461
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3462
        {
3463
          mLogger.error("insertPackageMetrics database access error only");
3464
          throw new SQLException();
3465
        }
3466
        else
3467
        {
3468
          mLogger.fatal("insertPackageMetrics show stopper");
868 mhunt 3469
          throw new Exception("insertPackageMetrics show stopper");
834 mhunt 3470
        }
3471
      }
3472
    }
3473
  }
3474
 
3475
  /**handles database connection/disconnection
866 mhunt 3476
   * executes the Exclude_Indirect_From_Build stored procedure with the passed parameters
814 mhunt 3477
   */
3478
  public void excludeFromBuild(String packageVersionId, 
866 mhunt 3479
                               String packageVersion, String rtagId, String rootPvId,
3480
                               String rootCause, String rootFile) throws SQLException, Exception
814 mhunt 3481
  {
3482
    mLogger.debug("excludeFromBuild " + packageVersionId);
3483
    if ( mUseDatabase )
3484
    {
3485
      try
3486
      {
3487
        connect();
866 mhunt 3488
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
814 mhunt 3489
        stmt.registerOutParameter( 1, Types.INTEGER);
3490
        stmt.setString( 2, packageVersionId );
3491
        stmt.setString( 3, packageVersion );
3492
        stmt.setString( 4, rtagId );
3493
        stmt.setString( 5, "buildadm" );
866 mhunt 3494
        stmt.setString( 6, rootPvId);
3495
        stmt.setString( 7, rootCause);
3496
        stmt.setString( 8, rootFile);
814 mhunt 3497
        stmt.executeUpdate();
3498
        int result = stmt.getInt( 1 );
3499
 
3500
        if ( result != 0 )
3501
        {
3502
          // flag build failure
866 mhunt 3503
          mLogger.fatal( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
868 mhunt 3504
          throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
814 mhunt 3505
        }
844 dpurdie 3506
        stmt.close();
814 mhunt 3507
        mConnection.commit();
3508
        disconnect();
3509
      }
3510
      catch( SQLException e )
3511
      {
3512
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3513
        {
3514
          mLogger.error("excludeFromBuild database access error only");
3515
          throw new SQLException();
3516
        }
3517
        else
3518
        {
3519
          mLogger.fatal("excludeFromBuild show stopper");
868 mhunt 3520
          throw new Exception("excludeFromBuild show stopper");
814 mhunt 3521
        }
3522
      }
3523
    }
3524
  }
3525
 
866 mhunt 3526
  /**removes an excluded package from the do_not_ripple table
3527
   */
3528
  public void includeToBuild(String packageVersionId, String rtagId) throws SQLException, Exception
3529
  {
3530
    mLogger.debug("includeToBuild " + packageVersionId);
3531
    if ( mUseDatabase )
3532
    {
3533
      try
3534
      {
3535
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.do_not_ripple where rtag_id=" + rtagId + " and pv_id=" + packageVersionId);
3536
        stmt.executeUpdate();
3537
        stmt.close();
3538
        mConnection.commit();
3539
      }
3540
      catch( SQLException e )
3541
      {
3542
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3543
        {
3544
          mLogger.error("includeToBuild database access error only");
3545
          throw new SQLException();
3546
        }
3547
        else
3548
        {
3549
          mLogger.fatal("includeToBuild show stopper");
868 mhunt 3550
          throw new Exception("includeToBuild show stopper");
866 mhunt 3551
        }
3552
      }
3553
    }
3554
  }
3555
 
814 mhunt 3556
  /**Representation of a row in the RELEASE_CONFIG table
3557
   */
3558
  private class ReleaseConfig
3559
  {
3560
    /**rtag_id column value
3561
     * @attribute
3562
     */
3563
    private int mRtag_id;
3564
 
3565
    /**rcon_id column value
3566
     * @attribute
3567
     */
3568
    private int mRcon_id;
3569
 
3570
    /**daemon_mode column value
3571
     * @attribute
3572
     */
3573
    private char mDaemon_mode;
3574
 
3575
    /**gbebuildfilter column value
3576
     * @attribute
3577
     */
3578
    private String mGbebuildfilter;
3579
 
3580
    /**constructor
3581
     */
3582
    ReleaseConfig(int rtag_id, int rcon_id, char daemon_mode, 
3583
                  String gbebuildfilter)
3584
    {
3585
      mLogger.debug("ReleaseConfig rtag_id " + rtag_id + " rcon_id " + rcon_id + " daemon_mode " + daemon_mode + " gbebuildfilter " + gbebuildfilter );
3586
      mRtag_id = rtag_id;
3587
      mRcon_id = rcon_id;
3588
      mDaemon_mode = daemon_mode;
3589
      mGbebuildfilter = gbebuildfilter;
3590
    }
3591
 
3592
    /**accessor method
3593
     */
3594
    int get_rtag_id()
3595
    {
3596
      mLogger.debug("get_rtag_id");
3597
      mLogger.info("get_rtag_id returned " + mRtag_id);
3598
      return mRtag_id;
3599
    }
3600
 
3601
    /**accessor method
3602
     */
3603
    int get_rcon_id()
3604
    {
3605
      mLogger.debug("get_rcon_id");
3606
      mLogger.info("get_rcon_id returned " + mRcon_id);
3607
      return mRcon_id;
3608
    }
3609
 
3610
    /**accessor method
3611
     */
3612
    char get_daemon_mode()
3613
    {
3614
      mLogger.debug("get_daemon_mode");
3615
      mLogger.info("get_daemon_mode returned " + mDaemon_mode);
3616
      return mDaemon_mode;
3617
    }
3618
 
3619
    /**accessor method
3620
     */
3621
    String get_gbebuildfilter()
3622
    {
3623
      mLogger.debug("get_gbebuildfilter");
3624
      mLogger.info("get_gbebuildfilter returned " + mGbebuildfilter);
3625
      return mGbebuildfilter;
3626
    }
3627
  }
3628
 
3629
  /**Representation of a row in the RUN_LEVEL table
3630
   */
3631
  private class RunLevel
3632
  {
3633
    /**rcon_id column value
3634
     * @attribute
3635
     */
3636
    private int mRcon_id;
3637
 
3638
    /**current_build_files column value
3639
     * @attribute
3640
     */
3641
    private String mCurrent_build_file;
3642
 
3643
    /**current_run_level column value
3644
     * @attribute
3645
     */
3646
    private int mCurrent_run_level;
3647
 
3648
    /**pause column value
3649
     * @attribute
3650
     */
3651
    private boolean mPause;
3652
 
3653
    /**constructor
3654
     */
3655
    RunLevel(int rcon_id, String current_build_file, int current_run_level, 
3656
             boolean pause)
3657
    {
3658
      mLogger.debug("RunLevel");
3659
      mRcon_id = rcon_id;
3660
      mCurrent_build_file = current_build_file;
3661
      mCurrent_run_level = current_run_level;
3662
      mPause = pause;
3663
    }
3664
 
3665
    /**accessor method
3666
     */
3667
    int get_rcon_id()
3668
    {
3669
      mLogger.debug("get_rcon_id");
3670
      mLogger.info("get_rcon_id returned " + mRcon_id);
3671
      return mRcon_id;
3672
    }
3673
 
3674
    /**accessor method
3675
     */
3676
    String get_current_build_file()
3677
    {
3678
      mLogger.debug("get_current_build_file");
3679
      mLogger.info("get_current_build_file returned " + mCurrent_build_file);
3680
      return mCurrent_build_file;
3681
    }
3682
 
3683
    /**accessor method
3684
     */
3685
    int get_current_run_level()
3686
    {
3687
      mLogger.debug("get_current_run_level");
3688
      mLogger.info("get_current_run_level returned " + mCurrent_run_level);
3689
      return mCurrent_run_level;
3690
    }
3691
 
3692
    /**accessor method
3693
     */
3694
    boolean get_pause()
3695
    {
3696
      mLogger.debug("get_pause");
3697
      mLogger.debug("get_pause returned " + mPause);      
3698
      return mPause;
3699
    }
3700
 
3701
  }
3702
 
3703
  /**constructor
3704
   */
3705
  public ReleaseManager(final String connectionString, final String username, 
3706
                        final String password)
3707
  {
3708
    mLogger.debug("ReleaseManager " + connectionString);
3709
    mConnectionString = connectionString;
3710
    mUsername = username;
3711
    mPassword = password;
3712
  }
3713
 
3714
  /**constructor used when schema information is unknown eg location, username, password
3715
   */
3716
  public ReleaseManager()
3717
  {
3718
    // inherit mConnectionString, mUsername, mPassword
3719
     mLogger.debug("ReleaseManager");
3720
  }
3721
 
3722
  /**connect to oracle
3723
   */
3724
  public void connect() throws SQLException, Exception
3725
  {
3726
    mLogger.debug("connect");
850 mhunt 3727
    mSession.lock();
814 mhunt 3728
 
3729
    if ( !mUseDatabase )
3730
    {
3731
      mLogger.info("connect !mUseDatabase");
3732
    }
3733
    else
3734
    {
3735
      if ( !mRegistered )
3736
      {
3737
        try
3738
        {
3739
          // the JDBC driver is registered only once per database that needs to be accessed
3740
          mLogger.debug("connect registering driver");
3741
          DriverManager.registerDriver( new OracleDriver() );
3742
          mRegistered = true;
3743
        }
3744
        catch(SQLException e)
3745
        {
3746
          mLogger.fatal("connect failed to register the oracle jdbc driver with the driver manager");
868 mhunt 3747
          throw new Exception("connect failed to register the oracle jdbc driver with the driver manager");
814 mhunt 3748
        }
3749
      }
3750
 
838 mhunt 3751
      // DEVI 46868
3752
      // loop indefinitely until a connection attempt succeeds
3753
      // unless the failure is on the first attempt
3754
      boolean problemConnecting;
3755
 
3756
      do
814 mhunt 3757
      {
850 mhunt 3758
        mLogger.warn("connect check connection");
838 mhunt 3759
        problemConnecting = false;
3760
 
3761
        try
836 mhunt 3762
        {
850 mhunt 3763
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
838 mhunt 3764
          {
850 mhunt 3765
            mLogger.warn("connect calling getConnection");
838 mhunt 3766
            mConnection = DriverManager.getConnection(mConnectionString, mUsername, mPassword);
3767
          }
836 mhunt 3768
        }
838 mhunt 3769
        catch(SQLException e)
3770
        {
850 mhunt 3771
          mLogger.warn("connect determined problem connecting");
838 mhunt 3772
          problemConnecting = true;
3773
          try
3774
          {
3775
            // sleep 30 secs
844 dpurdie 3776
            mLogger.warn("connect getConnection failed. sleep 30secs");
838 mhunt 3777
            Thread.sleep(30000);
3778
          }
3779
          catch (InterruptedException f)
3780
          {
3781
            mLogger.warn("connect caught InterruptedException");
3782
          }
3783
 
844 dpurdie 3784
 
838 mhunt 3785
          if ( mConnection == null )
3786
          {
3787
            // failed on first connection attempt - unlikely due to database loading - likely bad connection parameters
3788
            throw new SQLException();
3789
          }
3790
        }
3791
      } while ( problemConnecting );
814 mhunt 3792
    }
844 dpurdie 3793
 
814 mhunt 3794
  }
3795
 
3796
  /**disconnect from oracle
3797
   */
836 mhunt 3798
  public void disconnect() throws Exception
814 mhunt 3799
  {
3800
    mLogger.debug("disconnect");
838 mhunt 3801
/* DEVI 46868 
3802
 * never disconnect, thus the only time a connection attempt is made
3803
 * is when the server has (timed out) disconnected the session
3804
 *  if ( mUseDatabase )
814 mhunt 3805
    {
3806
      try
3807
      {
3808
        mConnection.close();
3809
      }
3810
      catch(SQLException e)
3811
      {
3812
        mLogger.error("disconnect caught Exception");
836 mhunt 3813
        throw new Exception();
814 mhunt 3814
      }
838 mhunt 3815
    }*/
850 mhunt 3816
    mSession.unlock();
814 mhunt 3817
  }
3818
 
3819
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id of the first element
3820
   */
3821
  public boolean getFirstReleaseConfig(MutableInt rcon_id)
3822
  {
3823
    mLogger.debug("getFirstReleaseConfig 1");
3824
    boolean retVal = true;
3825
 
3826
    try
3827
    {
3828
      mReleaseConfigIndex = 0;
864 mhunt 3829
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3830
      rcon_id.value = rc.get_rcon_id();
3831
    }
3832
    catch( ArrayIndexOutOfBoundsException e )
3833
    {
3834
      retVal = false;
3835
    }
3836
 
3837
    mLogger.info("getFirstReleaseConfig 1 returning " + retVal);
3838
    return retVal;
3839
  }
3840
 
3841
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the first element
3842
   */
3843
  public boolean getFirstReleaseConfig(MutableInt rtag_id, 
3844
                                       MutableInt rcon_id, 
3845
                                       MutableChar daemon_mode, 
3846
                                       MutableString gbebuildfilter)
3847
  {
3848
    mLogger.debug("getFirstReleaseConfig 2");
3849
    boolean retVal = true;
3850
 
3851
    try
3852
    {
3853
      mReleaseConfigIndex = 0;
864 mhunt 3854
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3855
      rtag_id.value = rc.get_rtag_id();
3856
      rcon_id.value = rc.get_rcon_id();
3857
      daemon_mode.value = rc.get_daemon_mode();
3858
      gbebuildfilter.value = rc.get_gbebuildfilter();
3859
    }
3860
    catch( ArrayIndexOutOfBoundsException e )
3861
    {
3862
      retVal = false;
3863
    }
3864
 
3865
    mLogger.info("getFirstReleaseConfig 2 returning " + retVal);
3866
    return retVal;
3867
  }
3868
 
3869
  /**returns true if the mRunLevelCollection is not empty and returns the rcon_id and current_run_level of the first element
3870
   */
3871
  public boolean getFirstRunLevel(MutableInt rcon_id, 
3872
                                  MutableInt current_run_level)
3873
  {
3874
    mLogger.debug("getFirstRunLevel");
3875
    boolean retVal = true;
3876
 
3877
    try
3878
    {
3879
      mRunLevelIndex = 0;
864 mhunt 3880
      RunLevel rl = mRunLevelCollection.get( mRunLevelIndex );
814 mhunt 3881
      rcon_id.value = rl.get_rcon_id();
3882
      current_run_level.value = rl.get_current_run_level();
3883
    }
3884
    catch( ArrayIndexOutOfBoundsException e )
3885
    {
3886
      retVal = false;
3887
    }
3888
 
3889
    mLogger.info("getFirstRunLevel returning " + retVal);
3890
    return retVal;
3891
  }
3892
 
3893
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id of the next element
3894
   */
3895
  public boolean getNextReleaseConfig(MutableInt rcon_id)
3896
  {
3897
    mLogger.debug("getNextReleaseConfig 1");
3898
    boolean retVal = true;
3899
 
3900
    try
3901
    {
3902
      mReleaseConfigIndex++;
864 mhunt 3903
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3904
      rcon_id.value = rc.get_rcon_id();
3905
    }
3906
    catch( ArrayIndexOutOfBoundsException e )
3907
    {
3908
      retVal = false;
3909
    }
3910
 
3911
    mLogger.info("getNextReleaseConfig 1 returning " + retVal);
3912
    return retVal;
3913
  }
3914
 
3915
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the next element
3916
   */
3917
  public boolean getNextReleaseConfig(MutableInt rtag_id, 
3918
                                      MutableInt rcon_id, 
3919
                                      MutableChar daemon_mode, 
3920
                                      MutableString gbebuildfilter)
3921
  {
3922
    mLogger.debug("getNextReleaseConfig 2");
3923
    boolean retVal = true;
3924
 
3925
    try
3926
    {
3927
      mReleaseConfigIndex++;
864 mhunt 3928
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
814 mhunt 3929
      rtag_id.value = rc.get_rtag_id();
3930
      rcon_id.value = rc.get_rcon_id();
3931
      daemon_mode.value = rc.get_daemon_mode();
3932
      gbebuildfilter.value = rc.get_gbebuildfilter();
3933
    }
3934
    catch( ArrayIndexOutOfBoundsException e )
3935
    {
3936
      retVal = false;
3937
    }
3938
 
3939
    mLogger.info("getNextReleaseConfig 2 returning " + retVal);
3940
    return retVal;
3941
  }
3942
 
3943
  /**returns true if the mRunLevelCollection contains a next element and returns the rcon_id and current_run_level of the next element
3944
   */
3945
  public boolean getNextRunLevel(MutableInt rcon_id, 
3946
                                 MutableInt current_run_level)
3947
  {
3948
    mLogger.debug("getNextRunLevel");
3949
    boolean retVal = true;
3950
 
3951
    try
3952
    {
3953
      mRunLevelIndex++;
864 mhunt 3954
      RunLevel rl = mRunLevelCollection.get( mRunLevelIndex );
814 mhunt 3955
      rcon_id.value = rl.get_rcon_id();
3956
      current_run_level.value = rl.get_current_run_level();
3957
    }
3958
    catch( ArrayIndexOutOfBoundsException e )
3959
    {
3960
      retVal = false;
3961
    }
3962
 
3963
    mLogger.info("getNextRunLevel returning " + retVal);
3964
    return retVal;
3965
  }
3966
 
3967
  /**queries the RUN_LEVEL table using the rcon_id primary key
3968
   * returns false if the query returns a result set containing one row with a non NULL pause column
3969
   * (indicating intent to pause the thread)
3970
   * refer to sequence diagram allowed to proceed
3971
   */
3972
  public boolean queryDirectedRunLevel(final int rcon_id) throws SQLException, Exception
3973
  {
3974
    mLogger.debug("queryDirectedRunLevel " + rcon_id);
3975
    boolean retVal = true;
3976
 
3977
    if ( mUseDatabase )
3978
    {
3979
      try
3980
      {
3981
        CallableStatement stmt = mConnection.prepareCall("select pause from release_manager.run_level where rcon_id=" + rcon_id);
3982
        ResultSet rset = stmt.executeQuery();
3983
        int rsetSize = 0;
3984
 
3985
        while( rset.next() )
3986
        {
3987
          rsetSize++;
3988
          rset.getInt("pause");
3989
 
3990
          if ( !rset.wasNull() )
3991
          {
3992
            retVal = false;
3993
          }
3994
        }
830 mhunt 3995
 
3996
        rset.close();
3997
        stmt.close();
814 mhunt 3998
 
3999
        if ( rsetSize > 1 )
4000
        {
4001
          mLogger.fatal("queryDirectedRunLevel rsetSize > 1");
4002
          // show stopper
868 mhunt 4003
          throw new Exception("queryDirectedRunLevel rsetSize > 1");
814 mhunt 4004
        }
4005
      }
4006
      catch ( SQLException e )
4007
      {
4008
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4009
        {
4010
          mLogger.error("queryDirectedRunLevel database access error only");
4011
          throw new SQLException();
4012
        }
4013
        else
4014
        {
4015
          mLogger.fatal("queryDirectedRunLevel show stopper");
868 mhunt 4016
          throw new Exception("queryDirectedRunLevel show stopper");
814 mhunt 4017
        }
4018
      }
4019
    }
4020
 
4021
    mLogger.info("queryDirectedRunLevel returning " + retVal);
4022
    return retVal;
4023
  }
4024
 
4025
  /**queries the RELEASE_CONFIG table using the rcon_id primary key, rtag_id, daemon_hostname, daemon_mode, gbebuildfilter
4026
   * return true if the query contains a result set containing one row
4027
   * (indicating the rcon_id is still configured and its configuration is unchanged)
4028
   * refer to sequence diagram allowed to proceed
4029
   */
4030
  public boolean queryReleaseConfig(final int rtag_id, final int rcon_id, 
4031
                                    final String daemon_hostname, 
4032
                                    final char daemon_mode, 
4033
                                    final String gbebuildfilter) throws SQLException, Exception
4034
  {
4035
    mLogger.debug("queryReleaseConfig 1");
4036
    boolean retVal = false;
4037
 
4038
    if ( !mUseDatabase )
4039
    {
4040
      mLogger.info("queryReleaseConfig 1 !mUseDatabase");
4041
 
4042
      if ( mConnectionString.compareTo("unit test exit") != 0 )
4043
      {
4044
        retVal = true;
4045
      }
4046
    }
4047
    else
4048
    {
4049
      try
4050
      {
856 mhunt 4051
        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 4052
        CallableStatement stmt = mConnection.prepareCall( sql );
4053
        ResultSet rset = stmt.executeQuery();
4054
        int rsetSize = 0;
4055
 
4056
        while( rset.next() )
4057
        {
4058
          rsetSize++;
4059
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4060
 
4061
          if ( gbe_buildfilter == null )
4062
          {
4063
            mLogger.info("queryReleaseConfig 1 gbe_buildfilter == null");
4064
            if ( gbebuildfilter.length() == 0 )
4065
            {
4066
              retVal = true;
4067
            }
4068
          }
4069
          else
4070
          {
4071
            if ( gbebuildfilter.compareTo( gbe_buildfilter ) == 0 )
4072
            {
4073
              retVal = true;
4074
            }
4075
          }
4076
        }
830 mhunt 4077
 
4078
        rset.close();
4079
        stmt.close();
814 mhunt 4080
 
4081
        if ( rsetSize > 1 )
4082
        {
4083
          mLogger.fatal("queryReleaseConfig 1 rsetSize > 1");
4084
          // show stopper
868 mhunt 4085
          throw new Exception("queryReleaseConfig 1 rsetSize > 1");
814 mhunt 4086
        }
4087
      }
4088
      catch ( SQLException e )
4089
      {
4090
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4091
        {
4092
          mLogger.error("queryReleaseConfig 1 database access error only");
4093
          throw new SQLException();
4094
        }
4095
        else
4096
        {
4097
          mLogger.fatal("queryReleaseConfig 1 show stopper");
868 mhunt 4098
          throw new Exception("queryReleaseConfig 1 show stopper");
814 mhunt 4099
        }
4100
      }
4101
    }
4102
 
4103
    mLogger.info("queryReleaseConfig 1 returning " + retVal);
4104
    return retVal;
4105
  }
4106
 
4107
  /**removes all elements from the mReleaseConfigCollection
4108
   * handles database connection and disconnection
4109
   * queries the RELEASE_CONFIG table using the rtag_id
4110
   * populates the mReleaseConfigCollection with the query result set
4111
   * partially implements the sequence diagrams coordinate slave threads generate build files
4112
   */
4113
  public void queryReleaseConfig(final int rtag_id) throws SQLException, Exception
4114
  {
4115
    mLogger.debug("queryReleaseConfig 2");
4116
    mReleaseConfigCollection.removeAllElements();
4117
 
4118
    if ( !mUseDatabase )
4119
    {
4120
      mLogger.info("queryReleaseConfig 2 !mUseDatabase");
4121
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unittestbuildfilter");
4122
      mReleaseConfigCollection.add(releaseConfig);
4123
      releaseConfig = new ReleaseConfig(1,2,'S',"anotherunittestbuildfilter");
4124
      mReleaseConfigCollection.add(releaseConfig);
4125
    }
4126
    else
4127
    {
4128
      try
4129
      {
4130
        connect();
4131
        CallableStatement stmt = mConnection.prepareCall("select rcon_id, daemon_mode, gbe_buildfilter from release_manager.release_config where rtag_id=" + rtag_id );
4132
        ResultSet rset = stmt.executeQuery();
4133
 
4134
        while( rset.next() )
4135
        {
4136
          int rcon_id = rset.getInt("rcon_id");
4137
 
4138
          if ( rset.wasNull() )
4139
          {
4140
            mLogger.fatal("queryReleaseConfig 2 null rcon_id " + rtag_id);
4141
            // show stopper
868 mhunt 4142
            throw new Exception("queryReleaseConfig 2 null rcon_id " + rtag_id);
814 mhunt 4143
          }
4144
 
4145
          char dm = 'S';          
4146
          String daemon_mode = rset.getString("daemon_mode");
4147
 
4148
          if ( daemon_mode != null )
4149
          {
4150
            mLogger.info("queryReleaseConfig 2 daemon_mode " + daemon_mode + ".");
4151
 
4152
            if ( daemon_mode.compareTo("M") == 0 )
4153
            {
4154
              dm = 'M';
4155
            }
4156
          }
4157
 
4158
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4159
 
4160
          if ( gbe_buildfilter == null )
4161
          {
4162
            gbe_buildfilter = new String("");
4163
          }
4164
 
4165
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4166
          mReleaseConfigCollection.add(releaseConfig);
4167
        }
4168
 
830 mhunt 4169
 
4170
        rset.close();
4171
        stmt.close();
814 mhunt 4172
        disconnect();
4173
      }
4174
      catch ( SQLException e )
4175
      {
4176
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4177
        {
4178
          mLogger.error("queryReleaseConfig 2 daemon_mode database access error only");
4179
          throw new SQLException();
4180
        }
4181
        else
4182
        {
4183
          mLogger.fatal("queryReleaseConfig 2 show stopper");
868 mhunt 4184
          throw new Exception("queryReleaseConfig 2 show stopper");
814 mhunt 4185
        }
4186
      }
4187
    }
4188
  }
4189
 
4190
  /**removes all elements from the mReleaseConfigCollection
4191
   * handles database connection and disconnection
4192
   * queries the RELEASE_CONFIG table using the daemon_hostname
4193
   * populates the mReleaseConfigCollection with the query result set
4194
   * partially implements the sequence diagram spawn thread
4195
   */
4196
  public void queryReleaseConfig(final String hostname) throws SQLException, Exception
4197
  {
4198
    mLogger.debug("queryReleaseConfig 3 " + hostname);
4199
    mReleaseConfigCollection.removeAllElements();
4200
 
4201
    if ( mConnectionString.compareTo("unit test spawn thread") == 0)
4202
    {
4203
      mLogger.info("queryReleaseConfig 3 unit test spawn thread");
4204
      // specifying a gbebuildfilter of unit test is designed to invoke a benign thread for unit test purposes
4205
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unit test spawn thread");
4206
      mReleaseConfigCollection.add(releaseConfig);
4207
      releaseConfig = new ReleaseConfig(2,2,'S',"unit test spawn thread");
4208
      mReleaseConfigCollection.add(releaseConfig);
4209
    }
4210
    else
4211
    {
4212
      try
4213
      {
4214
        connect();
856 mhunt 4215
        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 4216
        ResultSet rset = stmt.executeQuery();
4217
 
4218
        while( rset.next() )
4219
        {
4220
          int rtag_id = rset.getInt("rtag_id");
4221
 
4222
          if ( rset.wasNull() )
4223
          {
4224
            mLogger.fatal("queryReleaseConfig 3 null rtag_id");
4225
            // show stopper
868 mhunt 4226
            throw new Exception("queryReleaseConfig 3 null rtag_id");
814 mhunt 4227
          }
4228
 
4229
          int rcon_id = rset.getInt("rcon_id");
4230
 
4231
          if ( rset.wasNull() )
4232
          {
4233
            mLogger.fatal("queryReleaseConfig 3 null rcon_id");
4234
            // show stopper
868 mhunt 4235
            throw new Exception("queryReleaseConfig 3 null rcon_id");
814 mhunt 4236
          }
4237
 
4238
          char dm = 'S';          
4239
          String daemon_mode = rset.getString("daemon_mode");
4240
 
4241
          if ( daemon_mode != null )
4242
          {
4243
            mLogger.info("queryReleaseConfig 3 daemon_mode " + daemon_mode + ".");
4244
 
4245
            if ( daemon_mode.compareTo("M") == 0 )
4246
            {
4247
              dm = 'M';
4248
            }
4249
          }
4250
 
4251
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
4252
 
4253
          if ( gbe_buildfilter == null )
4254
          {
4255
            gbe_buildfilter = new String("");
4256
          }
4257
 
4258
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4259
          mReleaseConfigCollection.add(releaseConfig);
4260
        }
4261
 
830 mhunt 4262
        rset.close();
4263
        stmt.close();
814 mhunt 4264
        disconnect();
4265
      }
4266
      catch ( SQLException e )
4267
      {
4268
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4269
        {
4270
          mLogger.error("queryReleaseConfig 3 database access error only");
4271
          throw new SQLException();
4272
        }
4273
        else
4274
        {
4275
          mLogger.fatal("queryReleaseConfig 3 show stopper");
868 mhunt 4276
          throw new Exception("queryReleaseConfig 3 show stopper");
814 mhunt 4277
        }
4278
      }
4279
    }
4280
  }
4281
 
4282
  /**queries the RUN_LEVEL table using the rcon_id primary key
4283
   * handles database connection and disconnection
4284
   * polls indefinitely until CURRENT_BUILD_FILES column is non NULL
4285
   * returns the current_build_files
4286
   * implements the sequence diagram consume build files
4287
   */
4288
  public void queryRunLevel(int rcon_id, MutableString currentBuildFiles) throws SQLException, Exception
4289
  {
4290
    mLogger.debug("queryRunLevel 1 rcon_id " + rcon_id);
4291
    if ( !mUseDatabase )
4292
    {
4293
      mLogger.info("queryRunLevel 1 !mUseDatabase");
4294
      currentBuildFiles.value = "unit test build file content";
4295
    }
4296
    else
4297
    {
4298
      try
4299
      {
4300
        connect();
4301
        CallableStatement stmt = mConnection.prepareCall("select current_build_files from release_manager.run_level where rcon_id=" + rcon_id);
4302
        ResultSet rset = stmt.executeQuery();
4303
        int rsetSize = 0;
4304
 
4305
        while( rset.next() )
4306
        {
4307
          rsetSize++;
4308
          currentBuildFiles.value = rset.getString("current_build_files");
4309
          if (rset.wasNull())
4310
          {
4311
            currentBuildFiles.value = "";
4312
          }
4313
        }
4314
 
4315
        if ( rsetSize > 1 )
4316
        {
4317
          mLogger.fatal("queryRunLevel 1 rsetSize > 1");
4318
          // show stopper
868 mhunt 4319
          throw new Exception("queryRunLevel 1 rsetSize > 1");
814 mhunt 4320
        }
4321
 
830 mhunt 4322
        rset.close();
4323
        stmt.close();
814 mhunt 4324
        disconnect();
4325
      }
4326
      catch ( SQLException e )
4327
      {
4328
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4329
        {
4330
          mLogger.error("queryRunLevel 1 database access error only");
4331
          throw new SQLException();
4332
        }
4333
        else
4334
        {
4335
          mLogger.fatal("queryRunLevel 1 show stopper");
868 mhunt 4336
          throw new Exception("queryRunLevel 1 show stopper");
814 mhunt 4337
        }
4338
      }
4339
    }
4340
  }
4341
 
4342
  /**removes all elements from the mRunLevelCollection
4343
   * handles database connection and disconnection
4344
   *   select rl.rcon_id, rl.current_run_level from release_config rc, run_level rl
4345
   *   where rc.rtag_id=<rtag_id> and rl.rcon_id=rc.rcon_id;
4346
   * populates the mRunLevelCollection with the query result set
4347
   * refer to sequence diagram coordinate slave threads
4348
   */
4349
  public void queryRunLevel(final int rtag_id) throws SQLException, Exception
4350
  {
4351
    mLogger.debug("queryRunLevel 2 rtag_id " + rtag_id);
4352
    if ( mConnectionString.compareTo("unit test coordinate slave threads") == 0)
4353
    {
4354
      mLogger.info("queryRunLevel 2 unit test coordinate slave threads");
4355
 
4356
      if ( mRunLevelCollection.size() == 0)
4357
      {
4358
        // first time not all slave threads are waiting
4359
        RunLevel runLevel = new RunLevel(1, "", DB_WAITING, false);
4360
        mRunLevelCollection.add(runLevel);
4361
        runLevel = new RunLevel(2, "", DB_IDLE, false);
4362
        mRunLevelCollection.add(runLevel);
4363
      }
4364
      else
4365
      {
4366
        // subsequent times all slave threads are waiting
4367
        mRunLevelCollection.removeAllElements();
4368
        RunLevel runLevel = new RunLevel(1, "", DB_WAITING, false);
4369
        mRunLevelCollection.add(runLevel);
4370
        runLevel = new RunLevel(2, "", DB_WAITING, false);
4371
        mRunLevelCollection.add(runLevel);
4372
      }
4373
    }
4374
 
4375
    if ( mUseDatabase )
4376
    {
4377
      mRunLevelCollection.removeAllElements();
4378
 
4379
      try
4380
      {
4381
        connect();
4382
        CallableStatement stmt = mConnection.prepareCall(
4383
        "select rl.rcon_id, rl.current_run_level from release_config rc, run_level rl " +
4384
        "where rc.rtag_id=" +rtag_id + " and rl.rcon_id=rc.rcon_id");
4385
        ResultSet rset = stmt.executeQuery();
4386
        int rsetSize = 0;
4387
        int rcon_id = 0;
4388
        int current_run_level = 0;
4389
 
4390
        while( rset.next() )
4391
        {
4392
          rsetSize++;
4393
          rcon_id = rset.getInt("rcon_id");
4394
 
4395
          if ( rset.wasNull() )
4396
          {
4397
            mLogger.fatal("queryRunLevel 2 null rcon_id");
4398
            // show stopper
868 mhunt 4399
            throw new Exception("queryRunLevel 2 null rcon_id");
814 mhunt 4400
          }
4401
 
4402
          current_run_level = rset.getInt("current_run_level");
4403
 
4404
          if ( rset.wasNull() )
4405
          {
4406
            mLogger.fatal("queryRunLevel 2 null current_run_level");
4407
            // show stopper
868 mhunt 4408
            throw new Exception("queryRunLevel 2 null current_run_level");
814 mhunt 4409
          }
4410
 
4411
          RunLevel runLevel = new RunLevel(rcon_id, "", current_run_level, false);
4412
          mRunLevelCollection.add(runLevel);
4413
        }
4414
 
4415
        if ( rsetSize == 0 )
4416
        {
4417
          mLogger.fatal("queryRunLevel 2 rsetSize == 0");
4418
          // show stopper
868 mhunt 4419
          throw new Exception("queryRunLevel 2 rsetSize == 0");
814 mhunt 4420
        }
4421
 
830 mhunt 4422
        rset.close();
4423
        stmt.close();
814 mhunt 4424
        disconnect();
4425
      }
4426
      catch ( SQLException e )
4427
      {
4428
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4429
        {
4430
          mLogger.error("queryRunLevel 2 database access error only");
4431
          throw new SQLException();
4432
        }
4433
        else
4434
        {
4435
          mLogger.fatal("queryRunLevel 2 show stopper");
868 mhunt 4436
          throw new Exception("queryRunLevel 2 show stopper");
814 mhunt 4437
        }
4438
      }
4439
 
4440
 
4441
    }
4442
  }
4443
 
818 mhunt 4444
  /**removes all elements from the mRunLevelCollection
4445
   * handles database connection and disconnection
4446
   *   select rcon_id, current_run_level from run_level
4447
   *   where rcon_id=<rcon_id>;
4448
   * populates the mRunLevelCollection with the query result set
4449
   */
4450
  public void querySingleRunLevel(final int rcon_id) throws SQLException, Exception
4451
  {
4452
    mLogger.debug("querySingleRunLevel rcon_id " + rcon_id);
4453
    if ( !mUseDatabase )
4454
    {
4455
      mLogger.info("querySingleRunLevel !mUseDatabase");
4456
 
4457
      mRunLevelCollection.removeAllElements();
4458
      RunLevel runLevel = new RunLevel(rcon_id, "", DB_ACTIVE, false);
4459
      mRunLevelCollection.add(runLevel);
4460
    }
4461
    else
4462
    {
4463
      mRunLevelCollection.removeAllElements();
4464
 
4465
      try
4466
      {
4467
        connect();
4468
        CallableStatement stmt = mConnection.prepareCall(
4469
        "select rcon_id, current_run_level from run_level " +
4470
        "where rcon_id=" +rcon_id);
4471
        ResultSet rset = stmt.executeQuery();
4472
        int rsetSize = 0;
4473
        int current_run_level = 0;
4474
 
4475
        while( rset.next() )
4476
        {
4477
          rsetSize++;
4478
          current_run_level = rset.getInt("current_run_level");
4479
 
4480
          if ( rset.wasNull() )
4481
          {
4482
            mLogger.fatal("querySingleRunLevel null current_run_level");
4483
            // show stopper
868 mhunt 4484
            throw new Exception("querySingleRunLevel null current_run_level");
818 mhunt 4485
          }
4486
 
4487
          RunLevel runLevel = new RunLevel(rcon_id, "", current_run_level, false);
4488
          mRunLevelCollection.add(runLevel);
4489
        }
4490
 
4491
        if ( rsetSize != 1 )
4492
        {
4493
          mLogger.fatal("querySingleRunLevel rsetSize != 1");
4494
          // show stopper
868 mhunt 4495
          throw new Exception("querySingleRunLevel rsetSize != 1");
818 mhunt 4496
        }
4497
 
830 mhunt 4498
        rset.close();
4499
        stmt.close();
818 mhunt 4500
        disconnect();
4501
      }
4502
      catch ( SQLException e )
4503
      {
4504
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4505
        {
4506
          mLogger.error("querySingleRunLevel database access error only");
4507
          throw new SQLException();
4508
        }
4509
        else
4510
        {
4511
          mLogger.fatal("querySingleRunLevel show stopper");
868 mhunt 4512
          throw new Exception("querySingleRunLevel show stopper");
818 mhunt 4513
        }
4514
      }
4515
    }
4516
  }
4517
 
814 mhunt 4518
  /**queries the RUN_LEVEL_SCHEDULE table
4519
   * returns false if a row in the query result set indicates build service downtime is scheduled
4520
   * returns false if a row in the query result set has a non NULL indefinite_pause
4521
   * refer to the sequence diagram allowed to proceed
4522
   */
4523
  public boolean queryRunLevelSchedule(Date resumeTime) throws SQLException, Exception
4524
  {
4525
    mLogger.debug("queryRunLevelSchedule");
4526
    boolean retVal = true;
4527
 
4528
    if ( !mUseDatabase )
4529
    {
4530
      mLogger.info("queryRunLevelSchedule !mUseDatabase");
4531
 
4532
      if ( mConnectionString.compareTo("unit test not allowed to proceed") == 0 )
4533
      {
4534
        // schedule a 100ms max wait
4535
        resumeTime.setTime( resumeTime.getTime() + 100 );
4536
        retVal = false;
4537
      }
4538
    }
4539
    else
4540
    {
4541
      try
4542
      {
4543
        CallableStatement stmt = mConnection.prepareCall("select scheduled_pause, scheduled_resume, repeat, indefinite_pause from release_manager.run_level_schedule");
4544
        ResultSet rset = stmt.executeQuery();
4545
        Date now = new Date();
844 dpurdie 4546
 
4547
 
4548
        //
846 dpurdie 4549
        //  Scan the database information and determine if there is any reason
844 dpurdie 4550
        //  to pause. Terminate the loop on the first excuse to pause
4551
        //  as indefinite pause may have multiple (lots) of entries in the data
4552
        //  base.
4553
        //
4554
        while( retVal == true && rset.next() )
814 mhunt 4555
        {
846 dpurdie 4556
          //
4557
          //  Examine the current row from the data base
4558
          //  Expect one of two forms:
4559
          //    1) scheduled_pause
4560
          //       Must also have a scheduled_resume and a repeat
4561
          //    2) indefinite_pause
4562
          //
4563
 
4564
          //  Look for scheduled_pause style of entry
4565
          //
814 mhunt 4566
          Timestamp sp = rset.getTimestamp("scheduled_pause");
4567
          if ( sp != null )
4568
          {
4569
            Date scheduled_pause = new Date( sp.getTime() );
4570
            Timestamp sr = rset.getTimestamp("scheduled_resume");
4571
 
4572
            if ( sr != null )
4573
            {
4574
              Date scheduled_resume = new Date( sr.getTime() );
4575
              int repeat = rset.getInt("repeat");
4576
              mLogger.info("queryRunLevelSchedule repeat " + repeat);
846 dpurdie 4577
 
4578
              //
4579
              //  Have scheduled_pause and scheduled_resume
4580
              //  Examine the repeat field and determine how these are used
4581
              //  Supported repeat:
4582
              //      Once Only
4583
              //      Daily           Year, Month and Day information is ignored
4584
              //      Weekly          Only day of week is utilised
4585
              //
814 mhunt 4586
              if ( !rset.wasNull() )
4587
              {
4588
                switch( repeat )
4589
                {
4590
                  case 0:
4591
                  {
4592
                    // one off
4593
                    if ( scheduled_pause.before(now) && scheduled_resume.after(now) )
4594
                    {
4595
                      mLogger.warn("queryRunLevelSchedule one off scheduled downtime");
838 mhunt 4596
                      resumeTime = scheduled_resume;
814 mhunt 4597
                      retVal = false;
4598
                    }
4599
                    break;
4600
                  }
4601
                  case 1:
4602
                  {
846 dpurdie 4603
                    //  daily
4604
                    //  Create start and end fimes, then massage some fields
4605
                    //  to reflect todays date
4606
                    //
814 mhunt 4607
                    GregorianCalendar startOfDowntime = new GregorianCalendar();
4608
                    startOfDowntime.setTime(scheduled_pause);
4609
                    GregorianCalendar endOfDowntime = new GregorianCalendar();
4610
                    endOfDowntime.setTime(scheduled_resume);
4611
                    GregorianCalendar clock = new GregorianCalendar();
4612
                    clock.setTime(now);
846 dpurdie 4613
 
4614
                    // Force date fields to todays date
4615
                    endOfDowntime.set  ( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4616
                    startOfDowntime.set( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4617
 
814 mhunt 4618
                    if ( startOfDowntime.before(clock) && endOfDowntime.after(clock) )
4619
                    {
4620
                      mLogger.warn("queryRunLevelSchedule daily scheduled downtime");
838 mhunt 4621
                      resumeTime.setTime(endOfDowntime.getTimeInMillis());
814 mhunt 4622
                      retVal = false;
4623
                    }
4624
                    break;
4625
                  }
4626
                  case 7:
4627
                  {
4628
                    // weekly
846 dpurdie 4629
                    // Create start and end times, then massage some fields
4630
                    // to reflect todays date
4631
                    //
814 mhunt 4632
                    GregorianCalendar startOfDowntime = new GregorianCalendar();
4633
                    startOfDowntime.setTime(scheduled_pause);
4634
                    GregorianCalendar endOfDowntime = new GregorianCalendar();
4635
                    endOfDowntime.setTime(scheduled_resume);
4636
                    GregorianCalendar clock = new GregorianCalendar();
4637
                    clock.setTime(now);
846 dpurdie 4638
 
4639
                    // Only interested in one day of the week
814 mhunt 4640
                    if ( startOfDowntime.get(Calendar.DAY_OF_WEEK) == clock.get(Calendar.DAY_OF_WEEK) )
4641
                    {
846 dpurdie 4642
                      endOfDowntime.set  ( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
4643
                      startOfDowntime.set( clock.get(Calendar.YEAR), clock.get(Calendar.MONTH), clock.get(Calendar.DAY_OF_MONTH) );
814 mhunt 4644
 
4645
                      if ( startOfDowntime.before(clock) && endOfDowntime.after(clock) )
4646
                      {
4647
                        mLogger.warn("queryRunLevelSchedule weekly scheduled downtime");
838 mhunt 4648
                        resumeTime.setTime(endOfDowntime.getTimeInMillis());
814 mhunt 4649
                        retVal = false;
4650
                      }
4651
                    }
4652
                    break;
4653
                  }
4654
                }
4655
              }
4656
            }
4657
          }
4658
 
846 dpurdie 4659
          //
4660
          //  Look for indefinite_pause style of entry
4661
          //  Note: due to an implemenation error there may be many
4662
          //        rows that match. We only need one. The scan will
4663
          //        be termineted if we find any
4664
          //  
4665
          //
836 mhunt 4666
          String ip = rset.getString("indefinite_pause");
4667
          if ( ip != null )
814 mhunt 4668
          {
4669
            // indefinite pause is non null
4670
            mLogger.warn("queryRunLevelSchedule indefinite pause");
838 mhunt 4671
            GregorianCalendar clock = new GregorianCalendar();
4672
            clock.setTime(now);
4673
            // wait a minute
4674
            resumeTime.setTime(clock.getTimeInMillis() + 60000);
814 mhunt 4675
            retVal = false;
4676
          }
4677
        }
830 mhunt 4678
 
4679
        rset.close();
4680
        stmt.close();
814 mhunt 4681
      }
4682
      catch ( SQLException e )
4683
      {
4684
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4685
        {
4686
          mLogger.error("queryRunLevelSchedule database access error only");
4687
          throw new SQLException();
4688
        }
4689
        else
4690
        {
4691
          mLogger.fatal("queryRunLevelSchedule show stopper");
868 mhunt 4692
          throw new Exception("queryRunLevelSchedule show stopper");
814 mhunt 4693
        }
4694
      }
4695
    }
4696
 
4697
    mLogger.info("queryRunLevelSchedule returning " + retVal);
4698
    return retVal;
4699
  }
4700
 
4701
  /**persists the runLevel in the RUN_LEVEL table for the rcon_id primary key
4702
   * refer to sequence diagrams generate build files, allowed to proceed, not allowed to proceed, exit, check environment
4703
   */
4704
  public void updateCurrentRunLevel(final int rcon_id, final int runLevel) throws SQLException, Exception
4705
  {
4706
    mLogger.debug("updateCurrentRunLevel");
4707
    if ( !mUseDatabase )
4708
    {
4709
      mLogger.info("updateCurrentRunLevel !mUseDatabase");
4710
      Integer i = new Integer(runLevel);
4711
      mPersistedRunLevelCollection.add(i);
4712
    }
4713
    else
4714
    {
4715
      try
4716
      {
4717
        connect();
4718
        boolean update = false;
4719
        {
4720
          // check if the rcon_id exists in the table
4721
          CallableStatement stmt = mConnection.prepareCall("select rcon_id from release_manager.run_level where rcon_id=" + rcon_id);
4722
          ResultSet rset = stmt.executeQuery();
4723
 
4724
          while( rset.next() )
4725
          {
4726
            update = true;
4727
          }
830 mhunt 4728
 
4729
          rset.close();
4730
          stmt.close();
814 mhunt 4731
        }
4732
 
4733
        if ( !update )
4734
        {
4735
          // check if the rcon_id is still configured
4736
          boolean configured = false;
4737
          {
4738
            CallableStatement stmt = mConnection.prepareCall("select rcon_id from release_manager.release_config where rcon_id=" + rcon_id);
4739
            ResultSet rset = stmt.executeQuery();
4740
 
4741
            while( rset.next() )
4742
            {
4743
              configured = true;
4744
            }
830 mhunt 4745
 
4746
            rset.close();
4747
            stmt.close();
814 mhunt 4748
          }
864 mhunt 4749
 
4750
          if (configured)
4751
          {
4752
            CallableStatement stmt = mConnection.prepareCall("insert into release_manager.run_level (rcon_id) values (" + rcon_id + ")" );
4753
            stmt.executeUpdate();
4754
            stmt.close();
4755
          }
814 mhunt 4756
        }
4757
 
4758
        {
4759
          CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + " where rcon_id=" + rcon_id);
4760
          stmt.executeUpdate();
830 mhunt 4761
          stmt.close();
814 mhunt 4762
        }
4763
        mConnection.commit();
4764
        disconnect();
4765
      }
4766
      catch( SQLException e )
4767
      {
4768
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4769
        {
868 mhunt 4770
          mLogger.fatal("updateCurrentRunLevel database access error only");
4771
          throw new Exception("updateCurrentRunLevel database access error only");
814 mhunt 4772
        }
4773
        else
4774
        {
4775
          mLogger.fatal("updateCurrentRunLevel show stopper");
868 mhunt 4776
          throw new Exception("updateCurrentRunLevel show stopper");
814 mhunt 4777
        }
4778
      }
4779
    }
4780
  }
4781
 
866 mhunt 4782
  public void queryBuildExclusions(Vector<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
4783
  {
4784
    mLogger.debug("queryBuildExclusions " + baseline);
4785
 
4786
    if ( !mUseDatabase )
4787
    {
4788
      mLogger.info("queryBuildExclusions !mUseDatabase");
4789
    }
4790
    else
4791
    {
4792
      try
4793
      {
4794
        CallableStatement stmt = mConnection.prepareCall("select pv_id, root_pv_id, root_cause from release_manager.do_not_ripple where rtag_id=" + baseline);
4795
        ResultSet rset = stmt.executeQuery();
4796
 
4797
        while( rset.next() )
4798
        {
4799
          int pvId = rset.getInt("pv_id");
4800
 
4801
          if ( rset.wasNull() )
4802
          {
4803
            mLogger.fatal("queryBuildExclusions rset null pv_id");
4804
            // show stopper
868 mhunt 4805
            throw new Exception("queryBuildExclusions rset null pv_id");
866 mhunt 4806
          }
4807
 
4808
          int rootPvId = rset.getInt("root_pv_id");
4809
 
4810
          if ( rset.wasNull() )
4811
          {
4812
            // quite acceptable
4813
            rootPvId = -1;
4814
          }
4815
 
4816
          // again, a null root_cause is quite acceptable
4817
          String rootCause = rset.getString("root_cause");
4818
 
4819
          BuildExclusion buildExclusion = new BuildExclusion(pvId, rootPvId, rootCause);
4820
          buildExclusionCollection.add(buildExclusion);
4821
        }
4822
 
4823
        rset.close();
4824
        stmt.close();
4825
      }
4826
      catch ( SQLException e )
4827
      {
4828
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4829
        {
4830
          mLogger.error("queryBuildExclusions database access error only");
4831
          throw new SQLException();
4832
        }
4833
        else
4834
        {
4835
          mLogger.fatal("queryBuildExclusions show stopper");
868 mhunt 4836
          throw new Exception("queryBuildExclusions show stopper");
866 mhunt 4837
        }
4838
      }
4839
    }
4840
  }
814 mhunt 4841
}