Subversion Repositories DevTools

Rev

Rev 7022 | 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, _
7022 dpurdie 40
                  OP_CODE_1_STR, _
41
                  OP_CODE_2_STR)
149 ghuddy 42
End Sub
43
 
44
'--------------------------------------------------------------------------------------------
147 ghuddy 45
' Convert a Daemon Instruction operation code into a meaningful string
149 ghuddy 46
' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer
47
' for doing so.
147 ghuddy 48
'--------------------------------------------------------------------------------------------
49
Function DaemonInstructionOperationName(nOpCode)
50
   Select Case nOpCode
51
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
52
      DaemonInstructionOperationName = OP_CODE_0_STR
53
 
149 ghuddy 54
   Case OP_CODE_1_TEST_BUILD_PACKAGE
55
      DaemonInstructionOperationName = OP_CODE_1_STR
147 ghuddy 56
 
7022 dpurdie 57
   Case OP_CODE_2_FUTURE_BUILD
58
      DaemonInstructionOperationName = OP_CODE_2_STR
59
 
147 ghuddy 60
   Case Else
61
      DaemonInstructionOperationName = "Undefined (" & nOpCode & ")"
62
   End Select
63
End Function
149 ghuddy 64
 
147 ghuddy 65
'--------------------------------------------------------------------------------------------
149 ghuddy 66
' Convert a Daemon Instruction operation name into an op-code value
67
' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer
68
' for doing so.
69
'--------------------------------------------------------------------------------------------
70
Function DaemonInstructionOperationValue(nOpName)
71
   Select Case nOpName
72
   Case OP_CODE_0_STR
73
      DaemonInstructionOperationValue = OP_CODE_0_RIPPLE_BUILD_PACKAGE
74
 
75
   Case OP_CODE_1_STR
76
      DaemonInstructionOperationValue = OP_CODE_1_TEST_BUILD_PACKAGE
77
 
7022 dpurdie 78
   Case OP_CODE_2_STR
79
      DaemonInstructionOperationValue = OP_CODE_2_FUTURE_BUILD
80
 
149 ghuddy 81
   Case Else
82
      DaemonInstructionOperationValue = ""
83
   End Select
84
End Function
85
 
86
'--------------------------------------------------------------------------------------------
87
' Determines if a daemon instruction op-code value indicates that a PV_ID is required to be
88
' specified for the instruction.
89
'--------------------------------------------------------------------------------------------
90
Function DaemonInstructionNeedsPV_ID(nOpCode)
91
   Select Case nOpCode
92
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
93
      DaemonInstructionNeedsPV_ID = True
94
 
95
   Case OP_CODE_1_TEST_BUILD_PACKAGE
96
      DaemonInstructionNeedsPV_ID = True
97
 
7022 dpurdie 98
   Case OP_CODE_2_FUTURE_BUILD
99
      DaemonInstructionNeedsPV_ID = True
100
 
149 ghuddy 101
   Case Else
102
      DaemonInstructionNeedsPV_ID = False
103
   End Select
104
End Function
105
 
106
'--------------------------------------------------------------------------------------------
107
' Determines if a daemon instruction op-code value indicates that a repeat value is required
108
' to be specified for the instruction.
109
'--------------------------------------------------------------------------------------------
110
Function DaemonInstructionNeedsRepeat(nOpCode)
111
   ' currently - no op-codes need a repeat value
112
   DaemonInstructionNeedsRepeat = False
113
End Function
114
 
115
'--------------------------------------------------------------------------------------------
147 ghuddy 116
' Convert a Repeat Seconds value into a meaningful string. This takes account of the
117
' daemon instruction op-code too - a repeat seconds value is only relevant for certain
118
' op-codes
119
'--------------------------------------------------------------------------------------------
120
Function DaemonInstructionRepeatString(nOpCode, nRepeatSecs)
121
   DaemonInstructionRepeatString = "N/A"
122
 
123
   ' uncomment this when we are ready to introduce the "get release metrics" instruction
124
   'Select Case nOpCode
149 ghuddy 125
   'Case OP_CODE_?_GET_RELEASE_METRICS
147 ghuddy 126
   '   Select Case nRepeatSecs
127
   '   Case 86400
128
   '      DaemonInstructionRepeatString = "24Hrs"
129
   '   Case Else
130
   '      DaemonInstructionRepeatString = "NO"
131
   '   End Select
132
   '
133
   'Case Else
134
   '   DaemonInstructionRepeatString = "N/A"
135
   'End Select
136
 
137
End Function
6184 dpurdie 138
'--------------------------------------------------------------------------------------'--------------------------------------------------------------------------------------------
147 ghuddy 139
' Function to inform caller of whether the user is allowed to reset the daemon instructions
140
' in-progress flag
141
'--------------------------------------------------------------------------------------------
142
Function UserAllowedToResetInProgress
143
   UserAllowedToResetInProgress = True
144
   If objAccessControl.UserLogedIn Then
5061 dpurdie 145
      If NOT canActionControlInProject("ResetDaemonInstInProgress") Then
147 ghuddy 146
         UserAllowedToResetInProgress = False
147
      End If
148
   Else
149
      UserAllowedToResetInProgress = False
150
   End If
151
End Function
152
 
149 ghuddy 153
'--------------------------------------------------------------------------------------------
154
' Daemon Instruction validation function
155
'--------------------------------------------------------------------------------------------
183 brianf 156
Function HandleValidateDaemonInstructionError(nOpCode, retERRmsg, ByRef sErrorMsg)
149 ghuddy 157
   Dim s
147 ghuddy 158
 
149 ghuddy 159
   s = ""
6184 dpurdie 160
'retERRmsg = "enum_MSG_BROKEN_DEPENDENCIES_FOUND"
149 ghuddy 161
   HandleValidateDaemonInstructionError = True
162
 
163
   If NOT IsNull(retERRmsg) Then
151 ghuddy 164
      ' Exclusions -
165
      ' 1) Ignore "unit tests not supplied" error for ripple build package daemon instruction
166
      If NOT ((nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) AND (retERRmsg = "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"))  Then
149 ghuddy 167
 
151 ghuddy 168
         ' Re-interpret the error message that has been returned from the queries. We do this because normally,
169
         ' these errors are associated with individual message files but the messsages in those files are slightly
170
         ' inappropriate for the context of adding a daemon instruction so we will provide our own message display
171
         ' using the generic enum_WMSG_ERROR file with a bespoke error string.
172
         Select Case retERRmsg
173
         Case "enum_MSG_MISSING_DEPENDENCIES"
174
            s = "Some dependencies of this package are missing from a release."
175
         Case "enum_MSG_PACKAGE_INFORMATION_INCOMPLETE"
176
            s = "Package information section on Release Notes tab is not fully complete."
177
         Case "enum_MSG_AUTOBUILD_PACKAGE_REQUIRES_BUILD_STD_AND_ENV"
178
            s = "Package must have a build standard and build environment."
179
         Case "enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED"
180
            s = "A reason for this version must be supplied."
181
         Case "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"
182
            s = "There are no unit tests supplied for this package."
183
         Case "enum_MSG_PACKAGE_CHANGETYPE_INCOMPLETE"
184
            s = "Package change type in Release Notes Tab is not defined."
185
         Case "enum_MSG_BROKEN_DEPENDENCIES_FOUND"
186
            s = "Some of the packages dependencies are broken. Fix them first before trying to add a daemon instruction to this package."
187
         Case "enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND"
188
            s = "Some dependencies of this package are still not released. Release them first before trying to add a daemon instruction to this package."
189
         Case Else
190
            s = "Correct any errors in the release notes, and try again."
191
         End Select
149 ghuddy 192
 
6184 dpurdie 193
         sErrorMsg = "Cannot add this daemon instruction<br>" & s
151 ghuddy 194
 
195
         HandleValidateDaemonInstructionError = False
196
      End If
149 ghuddy 197
   End If
198
End Function
199
 
6184 dpurdie 200
Function ValidateDaemonInstruction(nOpCode, nRtag_id, nPv_id, ByRef sErrorMsg)
149 ghuddy 201
   Dim retERRmsg
202
   Dim retALRTmsg
203
   Dim retParameters
204
   Dim pkgType
205
   Dim s
206
   s = ""
207
   pkgType = 0
208
 
209
   ValidateDaemonInstruction = True
210
 
211
   Select Case nOpCode
212
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
213
      ' Note: cannot use CheckRequirementsForMakeApproved here because it fails on the change_type check. This seems
214
      ' to be because a daemon ripple build results in a new package version that has null in the change_type column
215
      ' so we cannot validate that column in the package_versions table.
216
 
217
      ' check missing dependencies, bad package info, missing build std/env, reason for version, unit test
218
      Call CheckRequirementsForMakePending ( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
219
      If IsNull(retERRmsg) Then
220
         ' Check broken dependencies, missing dependencies, unofficial dependencies, bad package info, reason for version, unit test
221
         Call CheckRequirementsForMakeRelease( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
222
      End If
6184 dpurdie 223
 
224
      ' Process retERRmsg into an error message 
183 brianf 225
      ValidateDaemonInstruction = HandleValidateDaemonInstructionError(nOpCode,retERRmsg,sErrorMsg)
149 ghuddy 226
 
227
   Case OP_CODE_1_TEST_BUILD_PACKAGE
151 ghuddy 228
      ValidateDaemonInstruction = True ' no validation checks for this instruction
149 ghuddy 229
 
7029 dpurdie 230
   Case OP_CODE_2_FUTURE_BUILD
231
      ValidateDaemonInstruction = True ' no validation checks for this instruction
232
 
149 ghuddy 233
   Case Else
6184 dpurdie 234
 
235
      sErrorMsg = "Attempt to add an unknown daemon instruction type"
149 ghuddy 236
      ValidateDaemonInstruction = False
237
   End Select
6184 dpurdie 238
 
149 ghuddy 239
End Function
240
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 241
Function DaemonInstructionPreventsEditing(nRtag_id, nPv_id)
149 ghuddy 242
 
153 ghuddy 243
   Dim rsQry
244
   Dim QryStr
149 ghuddy 245
 
153 ghuddy 246
   DaemonInstructionPreventsEditing = FALSE
149 ghuddy 247
 
153 ghuddy 248
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") Then
249
 
250
      QryStr = "SELECT COUNT(*) AS record_count"&_
251
               "  FROM DAEMON_INSTRUCTIONS "&_
252
               " WHERE (OP_CODE = "& OP_CODE_1_TEST_BUILD_PACKAGE &")"&_
253
               "   AND RTAG_ID = "& nRtag_id&_
254
               "   AND PV_ID = "& nPv_id
255
 
256
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
257
 
258
      If rsQry("record_count") <> 0 Then
259
        DaemonInstructionPreventsEditing = TRUE
260
      End If
261
 
262
      rsQry.Close
263
      Set rsQry = nothing
264
   End If
265
 
266
End Function
5030 dpurdie 267
 
153 ghuddy 268
'------------------------------------------------------------------------------------------------------------------------------------------
5030 dpurdie 269
Function DaemonInstructionPresent(nRtag_id, nPv_id, nOpCode)
270
 
271
   Dim rsQry
272
   Dim QryStr
273
 
274
   DaemonInstructionPresent = FALSE
275
 
276
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") AND (NOT IsNull(nOpCode)) AND (nOpCode <> "") Then
277
 
278
      QryStr = "SELECT COUNT(*) AS record_count"&_
279
               "  FROM DAEMON_INSTRUCTIONS "&_
280
               " WHERE (OP_CODE = "& nOpCode &")"&_
281
               "   AND RTAG_ID = "& nRtag_id&_
282
               "   AND PV_ID = "& nPv_id
283
 
284
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
285
 
286
      If rsQry("record_count") <> 0 Then
287
        DaemonInstructionPresent = TRUE
288
      End If
289
 
290
      rsQry.Close
291
      Set rsQry = nothing
292
   End If
293
 
294
End Function
295
 
296
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 297
Function DaemonInstructionPreventsReleaseDeletion(nRtag_id)
298
 
299
   Dim rsQry
300
   Dim QryStr
301
 
302
   DaemonInstructionPreventsReleaseDeletion = FALSE
303
 
304
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") Then
305
 
306
      QryStr = "SELECT COUNT(*) AS record_count"&_
307
               "  FROM DAEMON_INSTRUCTIONS "&_
308
               " WHERE RTAG_ID = "& nRtag_id
309
 
310
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
311
 
312
      If rsQry("record_count") <> 0 Then
313
        DaemonInstructionPreventsReleaseDeletion = TRUE
314
      End If
315
 
316
      rsQry.Close
317
      Set rsQry = nothing
318
   End If
319
 
320
End Function
321
'------------------------------------------------------------------------------------------------------------------------------------------
322
Function UserCanAddOrEditThisDaemonInst(nProjId, nReleaseMode, nOpCode)
323
 
324
   UserCanAddOrEditThisDaemonInst = TRUE
325
 
326
   If objAccessControl.UserLogedIn Then
5061 dpurdie 327
      If NOT canActionInProject() Then
153 ghuddy 328
         UserCanAddOrEditThisDaemonInst = False
329
      ElseIf (( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) AND (nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) ) Then
5061 dpurdie 330
         If NOT canActionControlInProject("ApproveForAutoBuild") Then
153 ghuddy 331
            UserCanAddOrEditThisDaemonInst = False
332
         End If
333
      End If
334
   Else
335
      UserCanAddOrEditThisDaemonInst = False
336
   End If
5061 dpurdie 337
 
153 ghuddy 338
End Function
339
'------------------------------------------------------------------------------------------------------------------------------------------
147 ghuddy 340
%>