Subversion Repositories DevTools

Rev

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