Subversion Repositories DevTools

Rev

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