Subversion Repositories DevTools

Rev

Rev 5357 | Rev 5898 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
123 ghuddy 1
<%
2
'=====================================================
3
'               COMMON MAKE RELEASE BUTTON SUBs
4
'=====================================================
5
'
6
' Conventions within this code
7
'
8
'   1) Where a paramter list contains both RTAG_ID and PV_ID, the RTAG_ID will precede the PV_ID parameter
9
'   2) Functions/Subs that are not used externally, are name decorated PRIVATE_
10
'   3) Functions/Subs that are used extennally, are name decorated PUBLIC_
11
'
12
'
13
'
14
%>
165 brianf 15
<!--#include file="release_changed.asp"-->
123 ghuddy 16
<%
17
Dim AutoBuildPermissionDenied
18
Dim ManualBuildPermissionDenied
129 ghuddy 19
Dim RaiseWIPExists
123 ghuddy 20
 
21
AutoBuildPermissionDenied   = FALSE
22
ManualBuildPermissionDenied = FALSE
23
 
24
 
25
'-----------------------------------------------------------------------------------------------------------------------------
26
' This is the pattern for approval determination. If the release is in open mode, permission is given. If the release is
27
' in restrictive/ccb mode, permission is given dependent on the accessControlObjectName being granted for the user.
28
'
29
Function PRIVATE_Is_Allowed_To(NNrtag_id, accessControlObjectName)
30
   Dim ReleaseMode
31
 
32
   ReleaseMode = GetReleaseMode ( NNrtag_id )
33
 
34
   PRIVATE_Is_Allowed_To = FALSE
35
 
5178 dpurdie 36
   If NOT releaseIsClosed(ReleaseMode) Then
123 ghuddy 37
      If ( ReleaseMode = enumDB_RELEASE_IN_OPEN_MODE ) Then
38
         PRIVATE_Is_Allowed_To = TRUE
39
      Else
5061 dpurdie 40
         If canActionControlInProject(accessControlObjectName) Then
123 ghuddy 41
            PRIVATE_Is_Allowed_To = TRUE
42
         End If
43
      End If
44
   End If
45
End Function
46
'-----------------------------------------------------------------------------------------------------------------------------
47
Function PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id)
48
 
49
   PRIVATE_Is_Allowed_To_Approve_Merge = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForAutoBuild") _
50
                                      OR PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForManualBuild")
51
End Function
52
'----------------------------------------------------------------------------------------------------------------------------------------
53
Function PRIVATE_Is_Allowed_To_Approve_ManualBuild(NNrtag_id)
54
 
55
   PRIVATE_Is_Allowed_To_Approve_ManualBuild = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForManualBuild")
56
End Function
57
'----------------------------------------------------------------------------------------------------------------------------------------
58
Function PRIVATE_Is_Allowed_To_Approve_AutoBuild(NNrtag_id)
59
 
60
   PRIVATE_Is_Allowed_To_Approve_AutoBuild = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForAutoBuild")
61
End Function
62
 
63
 
64
'=============================================================================================================================
65
' APPROVING PENDING MERGE OPERATIONS - Used from _approve_merge.asp as well as from within this file itself
66
'
67
' All functions in this section originally came from _approve_merge.asp and were placed here to support their use in more
68
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
69
'=============================================================================================================================
70
 
71
'-----------------------------------------------------------------------------------------------------------------------------
72
' USED to approve a pending merge operation. Used internally by the bulk release operation
165 brianf 73
Sub PRIVATE_ApproveMerge ( NNrtag_id, NNpv_id, op)
123 ghuddy 74
   On Error Resume Next
75
   objEH.ErrorRedirect = TRUE
76
 
77
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
78
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,  ORAPARM_INPUT, ORATYPE_NUMBER
79
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId,   ORAPARM_INPUT, ORATYPE_NUMBER
80
 
81
   objEH.TryORA ( OraSession )
82
 
83
   OraDatabase.ExecuteSQL _
84
      "BEGIN "&_
85
      " PK_ENVIRONMENT.APPROVE_MERGE ( :PV_ID, :RTAG_ID, :USER_ID );"&_
86
      "END; "
87
 
88
   objEH.CatchORA ( OraSession )
89
 
90
   OraDatabase.Parameters.Remove "PV_ID"
91
   OraDatabase.Parameters.Remove "RTAG_ID"
92
   OraDatabase.Parameters.Remove "USER_ID"
165 brianf 93
 
94
   If Not objEH.LastOraFailed Then
95
      Dim objRC: Set objRC = New ReleaseChanged
96
      Dim mode
97
      If op = "A" Then
98
        mode = enumRELEASE_CHANGE_MODE_PKG_ADDED
99
      ElseIf op = "S" Then
100
        mode = enumRELEASE_CHANGE_MODE_PKG_REMOVED
101
      End If
102
      Call objRC.Run_ReleaseChanged(NNrtag_id,NNpv_id,mode,true)
103
      Set objRC = Nothing
104
   End If
105
 
123 ghuddy 106
End Sub
107
 
108
'-----------------------------------------------------------------------------------------------------------------------------
109
' USED to approve a pending merge operation. Used externally from the _approve_merge.asp file, loaded when the btnApproveMerge
110
' action button is pressed.
111
Sub PUBLIC_ApproveMerge ( NNrtag_id, NNpv_id )
165 brianf 112
   Dim op: op = ""
113
   If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, "A") Then
114
     op = "A"
115
   ElseIf PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, "S") Then
116
     op = "S"
117
   End If 
118
 
123 ghuddy 119
   ' validate before carrying out the merge
165 brianf 120
   If op <> "" Then
123 ghuddy 121
      If PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id) Then
165 brianf 122
         Call PRIVATE_ApproveMerge(parRtag_id, NNpv_id, op)
123 ghuddy 123
      End If
124
   End If
125
End Sub
126
 
127
'-----------------------------------------------------------------------------------------------------------------------------
128
' USED to validate an attempt to approve a pending merge operation
129
Function PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, op)
130
   Dim rsQry
131
 
132
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
133
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id, ORAPARM_INPUT, ORATYPE_NUMBER
134
 
135
   Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("PlannedPackageVersionDetails.sql"), cint(0))
136
 
137
   If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
138
      ' Does the actual operation field in the database match that specified as a parameter?
139
      If (rsQry.Fields("operation") = op) Then
140
         PRIVATE_Is_A_Valid_Pending_Merge = TRUE
141
		Else
142
         PRIVATE_Is_A_Valid_Pending_Merge = FALSE
143
		End If
144
   Else
145
      PRIVATE_Is_A_Valid_Pending_Merge = FALSE
146
   End If
147
 
148
   OraDatabase.Parameters.Remove "PV_ID"
149
   OraDatabase.Parameters.Remove "RTAG_ID"
150
 
151
   rsQry.Close()
152
   Set rsQry = Nothing
153
End Function
154
 
155
 
156
'=============================================================================================================================
157
' APPROVING MANUAL BUILD PENDING VERSIONS - Used from _make_released.asp as well as from within this file itself
158
'
159
' All functions in this section originally came from _make_released.asp and were placed here to support their use in more
160
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
161
'=============================================================================================================================
162
 
163
 
164
'----------------------------------------------------------------------------------------------------------------------------------------
165
' This function came from _make_released.asp and is very similar to the PRIVATE_NotifyInterestAutoBuild, except the subject/body
166
' text is different. Unlike its auto-build counterpart, this one is called during the process of making a manual build release
167
' official.
168
' One question arises... can we not harmonize the email notification code somewhat, between manual and autobuild releases?
169
'
5097 dpurdie 170
' Currently, the function is called internally as part of the bulk release operation,
123 ghuddy 171
' loaded by _make_released.asp which in turn is loaded when a user presses the btnMakeReleased action button for manual
172
' built pending versions.
173
Sub PUBLIC_NotifyInterestManualBuild( NNrtag_id, NNpv_id )
174
   Err.Clear
175
   On Error Resume Next
3959 dpurdie 176
   Dim Query_String, rsQry
123 ghuddy 177
 
178
   Query_String = _
179
   "   SELECT * FROM PACKAGE_INTEREST PI, PACKAGES PKG, PACKAGE_VERSIONS PV, USERS U,"&_
180
   "   RELEASE_TAGS RT, PROJECTS PRJ WHERE PKG.PKG_ID = PI.PKG_ID AND "&_
181
   "   RT.RTAG_ID = "& NNrtag_id &""&_
182
   "   AND PV.PV_ID = "& NNpv_id &" AND PV.PKG_ID = PKG.PKG_ID AND "&_
183
   "   PRJ.PROJ_ID = RT.PROJ_ID AND PRJ.PROJ_ID = PI.PROJ_ID AND U.USER_ID = PI.USER_ID"
184
 
185
   Set rsQry = OraDatabase.DbCreateDynaset( Query_String , cint(0) )
186
 
187
   If rsQry.RecordCount <> "" Then
188
      While ((NOT rsQry.BOF) AND (NOT rsQry.EOF))
125 ghuddy 189
         If rsQry("user_email") <> "" Then
3959 dpurdie 190
            Send_Email  "Release Manager Notification",_
5357 dpurdie 191
                        ADMIN_EMAIL, _
3959 dpurdie 192
                        rsQry("user_email"),_
193
                        "Version "& rsQry("pkg_version") &" of Package "& rsQry("pkg_name") &" in Project " & rsQry("proj_name") &" on Release Branch " & rsQry("rtag_name") &" has been released.",_
194
                        "You have received this email as a result of your interest in this package. If you do not wish to receive further emails then remove your package interest from the notifications area in Release Manager.",_
195
                        NULL
123 ghuddy 196
         End If
197
         rsQry.MoveNext
198
      Wend
199
 
200
   End If
201
 
202
   rsQry.Close()
203
   set rsQry = nothing
204
End Sub
205
 
206
'----------------------------------------------------------------------------------------------------------------------------------------
5097 dpurdie 207
' Currently, this function is called internally as part of the bulk release operation,
123 ghuddy 208
' loaded by _make_released.asp which in turn is loaded when a user presses the btnMakeReleased action button for manual
209
' built pending versions. It initiates the execution of the windows script file that performs additional database updates
210
' that are needed to make official a package version that has already been built and published into dpkg_archive. This includes
211
' collecting info on all files that were published to dpkg_archive, and inserting that info into the RELEASED_COMPONENTS table.
129 ghuddy 212
Function PUBLIC_Run_onMakeOfficial ( nRtag_id, nPv_id )
123 ghuddy 213
 
214
   Dim objWSH, proj_id, Qry, sRtagName
215
 
129 ghuddy 216
   PUBLIC_Run_onMakeOfficial = FALSE
217
 
218
   On Error Resume Next
219
 
220
   objEH.TryORA ( OraSession )
221
 
123 ghuddy 222
   OraDatabase.ExecuteSQL " UPDATE package_versions "&_
223
                          " SET release_notes_info = '"& enum_RELEASE_NOTES_GENERATING &"'"&_
224
                          " WHERE pv_id = "& nPv_id
225
 
129 ghuddy 226
   objEH.CatchORA ( OraSession )
123 ghuddy 227
 
129 ghuddy 228
   If objEH.LastOraFailed = FALSE Then
229
      PUBLIC_Run_onMakeOfficial = TRUE
230
   End If
231
 
232
End Function
123 ghuddy 233
'-----------------------------------------------------------------------------------------------------------------------------
234
' This sub is used from _make_released.asp, loaded when a user presses the btnMakeReleased action button, as well as from
235
' internally within this file as part of the bulk release operation.
236
' This function basically removes the PV_ID entry from the WIP/PLANNED table, and adds it to the RELEASE_CONTENT table.
129 ghuddy 237
Function PUBLIC_MakeRelease ( NNrtag_id, NNpv_id  )
123 ghuddy 238
 
239
   On Error Resume Next
240
   objEH.ErrorRedirect = TRUE
241
 
242
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
243
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
244
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
245
 
246
   objEH.TryORA ( OraSession )
247
 
248
   OraDatabase.ExecuteSQL _
249
     "BEGIN "&_
250
     " PK_ENVIRONMENT.MAKE_RELEASE ( :PV_ID, :RTAG_ID, :USER_ID );"&_
251
     "END; "
252
 
253
   objEH.CatchORA ( OraSession )
254
 
255
   OraDatabase.Parameters.Remove "PV_ID"
256
   OraDatabase.Parameters.Remove "RTAG_ID"
257
   OraDatabase.Parameters.Remove "USER_ID"
258
 
129 ghuddy 259
   ' return TRUE if operation was successful, else FALSE
260
   If objEH.LastOraFailed Then
261
      PUBLIC_MakeRelease = FALSE
262
   Else
263
      PUBLIC_MakeRelease = TRUE
165 brianf 264
      Dim objRC: Set objRC = New ReleaseChanged
265
      Call objRC.Run_ReleaseChanged(NNrtag_id,NNpv_id,enumRELEASE_CHANGE_MODE_PKG_RELEASED,true)
266
      Set objRC = Nothing
129 ghuddy 267
   End If
123 ghuddy 268
 
129 ghuddy 269
End Function
270
 
271
 
123 ghuddy 272
'=============================================================================================================================
273
' APPROVING AUTO/MANUAL BUILD PENDING VERSIONS - Used from _make_approved.asp as well as from within this file itself
274
'
275
' All functions in this section originally came from _make_approved.asp and were placed here to support their use in more
276
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
277
'=============================================================================================================================
278
 
279
'------------------------------------------------------------------------------------------------------------------------------------------
280
' Currently, this function does not seem to be used. The call to it was commented out in the _make_approved.asp file from where it was
281
' originally called from.
282
'
283
Sub PRIVATE_NotifyInterestAutoBuild( NNrtag_id, NNpv_id )
284
   On Error Resume Next
3959 dpurdie 285
   Dim Query_String, rsQry
123 ghuddy 286
 
287
   Query_String = _
288
   "   SELECT * FROM PACKAGE_INTEREST PI, PACKAGES PKG, PACKAGE_VERSIONS PV, USERS U,"&_
289
   "   RELEASE_TAGS RT, PROJECTS PRJ WHERE PKG.PKG_ID = PI.PKG_ID AND "&_
290
   "   RT.RTAG_ID = "& NNrtag_id &""&_
291
   "   AND PV.PV_ID = "& NNpv_id &" AND PV.PKG_ID = PKG.PKG_ID AND "&_
292
   "   PRJ.PROJ_ID = RT.PROJ_ID AND PRJ.PROJ_ID = PI.PROJ_ID AND U.USER_ID = PI.USER_ID"
293
 
294
   Set rsQry = OraDatabase.DbCreateDynaset( Query_String , cint(0) )
295
 
296
   If rsQry.RecordCount <> "" Then
297
      While ((NOT rsQry.BOF) AND (NOT rsQry.EOF))
125 ghuddy 298
         If rsQry("user_email") <> "" Then
3959 dpurdie 299
            Send_Email  "Release Manager Notification",_
5357 dpurdie 300
                        ADMIN_EMAIL, _
3959 dpurdie 301
                        rsQry("user_email"),_
302
                        "New Version of Package "& rsQry("pkg_name") &" in Project " & rsQry("proj_name") &" on Release Branch " & rsQry("rtag_name") &" would be autobuild soon.",_
303
                        "You have received this email as a result of your interest in this package. If you do not wish to receive further emails then remove your package interest from the notifications area in Release Manager.",_
304
                        NULL
125 ghuddy 305
         End If
123 ghuddy 306
         rsQry.MoveNext
307
      Wend
308
   End If
309
 
310
   rsQry.Close()
311
   set rsQry = nothing
312
End Sub
313
'-------------------------------------------------------------------------------------
314
Sub PRIVATE_Get_Package_Issues(NNpv_id, SSsql)
3975 dpurdie 315
   Dim sqlstr, rsTemp, DEVIiss
123 ghuddy 316
 
317
   sqlstr = "SELECT iss_db, iss_id, iss_state, notes FROM CQ_ISSUES WHERE pv_id="& NNpv_id &"  AND iss_state = 1"
318
 
319
   Set rsTemp = OraDatabase.DbCreateDynaset( sqlstr, cint(0))
320
 
321
   DEVIiss = "-1"
322
 
323
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
324
      If CInt(rsTemp("iss_db")) = CInt(enumCLEARQUEST_DEVI_ID) Then
325
         DEVIiss = DEVIiss &","& rsTemp("iss_id")
326
      End If
327
 
328
      rsTemp.MoveNext
329
   WEnd
330
 
331
   ' Construct SQL statement for CQ database
332
   If Len(DEVIiss) <> 1 OR Len(TDSEiss) <> 1 Then
333
      SSsql = ReadFile( rootPath & "queries\cq_issues.sql" )
334
      SSsql = Replace( SSsql, "/*enumCLEARQUEST_DEVI_ID*/", enumCLEARQUEST_DEVI_ID)
335
      SSsql = Replace( SSsql, "/*DEVIiss*/", DEVIiss)
336
   End If
337
 
338
   rsTemp.Close
339
   Set rsTemp = nothing
340
 
341
End Sub
342
'-------------------------------------------------------------------------------------
129 ghuddy 343
Function PRIVATE_MakeApproved (NNrtag_id, NNpv_id)
123 ghuddy 344
 
345
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
346
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
347
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
348
 
129 ghuddy 349
   objEH.TryORA ( OraSession )
350
   On Error Resume Next
123 ghuddy 351
 
352
   OraDatabase.ExecuteSQL _
353
   "BEGIN "&_
354
   "   PK_ENVIRONMENT.MAKE_APPROVED ( :PV_ID, :RTAG_ID, :USER_ID ); "&_
355
   "END; "
356
 
129 ghuddy 357
   objEH.CatchORA ( OraSession )
123 ghuddy 358
 
359
   OraDatabase.Parameters.Remove "PV_ID"
360
   OraDatabase.Parameters.Remove "RTAG_ID"
361
   OraDatabase.Parameters.Remove "USER_ID"
362
 
129 ghuddy 363
   ' return TRUE if operation was successful, else FALSE
364
   If objEH.LastOraFailed Then
365
      PRIVATE_MakeApproved = FALSE
366
   Else
367
      PRIVATE_MakeApproved = TRUE
368
   End If
123 ghuddy 369
 
370
End Function
371
'-------------------------------------------------------------------------------------
372
' This function is called from _make_approved.asp, which is loaded when the btnApprovePackage
373
' action button is pressed. It is also called as part of the bulk release operation.
129 ghuddy 374
Function PUBLIC_ApproveRelease(NNrtag_id, NNpv_id, ByRef retParameters, isBulk)
123 ghuddy 375
 
376
   Dim retERRmsg
377
   Dim retALRTmsg
378
   Dim pkgType
379
 
380
   retParameters = ""
381
   pkgType = 0
382
 
383
   Set pkgInfoHash = CreateObject("Scripting.Dictionary")
384
 
385
   ' default return value
386
   PUBLIC_ApproveRelease = FALSE
387
 
388
   If ( NNrtag_id <> "") AND (NNpv_id <> "") Then
389
 
5146 dpurdie 390
     ' -- Check not about to replace an SDK
391
 
392
 
129 ghuddy 393
     '-- Get Package details
394
     Call Get_Pkg_Info ( NNpv_id, NNrtag_id )
123 ghuddy 395
 
4758 dpurdie 396
     ' Only process the package if it is still pending approval
397
     ' If the package has already been released, then we don't want to mark it as ready to build- again
398
     If pkgInfoHash.Item("dlocked") = "P" Then
123 ghuddy 399
 
4758 dpurdie 400
         If pkgInfoHash.Item("build_type") = "A" Then
401
            'Check If There Already Exists A WIP Instance Of The Package In The Release
402
            If Check_Package_WIP_Already_Exists(NNrtag_id, NNpv_id) > 0 Then
403
              RaiseWIPExists = TRUE
404
            End If
123 ghuddy 405
 
4758 dpurdie 406
            If PRIVATE_Is_Allowed_To_Approve_AutoBuild(NNrtag_id) Then
407
               '-- Approve Automatic-build package
408
               Call CheckRequirementsForMakeApproved ( NNpv_id, NNrtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
409
               If IsNull(retERRmsg) Then
410
                  If PRIVATE_MakeApproved (NNrtag_id, NNpv_id) = TRUE Then
123 ghuddy 411
 
4758 dpurdie 412
                      If ( RaiseWIPExists = TRUE ) AND ( isBulk = FALSE ) Then
413
                         Call RaiseMsg ( enum_MSG_PACKAGE_WIP_EXISTS&"?rtag_id="& NNrtag_id & "&pv_id="& NNpv_id & "", NNpv_id )
414
                         ' RaiseMsg redirects loaded web page, so no return
415
                         ' Deal with BulkMakeRelease elsewhere
416
                      End If
417
                      ' indicate success
418
                      PUBLIC_ApproveRelease = TRUE
129 ghuddy 419
                  End If
4758 dpurdie 420
               Else
421
                  Call RaiseMsg ( Eval(retERRmsg), NNrtag_id & "|" & NNpv_id & "|" & retParameters & "|" & "N" )
422
               End If
423
            Else
424
               ' Indicate an auto-build permission problem was detected in the global variable.
425
               ' This is only used within the context of a bulk release.
426
               AutoBuildPermissionDenied = TRUE
427
            End If
428
         Else
429
            If PRIVATE_Is_Allowed_To_Approve_ManualBuild(NNrtag_id) Then
430
               '-- Approve a Manual Build Release
431
               Call CheckRequirementsForMakeRelease ( NNpv_id, NNrtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
432
               If IsNull(retERRmsg) Then
123 ghuddy 433
 
4758 dpurdie 434
                  If PUBLIC_MakeRelease ( NNrtag_id, NNpv_id ) = TRUE Then
435
                  ' If all went well, initiate the generation of release notes, and email any interested parties
436
                     If PUBLIC_Run_onMakeOfficial ( NNrtag_id, NNpv_id ) = TRUE Then
437
                        Call PUBLIC_NotifyInterestManualBuild( NNrtag_id, NNpv_id )
123 ghuddy 438
 
4758 dpurdie 439
                        ' indicate success
440
                        PUBLIC_ApproveRelease = TRUE
441
                     End If
442
                  End If
443
               Else
444
                  Call RaiseMsg ( Eval(retERRmsg), NNrtag_id & "|" & NNpv_id & "|" & retParameters & "|" & "N" )
445
               End If
446
            Else
447
               ' Indicate a manual-build permission problem was detected in the global variable
448
               ' This is only used within the context of a bulk release.
449
               ManualBuildPermissionDenied = TRUE
450
            End If
451
         End If
452
 
453
       Else
454
         ' Package not in a state to be approved for building
455
         '
456
         PUBLIC_ApproveRelease = TRUE
457
       End If
123 ghuddy 458
   End If
459
End Function
460
'-----------------------------------------------------------------------------------------------------------------------------
461
 
462
 
463
'=============================================================================================================================
464
' MAKING A BULK RELEASE from a list of PV_IDs for a specified release
465
'
466
' This section contains the new "Bulk Release' code. This function is tied to the use of the make bulk release button.
467
'
468
'=============================================================================================================================
469
 
470
'-----------------------------------------------------------------------------------------------------------------------------
471
' This public function is called from the make_bulk_release.asp file, loaded when a user presses the Make Bulk Release
472
' button when viewing items on the Pending Tab of a release area.
473
'
474
' The function processes a list of PV_ID's that cam from the pending tab of a release, formed from each item whose checkbox
475
' was checked. There are 3 different types of item to deal with, and this function will deal with them in the order shown
476
' below:
477
'    1) Subtractive merge operations
478
'    2) Additive merge operations
479
'    3) Manual/Auto build items
480
'
481
' This order was chosen by design to ensure that in the end effect upon a release, the manual and auto build items
482
' take precedence over merge candidates. This occurs naturally if we process manual/auto build items last.
483
'
484
' Parameters:
485
'   NNrtag_id       The release area
486
'   NN_pv_id_list   A list of PV_IDs representing pending items to be approved for release or merge.
487
'
488
Sub PUBLIC_MakeBulkRelease (NNrtag_id, NN_pv_id_list)
489
   Dim initialList         ' holds all items
490
   Dim remainingList1()    ' To hold additive merge items
151 ghuddy 491
   Dim remainingList2()    ' To hold auto/manual build items that need to be validated before processing
492
   Dim remainingList3()    ' To hold auto/manual build items that can be processed
493
   Dim remainingList4()    ' To hold auto/manual build items that cannot be processed due to validation failures
494
   Dim len_remainingList1
495
   Dim len_remainingList2
496
   Dim len_remainingList3
497
   Dim len_remainingList4
123 ghuddy 498
   Dim pvId
499
   Dim retParameters
500
   Dim allowedToApproveMerge
501
 
502
   ' determine in advance if user is allowed to approve merges
503
   allowedToApproveMerge = PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id)
504
 
505
   ' ready the remaining list index to extract additive merges and manual/auto build items
151 ghuddy 506
   len_remainingList1 = 0
123 ghuddy 507
 
508
   AutoBuildPermissionDenied   = FALSE
509
   ManualBuildPermissionDenied = FALSE
510
 
511
   ' Remove any spaces and split the pv_id list into a string array
512
   initialList = Split ( Replace(NN_pv_id_list, " ", "" ), "," )
513
 
514
   ' Process each subtractive merge item in the string array.
515
   ' We do these first to cleanup the release somewhat before we start adding new stuff in
516
   For Each pvId In initialList
517
      If IsNumeric(pvId) Then
518
         ' Test to see if this PV_ID represents a pending SUBTRACTIVE merge operation, and proceed with it if permissions allow
519
         If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, pvId, "S") Then
520
            If allowedToApproveMerge Then
165 brianf 521
               Call PRIVATE_ApproveMerge(NNrtag_id, pvId, "S")
123 ghuddy 522
            Else
523
               AutoBuildPermissionDenied   = TRUE
524
               ManualBuildPermissionDenied = TRUE
525
            End If
526
         Else
527
            ' add item to the remaining list for the next loop to process
151 ghuddy 528
            len_remainingList1 = len_remainingList1 + 1
529
            ReDim Preserve remainingList1(len_remainingList1)
530
            remainingList1(len_remainingList1 - 1) = pvId
123 ghuddy 531
         End If
532
      End If
533
   Next
534
 
535
   ' ready the remaining list index to extract manual/auto build items
151 ghuddy 536
   len_remainingList2 = 0
123 ghuddy 537
 
538
   ' Now process each additive merge item in the string array
539
   ' We do these before finally processing any auto/manual build items so that the latter take precedence in their eventual
540
   ' effect upon the release.
541
   For Each pvId In remainingList1
542
      ' Test to see if this PV_ID represents a pending ADDITIVE merge operation, and proceed with it if permissions allow
543
      If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, pvId, "A") Then
544
         If allowedToApproveMerge Then
165 brianf 545
            Call PRIVATE_ApproveMerge(NNrtag_id, pvId, "A")
123 ghuddy 546
         Else
547
            AutoBuildPermissionDenied   = TRUE
548
            ManualBuildPermissionDenied = TRUE
549
         End If
550
      Else
551
         ' add item to the remaining list for the next loop to process
151 ghuddy 552
         len_remainingList2 = len_remainingList2 + 1
553
         ReDim Preserve remainingList2(len_remainingList2)
554
         remainingList2(len_remainingList2 - 1) = pvId
123 ghuddy 555
      End If
556
   Next
557
 
151 ghuddy 558
   ' ready the remaining list index to extract manual/auto build items
559
   len_remainingList3 = 0
560
   len_remainingList4 = 0
561
 
562
   ' We cannot bulk release multiple WIPS of the same pkg_id because the modified_stamp in the package versions
563
   ' table for each one will become identical upon doing so (since they are simultaneously being bulk released)
564
   ' and the build daemon will therefore not necessarily build them in the order the user needs them to be built in.
565
   ' This is especially the case with multiple WIPS for packages that are in fact database patches.
566
   ' We have to bust out those pv_ids from the ones we can bulk release, and tell the user about them afterwards,
567
   ' basically forcing the user to approve them one by one.
568
   ' We use a few dictionaries to bust apart the pv_id's
569
 
570
   Dim pkgIdsAndCounts
571
   Dim pkgIdsAndPvIds
572
   Dim pkgId
573
 
574
   Set pkgIdsAndCounts = Server.CreateObject("Scripting.Dictionary")
575
   Set pkgIdsAndPvIds = Server.CreateObject("Scripting.Dictionary")
576
 
577
   ' Count instances of pkg_id's and for each pkg_id, create a list of pv_id's, using the dictionaries declared earlier
578
   For Each pvId In remainingList2
579
      If ( NNrtag_id <> "") AND (pvId <> "") Then
580
         pkgId = Get_Pkg_Id_For_Pv_Id(pvId)
581
         If pkgIdsAndCounts.Exists(pkgId) Then
582
            pkgIdsAndCounts.Item(pkgId) = CStr(CInt(pkgIdsAndCounts.Item(pkgId)) + 1)
583
            pkgIdsAndPvIds.Item(pkgId) = pkgIdsAndPvIds.Item(pkgId) & "," & pvId
584
         Else
585
            pkgIdsAndCounts.Add pkgId, "1"
586
            pkgIdsAndPvIds.Add pkgId, pvId
587
         End If
588
      End If
589
   Next
590
 
591
   ' Now use the pkg_id counts to distinguish between the pv_id's we can proceed with and those we cannot.
592
   ' The ones we can proceed with are accumulated into remainingList3, and the ones we cannot are
593
   ' accumulated into remainingList4
594
   Dim i,a
595
   a = pkgIdsAndCounts.Keys
596
   For i=0 to pkgIdsAndCounts.Count-1
597
      If pkgIdsAndCounts.Item(a(i)) = "1" Then
598
         len_remainingList3 = len_remainingList3 + 1
599
         ReDim Preserve remainingList3(len_remainingList3)
600
         remainingList3(len_remainingList3 - 1) = pkgIdsAndPvIds.Item(a(i))
601
      Else
602
         len_remainingList4 = len_remainingList4 + 1
603
         ReDim Preserve remainingList4(len_remainingList4)
604
         remainingList4(len_remainingList4 - 1) = pkgIdsAndPvIds.Item(a(i))
605
      End If
606
   Next
607
 
608
   ' free dictionaries
609
   Set pkgIdsAndCounts = nothing
610
   Set pkgIdsAndPvIds = nothing
611
 
612
   ' Now process each new and valid Auto/Manaul build item in the string array
129 ghuddy 613
   RaiseWIPExists = FALSE
151 ghuddy 614
   For Each pvId In remainingList3
129 ghuddy 615
      Call PUBLIC_ApproveRelease(NNrtag_id, pvId, retParameters, TRUE)
123 ghuddy 616
   Next
129 ghuddy 617
   If ( RaiseWIPExists = TRUE ) Then
151 ghuddy 618
     Call RaiseMsg ( enum_MSG_PACKAGE_WIP_EXISTS & "?rtag_id="& request("rtag_id") & "&pv_id="& request("pv_id") & "", "" )
129 ghuddy 619
     ' RaiseMsg redirects loaded web page, so no return
620
   End If
123 ghuddy 621
 
151 ghuddy 622
   ' Issue a warning for when some items could not be bulk released due to having the same package ID's
623
   If len_remainingList4 > 0 Then
624
      Call RaiseMsg ( enum_MSG_PACKAGE_WIP_EXISTS_BULK_RELEASE & "?rtag_id="& request("rtag_id") & "&pv_id="& request("pv_id") & "", "" )
625
   End If
123 ghuddy 626
 
627
   ' If any items were not approved for release due to permission errors, issue an alert to the user
628
   If AutoBuildPermissionDenied = TRUE OR ManualBuildPermissionDenied = TRUE Then
151 ghuddy 629
      Call RaiseMsg( enum_MSG_PERMISSION_PROBLEMS_BULK_RELEASE & "?rtag_id="& request("rtag_id") & "&pv_id="& request("pv_id") & "", "" )
123 ghuddy 630
   End If
631
 
632
End Sub
633
'-----------------------------------------------------------------------------------------------------------------------------
4358 dpurdie 634
'=============================================================================================================================
635
' MAKING A BULK REJECT from a list of PV_IDs for a specified release
636
'
637
' This section contains the new "Bulk Reject' code. This function is tied to the use of the make bulk reject button.
638
'
639
'=============================================================================================================================
123 ghuddy 640
 
4358 dpurdie 641
'-----------------------------------------------------------------------------------------------------------------------------
642
' This public function is called from the make_bulk_reject.asp file, loaded when a user presses the Make Bulk Reject
643
' button when viewing items on the Pending Tab of a release area.
644
'
645
' The function processes a list of PV_ID's that cam from the pending tab of a release, formed from each item whose checkbox
646
' was checked. There are 3 different types of item to deal with:
647
'    1) Subtractive merge operations
648
'    2) Additive merge operations
649
'    3) Manual/Auto build items
650
'
651
'
652
' Parameters:
653
'   NNrtag_id       The release area
654
'   NN_pv_id_list   A list of PV_IDs representing pending items to be approved for release or merge.
655
'
656
Sub PUBLIC_MakeBulkReject (NNrtag_id, NN_pv_id_list)
657
   Dim initialList         ' holds all items
658
   Dim pvId
659
   Dim allowedToApproveMerge
660
   Dim errorSeen
123 ghuddy 661
 
4358 dpurdie 662
   ' Init
663
   errorSeen = 0
664
 
665
   ' determine in advance if user is allowed to approve merges
666
   allowedToApproveMerge = PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id)
667
 
668
   If allowedToApproveMerge Then
669
    ' Remove any spaces and split the pv_id list into a string array
670
    initialList = Split ( Replace(NN_pv_id_list, " ", "" ), "," )
671
    For Each pvId In initialList
672
        Call PRIVATE_MakeReject(NNrtag_id,pvId, errorSeen)
673
    Next
674
      If errorSeen <> 0 Then
675
        Call RaiseMsg( enum_MSG_ERROR & "?rtag_id="& request("rtag_id") & "&pv_id="& request("pv_id"), _ 
676
            "An error was encounted rejecting one or more of the packages.<p>Packages that have not been rejected are in the 'Pending' state." )
677
      End If
678
   Else
679
      Call RaiseMsg( enum_MSG_ERROR & "?rtag_id="& request("rtag_id") & "&pv_id="& request("pv_id"), _ 
680
            "You do not appear to have permissions to perform the Bulk Reject operation" )
681
   End If
682
End Sub
683
 
684
'-----------------------------------------------------------------------------------------------------------------------------
685
' This public function is called from the make_bulk_reject.asp file, loaded when a user presses the Make Bulk Reject
686
'   Private function to reject a package-version
687
 
688
 
689
Sub PRIVATE_MakeReject(NNrtag_id,NNpvId, ByRef NNerrorSeen)
690
       objEH.TryORA ( OraSession )
691
   On Error Resume Next
692
 
693
   OraDatabase.Parameters.Add "PV_ID",   NNpvId,                  ORAPARM_INPUT, ORATYPE_NUMBER
694
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
695
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
696
 
697
   OraDatabase.ExecuteSQL _
698
   "BEGIN "&_
699
   " PK_ENVIRONMENT.MAKE_REJECT ( :PV_ID, :RTAG_ID, :USER_ID ); "&_
700
   "END; "
701
 
702
   objEH.CatchORA ( OraSession )
703
 
704
   OraDatabase.Parameters.Remove "PV_ID"
705
   OraDatabase.Parameters.Remove "RTAG_ID"
706
   OraDatabase.Parameters.Remove "USER_ID"
707
 
708
End Sub 
709
'-----------------------------------------------------------------------------------------------------------------------------
123 ghuddy 710
%>