Subversion Repositories DevTools

Rev

Rev 5957 | 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, _
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
6184 dpurdie 128
'--------------------------------------------------------------------------------------'--------------------------------------------------------------------------------------------
147 ghuddy 129
' Function to inform caller of whether the user is allowed to reset the daemon instructions
130
' in-progress flag
131
'--------------------------------------------------------------------------------------------
132
Function UserAllowedToResetInProgress
133
   UserAllowedToResetInProgress = True
134
   If objAccessControl.UserLogedIn Then
5061 dpurdie 135
      If NOT canActionControlInProject("ResetDaemonInstInProgress") Then
147 ghuddy 136
         UserAllowedToResetInProgress = False
137
      End If
138
   Else
139
      UserAllowedToResetInProgress = False
140
   End If
141
End Function
142
 
149 ghuddy 143
'--------------------------------------------------------------------------------------------
144
' Daemon Instruction validation function
145
'--------------------------------------------------------------------------------------------
183 brianf 146
Function HandleValidateDaemonInstructionError(nOpCode, retERRmsg, ByRef sErrorMsg)
149 ghuddy 147
   Dim s
147 ghuddy 148
 
149 ghuddy 149
   s = ""
6184 dpurdie 150
'retERRmsg = "enum_MSG_BROKEN_DEPENDENCIES_FOUND"
149 ghuddy 151
   HandleValidateDaemonInstructionError = True
152
 
153
   If NOT IsNull(retERRmsg) Then
151 ghuddy 154
      ' Exclusions -
155
      ' 1) Ignore "unit tests not supplied" error for ripple build package daemon instruction
156
      If NOT ((nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) AND (retERRmsg = "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"))  Then
149 ghuddy 157
 
151 ghuddy 158
         ' Re-interpret the error message that has been returned from the queries. We do this because normally,
159
         ' these errors are associated with individual message files but the messsages in those files are slightly
160
         ' inappropriate for the context of adding a daemon instruction so we will provide our own message display
161
         ' using the generic enum_WMSG_ERROR file with a bespoke error string.
162
         Select Case retERRmsg
163
         Case "enum_MSG_MISSING_DEPENDENCIES"
164
            s = "Some dependencies of this package are missing from a release."
165
         Case "enum_MSG_PACKAGE_INFORMATION_INCOMPLETE"
166
            s = "Package information section on Release Notes tab is not fully complete."
167
         Case "enum_MSG_AUTOBUILD_PACKAGE_REQUIRES_BUILD_STD_AND_ENV"
168
            s = "Package must have a build standard and build environment."
169
         Case "enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED"
170
            s = "A reason for this version must be supplied."
171
         Case "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"
172
            s = "There are no unit tests supplied for this package."
173
         Case "enum_MSG_PACKAGE_CHANGETYPE_INCOMPLETE"
174
            s = "Package change type in Release Notes Tab is not defined."
175
         Case "enum_MSG_BROKEN_DEPENDENCIES_FOUND"
176
            s = "Some of the packages dependencies are broken. Fix them first before trying to add a daemon instruction to this package."
177
         Case "enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND"
178
            s = "Some dependencies of this package are still not released. Release them first before trying to add a daemon instruction to this package."
179
         Case Else
180
            s = "Correct any errors in the release notes, and try again."
181
         End Select
149 ghuddy 182
 
6184 dpurdie 183
         sErrorMsg = "Cannot add this daemon instruction<br>" & s
151 ghuddy 184
 
185
         HandleValidateDaemonInstructionError = False
186
      End If
149 ghuddy 187
   End If
188
End Function
189
 
6184 dpurdie 190
Function ValidateDaemonInstruction(nOpCode, nRtag_id, nPv_id, ByRef sErrorMsg)
149 ghuddy 191
   Dim retERRmsg
192
   Dim retALRTmsg
193
   Dim retParameters
194
   Dim pkgType
195
   Dim s
196
   s = ""
197
   pkgType = 0
198
 
199
   ValidateDaemonInstruction = True
200
 
201
   Select Case nOpCode
202
   Case OP_CODE_0_RIPPLE_BUILD_PACKAGE
203
      ' Note: cannot use CheckRequirementsForMakeApproved here because it fails on the change_type check. This seems
204
      ' to be because a daemon ripple build results in a new package version that has null in the change_type column
205
      ' so we cannot validate that column in the package_versions table.
206
 
207
      ' check missing dependencies, bad package info, missing build std/env, reason for version, unit test
208
      Call CheckRequirementsForMakePending ( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
209
      If IsNull(retERRmsg) Then
210
         ' Check broken dependencies, missing dependencies, unofficial dependencies, bad package info, reason for version, unit test
211
         Call CheckRequirementsForMakeRelease( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
212
      End If
6184 dpurdie 213
 
214
      ' Process retERRmsg into an error message 
183 brianf 215
      ValidateDaemonInstruction = HandleValidateDaemonInstructionError(nOpCode,retERRmsg,sErrorMsg)
149 ghuddy 216
 
217
   Case OP_CODE_1_TEST_BUILD_PACKAGE
151 ghuddy 218
      ValidateDaemonInstruction = True ' no validation checks for this instruction
149 ghuddy 219
 
220
   Case Else
6184 dpurdie 221
 
222
      sErrorMsg = "Attempt to add an unknown daemon instruction type"
149 ghuddy 223
      ValidateDaemonInstruction = False
224
   End Select
6184 dpurdie 225
 
149 ghuddy 226
End Function
227
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 228
Function DaemonInstructionPreventsEditing(nRtag_id, nPv_id)
149 ghuddy 229
 
153 ghuddy 230
   Dim rsQry
231
   Dim QryStr
149 ghuddy 232
 
153 ghuddy 233
   DaemonInstructionPreventsEditing = FALSE
149 ghuddy 234
 
153 ghuddy 235
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") Then
236
 
237
      QryStr = "SELECT COUNT(*) AS record_count"&_
238
               "  FROM DAEMON_INSTRUCTIONS "&_
239
               " WHERE (OP_CODE = "& OP_CODE_1_TEST_BUILD_PACKAGE &")"&_
240
               "   AND RTAG_ID = "& nRtag_id&_
241
               "   AND PV_ID = "& nPv_id
242
 
243
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
244
 
245
      If rsQry("record_count") <> 0 Then
246
        DaemonInstructionPreventsEditing = TRUE
247
      End If
248
 
249
      rsQry.Close
250
      Set rsQry = nothing
251
   End If
252
 
253
End Function
5030 dpurdie 254
 
153 ghuddy 255
'------------------------------------------------------------------------------------------------------------------------------------------
5030 dpurdie 256
Function DaemonInstructionPresent(nRtag_id, nPv_id, nOpCode)
257
 
258
   Dim rsQry
259
   Dim QryStr
260
 
261
   DaemonInstructionPresent = FALSE
262
 
263
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") AND (NOT IsNull(nOpCode)) AND (nOpCode <> "") Then
264
 
265
      QryStr = "SELECT COUNT(*) AS record_count"&_
266
               "  FROM DAEMON_INSTRUCTIONS "&_
267
               " WHERE (OP_CODE = "& nOpCode &")"&_
268
               "   AND RTAG_ID = "& nRtag_id&_
269
               "   AND PV_ID = "& nPv_id
270
 
271
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
272
 
273
      If rsQry("record_count") <> 0 Then
274
        DaemonInstructionPresent = TRUE
275
      End If
276
 
277
      rsQry.Close
278
      Set rsQry = nothing
279
   End If
280
 
281
End Function
282
 
283
'------------------------------------------------------------------------------------------------------------------------------------------
153 ghuddy 284
Function DaemonInstructionPreventsReleaseDeletion(nRtag_id)
285
 
286
   Dim rsQry
287
   Dim QryStr
288
 
289
   DaemonInstructionPreventsReleaseDeletion = FALSE
290
 
291
   If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") Then
292
 
293
      QryStr = "SELECT COUNT(*) AS record_count"&_
294
               "  FROM DAEMON_INSTRUCTIONS "&_
295
               " WHERE RTAG_ID = "& nRtag_id
296
 
297
      Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )
298
 
299
      If rsQry("record_count") <> 0 Then
300
        DaemonInstructionPreventsReleaseDeletion = TRUE
301
      End If
302
 
303
      rsQry.Close
304
      Set rsQry = nothing
305
   End If
306
 
307
End Function
308
'------------------------------------------------------------------------------------------------------------------------------------------
309
Function UserCanAddOrEditThisDaemonInst(nProjId, nReleaseMode, nOpCode)
310
 
311
   UserCanAddOrEditThisDaemonInst = TRUE
312
 
313
   If objAccessControl.UserLogedIn Then
5061 dpurdie 314
      If NOT canActionInProject() Then
153 ghuddy 315
         UserCanAddOrEditThisDaemonInst = False
316
      ElseIf (( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) AND (nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) ) Then
5061 dpurdie 317
         If NOT canActionControlInProject("ApproveForAutoBuild") Then
153 ghuddy 318
            UserCanAddOrEditThisDaemonInst = False
319
         End If
320
      End If
321
   Else
322
      UserCanAddOrEditThisDaemonInst = False
323
   End If
5061 dpurdie 324
 
153 ghuddy 325
End Function
326
'------------------------------------------------------------------------------------------------------------------------------------------
147 ghuddy 327
%>