Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
147 ghuddy 1
<%
2
'=====================================================
3
'    Common Subs for DAEMON INSTRUCTIONS
4
'=====================================================
5
%>
6
<%
7
'--------------------------------------------------------------------------------------------
8
' Indicates if the specified daemon instruction is in progress
9
'--------------------------------------------------------------------------------------------
10
Function DaemonInstructionInProgress( nInstId )
11
   Dim rsQry
12
 
13
   DaemonInstructionInProgress = False
14
 
15
   If NOT IsNull(nInstId) AND nInstId <> "" Then
16
 
17
      Set rsQry = OraDatabase.DbCreateDynaset( "SELECT IN_PROGRESS"&_
18
                                               "  FROM DAEMON_INSTRUCTIONS "&_
19
                                               " WHERE DAEMON_INSTRUCTIONS_ID = "& nInstId, ORADYN_DEFAULT )
20
      If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then
21
 
22
         If (NOT IsNull(rsQry("IN_PROGRESS"))) AND (rsQry("IN_PROGRESS") = "1") Then
23
            DaemonInstructionInProgress = True
24
         End If
25
      End If
26
 
27
      rsQry.Close
28
      Set rsQry = nothing
29
   End If
30
End Function
149 ghuddy 31
 
147 ghuddy 32
'--------------------------------------------------------------------------------------------
149 ghuddy 33
' Assign the inout parameter to an array containing the list of all human readable op-code
34
' strings, in ascending op-code value order. This list will be used to form a drop-down list
35
' control on an html form
36
'--------------------------------------------------------------------------------------------
37
Sub GetDaemonInstructionOperationNameArray(nArray)
38
   ' append new op-codes to this list when they are invented
39
   nArray = array(OP_CODE_0_STR, _
40
                  OP_CODE_1_STR)
41
End Sub
42
 
43
'--------------------------------------------------------------------------------------------
147 ghuddy 44
' Convert a Daemon Instruction operation code into a meaningful string
149 ghuddy 45
' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer
46
' for doing so.
147 ghuddy 47
'--------------------------------------------------------------------------------------------
48
Function DaemonInstructionOperationName(nOpCode)
49
   Select Case nOpCode
50
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
51
      DaemonInstructionOperationName = OP_CODE_0_STR
52
 
149 ghuddy 53
   Case OP_CODE_1_TEST_BUILD_PACKAGE
54
      DaemonInstructionOperationName = OP_CODE_1_STR
147 ghuddy 55
 
56
   Case Else
57
      DaemonInstructionOperationName = "Undefined (" & nOpCode & ")"
58
   End Select
59
End Function
149 ghuddy 60
 
147 ghuddy 61
'--------------------------------------------------------------------------------------------
149 ghuddy 62
' Convert a Daemon Instruction operation name into an op-code value
63
' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer
64
' for doing so.
65
'--------------------------------------------------------------------------------------------
66
Function DaemonInstructionOperationValue(nOpName)
67
   Select Case nOpName
68
   Case OP_CODE_0_STR
69
      DaemonInstructionOperationValue = OP_CODE_0_RIPPLE_BUILD_PACKAGE
70
 
71
   Case OP_CODE_1_STR
72
      DaemonInstructionOperationValue = OP_CODE_1_TEST_BUILD_PACKAGE
73
 
74
   Case Else
75
      DaemonInstructionOperationValue = ""
76
   End Select
77
End Function
78
 
79
'--------------------------------------------------------------------------------------------
80
' Determines if a daemon instruction op-code value indicates that a PV_ID is required to be
81
' specified for the instruction.
82
'--------------------------------------------------------------------------------------------
83
Function DaemonInstructionNeedsPV_ID(nOpCode)
84
   Select Case nOpCode
85
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
86
      DaemonInstructionNeedsPV_ID = True
87
 
88
   Case OP_CODE_1_TEST_BUILD_PACKAGE
89
      DaemonInstructionNeedsPV_ID = True
90
 
91
   Case Else
92
      DaemonInstructionNeedsPV_ID = False
93
   End Select
94
End Function
95
 
96
'--------------------------------------------------------------------------------------------
97
' Determines if a daemon instruction op-code value indicates that a repeat value is required
98
' to be specified for the instruction.
99
'--------------------------------------------------------------------------------------------
100
Function DaemonInstructionNeedsRepeat(nOpCode)
101
   ' currently - no op-codes need a repeat value
102
   DaemonInstructionNeedsRepeat = False
103
End Function
104
 
105
'--------------------------------------------------------------------------------------------
147 ghuddy 106
' Convert a Repeat Seconds value into a meaningful string. This takes account of the
107
' daemon instruction op-code too - a repeat seconds value is only relevant for certain
108
' op-codes
109
'--------------------------------------------------------------------------------------------
110
Function DaemonInstructionRepeatString(nOpCode, nRepeatSecs)
111
   DaemonInstructionRepeatString = "N/A"
112
 
113
   ' uncomment this when we are ready to introduce the "get release metrics" instruction
114
   'Select Case nOpCode
149 ghuddy 115
   'Case OP_CODE_?_GET_RELEASE_METRICS
147 ghuddy 116
   '   Select Case nRepeatSecs
117
   '   Case 86400
118
   '      DaemonInstructionRepeatString = "24Hrs"
119
   '   Case Else
120
   '      DaemonInstructionRepeatString = "NO"
121
   '   End Select
122
   '
123
   'Case Else
124
   '   DaemonInstructionRepeatString = "N/A"
125
   'End Select
126
 
127
End Function
128
'--------------------------------------------------------------------------------------------
129
' Queries the database to get a comma-seperated list of op-codes for a given release, and
130
' converts them into a comma seperated list of operation names for display purposes
149 ghuddy 131
' This is used in _package_common.asp to provide visual indication to RM users that daemon
132
' instructions for the release have been created.
147 ghuddy 133
'--------------------------------------------------------------------------------------------
134
Function GetOpCodeListForRtagId( pretext, nRtag_id, posttext )
135
   Dim opCodeListString
136
   Dim opCodeList
137
   Dim opCodeStr
138
   GetOpCodeListForRtagId = ""
139
 
140
   On Error Resume Next
141
 
142
   objEH.TryORA ( OraSession )
143
 
144
   OraDatabase.Parameters.Add "OP_CODE_LIST", NULL, ORAPARM_OUTPUT, ORATYPE_VARCHAR2
145
 
146
   OraDatabase.ExecuteSQL _
147
   "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag("& nRtag_id & "); END;"
148
 
149
   objEH.CatchORA ( OraSession )
150
 
151
   opCodeListString  = OraDatabase.Parameters("OP_CODE_LIST").Value
152
 
153
   OraDatabase.Parameters.Remove "OP_CODE_LIST"
154
 
155
   If NOT IsNull(opCodeListString) AND opCodeListString <> "" Then
156
      opCodeList = Split(opCodeListString, ",")
157
      For Each opCodeStr In opCodeList
158
         If NOT IsNull(opCodeStr) AND opCodeStr <> "" Then
159
            GetOpCodeListForRtagId = GetOpCodeListForRtagId + DaemonInstructionOperationName(opCodeStr)
160
         End If
161
      Next
162
   End If
163
 
164
   If GetOpCodeListForRtagId <> "" Then
165
      GetOpCodeListForRtagId = pretext & GetOpCodeListForRtagId + posttext
166
   End If
167
End Function
168
'--------------------------------------------------------------------------------------------
169
' Queries the database to get a comma-seperated list of op-codes for a given release and package
170
' version, and converts them into a comma seperated list of operation names for display purposes
149 ghuddy 171
' This is used in _package_common.asp to provide visual indication to RM users that daemon
172
' instructions for the release and package version have been created.
147 ghuddy 173
'--------------------------------------------------------------------------------------------
174
Function GetOpCodeListForRtagIdAndPvId( pretext, nRtag_id, nPv_id, posttext )
175
   Dim opCodeListString
176
   Dim opCodeList
177
   Dim opCodeStr
178
 
179
   GetOpCodeListForRtagIdAndPvId = ""
180
 
181
   On Error Resume Next
182
 
183
   If (NOT IsNull(nRtag_id)) AND nRtag_id <> "" Then
184
 
185
      objEH.TryORA ( OraSession )
186
 
187
      OraDatabase.Parameters.Add "OP_CODE_LIST", NULL, ORAPARM_OUTPUT, ORATYPE_VARCHAR2
188
 
189
      If (NOT IsNull(nPv_id)) AND nPv_id <> "" Then
190
         OraDatabase.ExecuteSQL _
191
         "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag_pvid("& nRtag_id & "," & nPv_id & "); END;"
192
      Else
193
         OraDatabase.ExecuteSQL _
194
         "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag("& nRtag_id & "); END;"
195
      End If
196
 
197
      objEH.CatchORA ( OraSession )
198
 
199
      opCodeListString  = OraDatabase.Parameters("OP_CODE_LIST").Value
200
 
201
      OraDatabase.Parameters.Remove "OP_CODE_LIST"
202
 
203
      If NOT IsNull(opCodeListString) AND opCodeListString <> "" Then
204
         opCodeList = Split(opCodeListString, ",")
205
         For Each opCodeStr In opCodeList
206
            If NOT IsNull(opCodeStr) AND opCodeStr <> "" Then
207
               GetOpCodeListForRtagIdAndPvId = GetOpCodeListForRtagIdAndPvId + DaemonInstructionOperationName(opCodeStr)
208
            End If
209
         Next
210
      End If
211
 
212
   End If
213
 
214
   If GetOpCodeListForRtagIdAndPvId <> "" Then
215
      GetOpCodeListForRtagIdAndPvId = pretext & GetOpCodeListForRtagIdAndPvId + posttext
216
   End If
217
End Function
218
'--------------------------------------------------------------------------------------------
219
' Function to inform caller of whether the user is allowed to reset the daemon instructions
220
' in-progress flag
221
'--------------------------------------------------------------------------------------------
222
Function UserAllowedToResetInProgress
223
   UserAllowedToResetInProgress = True
224
   If objAccessControl.UserLogedIn Then
5061 dpurdie 225
      If NOT canActionControlInProject("ResetDaemonInstInProgress") Then
147 ghuddy 226
         UserAllowedToResetInProgress = False
227
      End If
228
   Else
229
      UserAllowedToResetInProgress = False
230
   End If
231
End Function
232
 
149 ghuddy 233
'--------------------------------------------------------------------------------------------
234
' Daemon Instruction validation function
235
'--------------------------------------------------------------------------------------------
183 brianf 236
Function HandleValidateDaemonInstructionError(nOpCode, retERRmsg, ByRef sErrorMsg)
149 ghuddy 237
   Dim s
147 ghuddy 238
 
149 ghuddy 239
   s = ""
147 ghuddy 240
 
149 ghuddy 241
   HandleValidateDaemonInstructionError = True
242
 
243
   If NOT IsNull(retERRmsg) Then
151 ghuddy 244
      ' Exclusions -
245
      ' 1) Ignore "unit tests not supplied" error for ripple build package daemon instruction
246
      If NOT ((nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) AND (retERRmsg = "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"))  Then
149 ghuddy 247
 
151 ghuddy 248
         ' Re-interpret the error message that has been returned from the queries. We do this because normally,
249
         ' these errors are associated with individual message files but the messsages in those files are slightly
250
         ' inappropriate for the context of adding a daemon instruction so we will provide our own message display
251
         ' using the generic enum_WMSG_ERROR file with a bespoke error string.
252
         Select Case retERRmsg
253
         Case "enum_MSG_MISSING_DEPENDENCIES"
254
            s = "Some dependencies of this package are missing from a release."
255
         Case "enum_MSG_PACKAGE_INFORMATION_INCOMPLETE"
256
            s = "Package information section on Release Notes tab is not fully complete."
257
         Case "enum_MSG_AUTOBUILD_PACKAGE_REQUIRES_BUILD_STD_AND_ENV"
258
            s = "Package must have a build standard and build environment."
259
         Case "enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED"
260
            s = "A reason for this version must be supplied."
261
         Case "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"
262
            s = "There are no unit tests supplied for this package."
263
         Case "enum_MSG_PACKAGE_CHANGETYPE_INCOMPLETE"
264
            s = "Package change type in Release Notes Tab is not defined."
265
         Case "enum_MSG_BROKEN_DEPENDENCIES_FOUND"
266
            s = "Some of the packages dependencies are broken. Fix them first before trying to add a daemon instruction to this package."
267
         Case "enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND"
268
            s = "Some dependencies of this package are still not released. Release them first before trying to add a daemon instruction to this package."
269
         Case Else
270
            s = "Correct any errors in the release notes, and try again."
271
         End Select
149 ghuddy 272
 
183 brianf 273
         sErrorMsg = "Cannot add this daemon instruction<br><br>" & s
151 ghuddy 274
 
275
         HandleValidateDaemonInstructionError = False
276
      End If
149 ghuddy 277
   End If
278
 
279
End Function
280
 
281
Function ValidateDaemonInstruction(nOpCode, nRtag_id, nPv_id)
282
   Dim retERRmsg
283
   Dim retALRTmsg
284
   Dim retParameters
285
   Dim pkgType
286
   Dim s
183 brianf 287
   Dim sErrorMsg
149 ghuddy 288
   s = ""
289
   pkgType = 0
290
 
291
   ValidateDaemonInstruction = True
292
 
293
   Select Case nOpCode
294
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
295
      ' Note: cannot use CheckRequirementsForMakeApproved here because it fails on the change_type check. This seems
296
      ' to be because a daemon ripple build results in a new package version that has null in the change_type column
297
      ' so we cannot validate that column in the package_versions table.
298
 
299
      ' check missing dependencies, bad package info, missing build std/env, reason for version, unit test
300
      Call CheckRequirementsForMakePending ( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
301
      If IsNull(retERRmsg) Then
302
         ' Check broken dependencies, missing dependencies, unofficial dependencies, bad package info, reason for version, unit test
303
         Call CheckRequirementsForMakeRelease( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
304
      End If
183 brianf 305
      ValidateDaemonInstruction = HandleValidateDaemonInstructionError(nOpCode,retERRmsg,sErrorMsg)
149 ghuddy 306
 
183 brianf 307
      If Not ValidateDaemonInstruction Then
308
        Call RaiseMsg(enum_MSG_ERROR, sErrorMsg)
309
      End If
149 ghuddy 310
   Case OP_CODE_1_TEST_BUILD_PACKAGE
151 ghuddy 311
      ValidateDaemonInstruction = True ' no validation checks for this instruction
149 ghuddy 312
 
313
   Case Else
183 brianf 314
      Call RaiseMsg(enum_MSG_ERROR, "Attempt to add an unknown daemon instruction")
149 ghuddy 315
      ValidateDaemonInstruction = False
316
   End Select
317
End Function
318
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 319
Function DaemonInstructionPreventsEditing(nRtag_id, nPv_id)
149 ghuddy 320
 
153 ghuddy 321
   Dim rsQry
322
   Dim QryStr
149 ghuddy 323
 
153 ghuddy 324
   DaemonInstructionPreventsEditing = FALSE
149 ghuddy 325
 
153 ghuddy 326
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") Then
327
 
328
      QryStr = "SELECT COUNT(*) AS record_count"&_
329
               "  FROM DAEMON_INSTRUCTIONS "&_
330
               " WHERE (OP_CODE = "& OP_CODE_1_TEST_BUILD_PACKAGE &")"&_
331
               "   AND RTAG_ID = "& nRtag_id&_
332
               "   AND PV_ID = "& nPv_id
333
 
334
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
335
 
336
      If rsQry("record_count") <> 0 Then
337
        DaemonInstructionPreventsEditing = TRUE
338
      End If
339
 
340
      rsQry.Close
341
      Set rsQry = nothing
342
   End If
343
 
344
End Function
5030 dpurdie 345
 
153 ghuddy 346
'------------------------------------------------------------------------------------------------------------------------------------------
5030 dpurdie 347
Function DaemonInstructionPresent(nRtag_id, nPv_id, nOpCode)
348
 
349
   Dim rsQry
350
   Dim QryStr
351
 
352
   DaemonInstructionPresent = FALSE
353
 
354
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") AND (NOT IsNull(nOpCode)) AND (nOpCode <> "") Then
355
 
356
      QryStr = "SELECT COUNT(*) AS record_count"&_
357
               "  FROM DAEMON_INSTRUCTIONS "&_
358
               " WHERE (OP_CODE = "& nOpCode &")"&_
359
               "   AND RTAG_ID = "& nRtag_id&_
360
               "   AND PV_ID = "& nPv_id
361
 
362
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
363
 
364
      If rsQry("record_count") <> 0 Then
365
        DaemonInstructionPresent = TRUE
366
      End If
367
 
368
      rsQry.Close
369
      Set rsQry = nothing
370
   End If
371
 
372
End Function
373
 
374
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 375
Function DaemonInstructionPreventsReleaseDeletion(nRtag_id)
376
 
377
   Dim rsQry
378
   Dim QryStr
379
 
380
   DaemonInstructionPreventsReleaseDeletion = FALSE
381
 
382
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") Then
383
 
384
      QryStr = "SELECT COUNT(*) AS record_count"&_
385
               "  FROM DAEMON_INSTRUCTIONS "&_
386
               " WHERE RTAG_ID = "& nRtag_id
387
 
388
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
389
 
390
      If rsQry("record_count") <> 0 Then
391
        DaemonInstructionPreventsReleaseDeletion = TRUE
392
      End If
393
 
394
      rsQry.Close
395
      Set rsQry = nothing
396
   End If
397
 
398
End Function
399
'------------------------------------------------------------------------------------------------------------------------------------------
400
Function UserCanAddOrEditThisDaemonInst(nProjId, nReleaseMode, nOpCode)
401
 
402
   UserCanAddOrEditThisDaemonInst = TRUE
403
 
404
   If objAccessControl.UserLogedIn Then
5061 dpurdie 405
      If NOT canActionInProject() Then
153 ghuddy 406
         UserCanAddOrEditThisDaemonInst = False
407
      ElseIf (( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) AND (nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) ) Then
5061 dpurdie 408
         If NOT canActionControlInProject("ApproveForAutoBuild") Then
153 ghuddy 409
            UserCanAddOrEditThisDaemonInst = False
410
         End If
411
      End If
412
   Else
413
      UserCanAddOrEditThisDaemonInst = False
414
   End If
5061 dpurdie 415
 
153 ghuddy 416
End Function
417
'------------------------------------------------------------------------------------------------------------------------------------------
147 ghuddy 418
%>