Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

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