<% '===================================================== ' Common Subs for DAEMON INSTRUCTIONS ' ' NB. Must be included AFTER conf.asp '===================================================== %> <% '-------------------------------------------------------------------------------------------- ' Indicates if the specified daemon instruction is in progress '-------------------------------------------------------------------------------------------- Function DaemonInstructionInProgress( nInstId ) Dim rsQry DaemonInstructionInProgress = False If NOT IsNull(nInstId) AND nInstId <> "" Then Set rsQry = OraDatabase.DbCreateDynaset( "SELECT IN_PROGRESS"&_ " FROM DAEMON_INSTRUCTIONS "&_ " WHERE DAEMON_INSTRUCTIONS_ID = "& nInstId, ORADYN_DEFAULT ) If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then If (NOT IsNull(rsQry("IN_PROGRESS"))) AND (rsQry("IN_PROGRESS") = "1") Then DaemonInstructionInProgress = True End If End If rsQry.Close Set rsQry = nothing End If End Function '-------------------------------------------------------------------------------------------- ' Assign the inout parameter to an array containing the list of all human readable op-code ' strings, in ascending op-code value order. This list will be used to form a drop-down list ' control on an html form '-------------------------------------------------------------------------------------------- Sub GetDaemonInstructionOperationNameArray(nArray) ' append new op-codes to this list when they are invented nArray = array(OP_CODE_0_STR, _ OP_CODE_1_STR) End Sub '-------------------------------------------------------------------------------------------- ' Convert a Daemon Instruction operation code into a meaningful string ' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer ' for doing so. '-------------------------------------------------------------------------------------------- Function DaemonInstructionOperationName(nOpCode) Select Case nOpCode Case OP_CODE_0_RIPPLE_BUILD_PACKAGE DaemonInstructionOperationName = OP_CODE_0_STR Case OP_CODE_1_TEST_BUILD_PACKAGE DaemonInstructionOperationName = OP_CODE_1_STR Case Else DaemonInstructionOperationName = "Undefined (" & nOpCode & ")" End Select End Function '-------------------------------------------------------------------------------------------- ' Convert a Daemon Instruction operation name into an op-code value ' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer ' for doing so. '-------------------------------------------------------------------------------------------- Function DaemonInstructionOperationValue(nOpName) Select Case nOpName Case OP_CODE_0_STR DaemonInstructionOperationValue = OP_CODE_0_RIPPLE_BUILD_PACKAGE Case OP_CODE_1_STR DaemonInstructionOperationValue = OP_CODE_1_TEST_BUILD_PACKAGE Case Else DaemonInstructionOperationValue = "" End Select End Function '-------------------------------------------------------------------------------------------- ' Determines if a daemon instruction op-code value indicates that a PV_ID is required to be ' specified for the instruction. '-------------------------------------------------------------------------------------------- Function DaemonInstructionNeedsPV_ID(nOpCode) Select Case nOpCode Case OP_CODE_0_RIPPLE_BUILD_PACKAGE DaemonInstructionNeedsPV_ID = True Case OP_CODE_1_TEST_BUILD_PACKAGE DaemonInstructionNeedsPV_ID = True Case Else DaemonInstructionNeedsPV_ID = False End Select End Function '-------------------------------------------------------------------------------------------- ' Determines if a daemon instruction op-code value indicates that a repeat value is required ' to be specified for the instruction. '-------------------------------------------------------------------------------------------- Function DaemonInstructionNeedsRepeat(nOpCode) ' currently - no op-codes need a repeat value DaemonInstructionNeedsRepeat = False End Function '-------------------------------------------------------------------------------------------- ' Convert a Repeat Seconds value into a meaningful string. This takes account of the ' daemon instruction op-code too - a repeat seconds value is only relevant for certain ' op-codes '-------------------------------------------------------------------------------------------- Function DaemonInstructionRepeatString(nOpCode, nRepeatSecs) DaemonInstructionRepeatString = "N/A" ' uncomment this when we are ready to introduce the "get release metrics" instruction 'Select Case nOpCode 'Case OP_CODE_?_GET_RELEASE_METRICS ' Select Case nRepeatSecs ' Case 86400 ' DaemonInstructionRepeatString = "24Hrs" ' Case Else ' DaemonInstructionRepeatString = "NO" ' End Select ' 'Case Else ' DaemonInstructionRepeatString = "N/A" 'End Select End Function '-------------------------------------------------------------------------------------------- ' Queries the database to get a comma-seperated list of op-codes for a given release, and ' converts them into a comma seperated list of operation names for display purposes ' This is used in _package_common.asp to provide visual indication to RM users that daemon ' instructions for the release have been created. '-------------------------------------------------------------------------------------------- Function GetOpCodeListForRtagId( pretext, nRtag_id, posttext ) Dim opCodeListString Dim opCodeList Dim opCodeStr GetOpCodeListForRtagId = "" On Error Resume Next objEH.TryORA ( OraSession ) OraDatabase.Parameters.Add "OP_CODE_LIST", NULL, ORAPARM_OUTPUT, ORATYPE_VARCHAR2 OraDatabase.ExecuteSQL _ "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag("& nRtag_id & "); END;" objEH.CatchORA ( OraSession ) opCodeListString = OraDatabase.Parameters("OP_CODE_LIST").Value OraDatabase.Parameters.Remove "OP_CODE_LIST" If NOT IsNull(opCodeListString) AND opCodeListString <> "" Then opCodeList = Split(opCodeListString, ",") For Each opCodeStr In opCodeList If NOT IsNull(opCodeStr) AND opCodeStr <> "" Then GetOpCodeListForRtagId = GetOpCodeListForRtagId + DaemonInstructionOperationName(opCodeStr) End If Next End If If GetOpCodeListForRtagId <> "" Then GetOpCodeListForRtagId = pretext & GetOpCodeListForRtagId + posttext End If End Function '-------------------------------------------------------------------------------------------- ' Queries the database to get a comma-seperated list of op-codes for a given release and package ' version, and converts them into a comma seperated list of operation names for display purposes ' This is used in _package_common.asp to provide visual indication to RM users that daemon ' instructions for the release and package version have been created. '-------------------------------------------------------------------------------------------- Function GetOpCodeListForRtagIdAndPvId( pretext, nRtag_id, nPv_id, posttext ) Dim opCodeListString Dim opCodeList Dim opCodeStr GetOpCodeListForRtagIdAndPvId = "" On Error Resume Next If (NOT IsNull(nRtag_id)) AND nRtag_id <> "" Then objEH.TryORA ( OraSession ) OraDatabase.Parameters.Add "OP_CODE_LIST", NULL, ORAPARM_OUTPUT, ORATYPE_VARCHAR2 If (NOT IsNull(nPv_id)) AND nPv_id <> "" Then OraDatabase.ExecuteSQL _ "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag_pvid("& nRtag_id & "," & nPv_id & "); END;" Else OraDatabase.ExecuteSQL _ "BEGIN :OP_CODE_LIST := PK_BUILDAPI.daemon_ops_for_rtag("& nRtag_id & "); END;" End If objEH.CatchORA ( OraSession ) opCodeListString = OraDatabase.Parameters("OP_CODE_LIST").Value OraDatabase.Parameters.Remove "OP_CODE_LIST" If NOT IsNull(opCodeListString) AND opCodeListString <> "" Then opCodeList = Split(opCodeListString, ",") For Each opCodeStr In opCodeList If NOT IsNull(opCodeStr) AND opCodeStr <> "" Then GetOpCodeListForRtagIdAndPvId = GetOpCodeListForRtagIdAndPvId + DaemonInstructionOperationName(opCodeStr) End If Next End If End If If GetOpCodeListForRtagIdAndPvId <> "" Then GetOpCodeListForRtagIdAndPvId = pretext & GetOpCodeListForRtagIdAndPvId + posttext End If End Function '-------------------------------------------------------------------------------------------- ' Function to inform caller of whether the user is allowed to reset the daemon instructions ' in-progress flag '-------------------------------------------------------------------------------------------- Function UserAllowedToResetInProgress UserAllowedToResetInProgress = True If objAccessControl.UserLogedIn Then If NOT objAccessControl.IsActive("ResetDaemonInstInProgress") Then UserAllowedToResetInProgress = False End If Else UserAllowedToResetInProgress = False End If End Function '-------------------------------------------------------------------------------------------- ' Daemon Instruction validation function '-------------------------------------------------------------------------------------------- Function HandleValidateDaemonInstructionError(nOpCode, retERRmsg, ByRef sErrorMsg) Dim s s = "" HandleValidateDaemonInstructionError = True If NOT IsNull(retERRmsg) Then ' Exclusions - ' 1) Ignore "unit tests not supplied" error for ripple build package daemon instruction If NOT ((nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) AND (retERRmsg = "enum_MSG_UNIT_TESTS_NOT_SUPPLIED")) Then ' Re-interpret the error message that has been returned from the queries. We do this because normally, ' these errors are associated with individual message files but the messsages in those files are slightly ' inappropriate for the context of adding a daemon instruction so we will provide our own message display ' using the generic enum_WMSG_ERROR file with a bespoke error string. Select Case retERRmsg Case "enum_MSG_MISSING_DEPENDENCIES" s = "Some dependencies of this package are missing from a release." Case "enum_MSG_PACKAGE_INFORMATION_INCOMPLETE" s = "Package information section on Release Notes tab is not fully complete." Case "enum_MSG_AUTOBUILD_PACKAGE_REQUIRES_BUILD_STD_AND_ENV" s = "Package must have a build standard and build environment." Case "enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED" s = "A reason for this version must be supplied." Case "enum_MSG_UNIT_TESTS_NOT_SUPPLIED" s = "There are no unit tests supplied for this package." Case "enum_MSG_PACKAGE_CHANGETYPE_INCOMPLETE" s = "Package change type in Release Notes Tab is not defined." Case "enum_MSG_BROKEN_DEPENDENCIES_FOUND" s = "Some of the packages dependencies are broken. Fix them first before trying to add a daemon instruction to this package." Case "enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND" s = "Some dependencies of this package are still not released. Release them first before trying to add a daemon instruction to this package." Case Else s = "Correct any errors in the release notes, and try again." End Select sErrorMsg = "Cannot add this daemon instruction

" & s HandleValidateDaemonInstructionError = False End If End If End Function Function ValidateDaemonInstruction(nOpCode, nRtag_id, nPv_id) Dim retERRmsg Dim retALRTmsg Dim retParameters Dim pkgType Dim s Dim sErrorMsg s = "" pkgType = 0 ValidateDaemonInstruction = True Select Case nOpCode Case OP_CODE_0_RIPPLE_BUILD_PACKAGE ' Note: cannot use CheckRequirementsForMakeApproved here because it fails on the change_type check. This seems ' to be because a daemon ripple build results in a new package version that has null in the change_type column ' so we cannot validate that column in the package_versions table. ' check missing dependencies, bad package info, missing build std/env, reason for version, unit test Call CheckRequirementsForMakePending ( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters ) If IsNull(retERRmsg) Then ' Check broken dependencies, missing dependencies, unofficial dependencies, bad package info, reason for version, unit test Call CheckRequirementsForMakeRelease( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters ) End If ValidateDaemonInstruction = HandleValidateDaemonInstructionError(nOpCode,retERRmsg,sErrorMsg) If Not ValidateDaemonInstruction Then Call RaiseMsg(enum_MSG_ERROR, sErrorMsg) End If Case OP_CODE_1_TEST_BUILD_PACKAGE ValidateDaemonInstruction = True ' no validation checks for this instruction Case Else Call RaiseMsg(enum_MSG_ERROR, "Attempt to add an unknown daemon instruction") ValidateDaemonInstruction = False End Select End Function '------------------------------------------------------------------------------------------------------------------------------------------ Function DaemonInstructionPreventsEditing(nRtag_id, nPv_id) Dim rsQry Dim QryStr DaemonInstructionPreventsEditing = FALSE If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") Then QryStr = "SELECT COUNT(*) AS record_count"&_ " FROM DAEMON_INSTRUCTIONS "&_ " WHERE (OP_CODE = "& OP_CODE_1_TEST_BUILD_PACKAGE &")"&_ " AND RTAG_ID = "& nRtag_id&_ " AND PV_ID = "& nPv_id Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT ) If rsQry("record_count") <> 0 Then DaemonInstructionPreventsEditing = TRUE End If rsQry.Close Set rsQry = nothing End If End Function '------------------------------------------------------------------------------------------------------------------------------------------ Function DaemonInstructionPreventsReleaseDeletion(nRtag_id) Dim rsQry Dim QryStr DaemonInstructionPreventsReleaseDeletion = FALSE If (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") Then QryStr = "SELECT COUNT(*) AS record_count"&_ " FROM DAEMON_INSTRUCTIONS "&_ " WHERE RTAG_ID = "& nRtag_id Set rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT ) If rsQry("record_count") <> 0 Then DaemonInstructionPreventsReleaseDeletion = TRUE End If rsQry.Close Set rsQry = nothing End If End Function '------------------------------------------------------------------------------------------------------------------------------------------ Function UserCanAddOrEditThisDaemonInst(nProjId, nReleaseMode, nOpCode) UserCanAddOrEditThisDaemonInst = TRUE If objAccessControl.UserLogedIn Then If NOT objAccessControl.IsDataActive ("PROJECTS", nProjId, "EditProjects") OR NOT objAccessControl.IsDataVisible ("PROJECTS", nProjId, "EditProjects") Then UserCanAddOrEditThisDaemonInst = False ElseIf NOT objAccessControl.IsDataActive ("PROJECTS", nProjId, enumDB_PERMISSION_TYPE_ACTIVE) Then UserCanAddOrEditThisDaemonInst = False ElseIf (( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) AND (nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) ) Then If NOT objAccessControl.IsActive("ApproveForAutoBuild") Then UserCanAddOrEditThisDaemonInst = False End If End If Else UserCanAddOrEditThisDaemonInst = False End If End Function '------------------------------------------------------------------------------------------------------------------------------------------ %>