%@LANGUAGE="VBSCRIPT"%> <% Option explicit Response.Expires = 0 ' always load the page, dont store %> <% '===================================================== ' Package Information '===================================================== %> <% ' Set rfile parameter. This is a return page after Login Call objPMod.StoreParameter ( "rfile", "fixed_issues.asp" ) '------------ ACCESS CONTROL ------------------ %> <% '------------ Variable Definition ------------- Dim parPv_id Dim query Dim rsQry, rsTemp Dim checked Dim FRdeployableYES, FRdeployableNO Dim objFormCollector Dim pageIsEditable, criticalSectionIsEditable Dim disableCriticalSectionEdit Dim Query_String Dim parVCSTag Dim parBSName Dim submit_action_url Dim on_submit_validation Dim sDefaultLabel, sLabel, sLabelReadOnly Dim isWIP '------------ Constants Declaration ----------- '------------ Variable Init ------------------- Set objFormCollector = CreateObject("Scripting.Dictionary") parPv_id = QStrPar("pv_id") parVCSTag = QStrPar("vcs_tag") parBSName = QStrPar("bs_name") '---------------------------------------------- %> <% Sub MessageBox_BM_Exclusivity() %> <% End Sub Sub MessageBox_RequiredFieldsEmpty() %> <% End Sub Sub MessageBox_Need_A_BuildStandard() %> <% End Sub '---------------------------------------------------------------------------------------------------------------------- ' Function to get the build standard name (eg. JATS) from a build standard ID Function bs_name_from_bs_id( nBs_Id ) Dim rsTemp, Query_String bs_name_from_bs_id = "NONE" If NOT IsNull(nBs_Id) Then Query_String = " SELECT * FROM build_standards WHERE bs_id = "& nBs_Id Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then bs_name_from_bs_id = rsTemp("bs_name") End If End If End Function '---------------------------------------------------------------------------------------------------------------------- ' Function to get the build standard ID from a build standard name (eg. JATS) Function bs_id_from_bs_name( nBs_Name ) Dim rsTemp, Query_String bs_id_from_bs_name = 0 Query_String = " SELECT * FROM build_standards WHERE bs_name = '"& nBs_Name &"'" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then bs_id_from_bs_name = rsTemp("bs_id") End If End Function '---------------------------------------------------------------------------------------------------------------------- ' Function to get the Version Control System type ID for ClearCase, based on the assumption that the TAG used for ' ClearCase is 'CC' 'Function get_clearcase_vcs_type_id() ' Dim rsTemp, Query_String ' ' Query_String = _ ' " SELECT * FROM VCS_TYPE WHERE tag = 'CC'" ' ' Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) ' If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then ' get_clearcase_vcs_type_id = rsTemp("vcs_type_id") ' Else ' Call RaiseMsg(enum_MSG_ERROR, "Database is missing a VCS setting for Name: ClearCase, Tag: CC") ' End If ' rsTemp.Close ' Set rsTemp = nothing 'End Function '---------------------------------------------------------------------------------------------------------------------- ' Function to get the Version Control System type ID for Subversion, based on the assumption that the TAG used for ' Subversion is 'SVN' Function get_subversion_vcs_type_id() Dim rsTemp, Query_String Query_String = _ " SELECT * FROM VCS_TYPE WHERE tag = 'SVN'" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then get_subversion_vcs_type_id = rsTemp("vcs_type_id") Else Call RaiseMsg(enum_MSG_ERROR, "Database is missing a VCS setting for Name: Subversion, Tag: SVN") End If rsTemp.Close Set rsTemp = nothing End Function '---------------------------------------------------------------------------------------------------------------------- ' Function to get the Version Control System type ID for Uncontrolled, based on the assumption that the TAG used for ' ClearCase is 'UC' Function get_uncontrolled_vcs_type_id() Dim rsTemp, Query_String Query_String = _ " SELECT * FROM VCS_TYPE WHERE tag = 'UC'" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then get_uncontrolled_vcs_type_id = rsTemp("vcs_type_id") Else Call RaiseMsg(enum_MSG_ERROR, "Database is missing a VCS setting for Name: Uncontrolled, Tag: UC") End If rsTemp.Close Set rsTemp = nothing End Function '---------------------------------------------------------------------------------------------------------------------- Sub Get_Form_Details( nPv_id, ByRef objDetails ) Dim rsTemp, Query_String ' Dim CC_vcs_type_id Dim SVN_vcs_type_id Dim UC_vcs_type_id ' Get VCS type IDs to use when evaluating legacy rows created before the introduction of the VCS tables and logic. ' These get uses in the query (see below) in the CASE statement. ' CC_vcs_type_id = get_clearcase_vcs_type_id() SVN_vcs_type_id = get_subversion_vcs_type_id UC_vcs_type_id = get_uncontrolled_vcs_type_id() Query_String = _ " SELECT pkg.pkg_name, pv.pkg_version, pv.pkg_label, pv.src_path, pv.pv_description,"&_ " pv.pv_overview, pv.v_ext, is_deployable, is_build_env_required, pv.build_type,"&_ " pv.bs_id, pv.dlocked,"&_ " (CASE WHEN pkg_label = 'N/A' AND pv.vcs_type_id IS NULL THEN "& UC_vcs_type_id &_ " WHEN pv.vcs_type_id IS NULL THEN " & SVN_vcs_type_id &_ " ELSE pv.vcs_type_id END) AS vcs_type_id "&_ " FROM package_versions pv, packages pkg"&_ " WHERE pv.pkg_id = pkg.pkg_id"&_ " AND pv_id = "& nPv_id Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If (NOT rsTemp.BOF ) AND (NOT rsTemp.EOF) Then objDetails.Item("pkg_name") = rsTemp("pkg_name") objDetails.Item("pkg_version") = rsTemp("pkg_version") objDetails.Item("pkg_label") = rsTemp("pkg_label") objDetails.Item("src_path") = rsTemp("src_path") objDetails.Item("pv_description") = rsTemp("pv_description") objDetails.Item("pv_overview") = rsTemp("pv_overview") objDetails.Item("v_ext") = rsTemp("v_ext") objDetails.Item("is_deployable") = rsTemp("is_deployable") objDetails.Item("is_build_env_required") = rsTemp("is_build_env_required") objDetails.Item("build_type") = rsTemp("build_type") objDetails.Item("bs_id") = rsTemp("bs_id") objDetails.Item("dlocked") = rsTemp("dlocked") objDetails.Item("vcs_type_id") = rsTemp("vcs_type_id") rsTemp.Close ' This code allows the form to be altered by the user from the original build std configuration to a new ' one without having to update the database - we only want to do that when the user hits the ' submit button. The relevant fields in the objDetails are obtained in different ways accordingly. If IsNull(parBSName) OR parBSName = "" Then objDetails.Item("bs_name") = bs_name_from_bs_id( objDetails.Item("bs_id") ) Else objDetails.Item("bs_id") = bs_id_from_bs_name( parBSName ) objDetails.Item("bs_name") = parBSName End If ' Re-evaluate the is_build_env_required flag setting based on the possibly updated bs_name If UCase(objDetails.Item("bs_name")) = "NONE" Then objDetails.Item("is_build_env_required") = "N" Else objDetails.Item("is_build_env_required") = "Y" End If ' This code allows the form to be altered by the user from the original VCS configuration to a new ' one without having to update the database - we only want to do that when the user hits the ' submit button. The relevant fields in the objDetails are obtained in different ways accordingly. If IsNull(parVCSTag) OR parVCSTag = "" Then call vcs_info_from_vcs_type_id( objDetails.Item("vcs_type_id"), objDetails ) Else call vcs_info_from_vcs_tag( parVCSTag, objDetails ) End If End If rsTemp.Close Set rsTemp = Nothing End Sub '---------------------------------------------------------------------------------------------------------------------- ' Updates the database, specifically the is_build_env_required flag setting in the package_versions table ' The update is only performed if it is needed, ie. if the value is already correct, no update is needed. Sub UpdateIsBuildEnvRequired( nPv_id, nBs_name ) Dim rsTemp, Query_String Query_String = _ " SELECT bs_id, is_build_env_required"&_ " FROM package_versions"&_ " WHERE pv_id = "& nPv_id Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0)) If (UCase(nBs_name) = "NONE") AND (IsNull(rsTemp("is_build_env_required")) OR (rsTemp("is_build_env_required") <> "N")) Then rsTemp.Edit rsTemp.Fields("bs_id").Value = rsTemp("bs_id") rsTemp.Fields("is_build_env_required").Value = "N" rsTemp.Update ElseIf (UCase(nBs_name) <> "NONE") AND (IsNull(rsTemp("is_build_env_required")) OR (rsTemp("is_build_env_required") <> "Y")) Then rsTemp.Edit rsTemp.Fields("bs_id").Value = rsTemp("bs_id") rsTemp.Fields("is_build_env_required").Value = "Y" rsTemp.Update End If rsTemp.Close Set rsTemp = nothing End Sub '---------------------------------------------------------------------------------------------------------------------- ' Deletes the rows belonging to the current PV_ID, from the package_build_info table. ' This is normally done in preparation for updating the package_build_info table based on the latest ' (and possibly updated) build standard for the current PV_ID. Sub DeletePackageBuildInfo( nPv_id ) On Error Resume Next objEH.TryORA ( OraSession ) OraDatabase.ExecuteSQL _ "DELETE FROM PACKAGE_BUILD_INFO WHERE PV_ID ="& nPv_id objEH.CatchORA ( OraSession ) End Sub '---------------------------------------------------------------------------------------------------------------------- ' Updates the vcs_type_id column for the current PV_ID, in the package_versions table. ' The update is only performed if it is necessary, ie. the user has changed the setting via the form, or the existing ' value is not yet assigned. Sub UpdateVCS ( nPv_id, nVcs_type_id, nVcs_name, nVcs_tag ) Dim rsTemp, Query_String Dim new_bs_id Query_String = _ " SELECT vcs_type_id"&_ " FROM package_versions"&_ " WHERE pv_id = "& nPv_id Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0)) ' compare new bs_id to existing bs_id to see if a change has been requested If nVcs_type_id <> rsTemp("vcs_type_id") OR IsNull(rsTemp("vcs_type_id")) Then 'update fields rsTemp.Edit rsTemp.Fields("vcs_type_id").Value = nVcs_type_id rsTemp.Update Call Log_Action ( nPv_id, "vcs_type_id_update", "VCS Type ID Update: " & nVcs_name ) End If rsTemp.Close Set rsTemp = nothing End Sub '---------------------------------------------------------------------------------------------------------------------- ' Updates the bs_id column value for the current PV_ID in the package_versions table. ' The update is only performed if it is necessary, ie. the user has changed the setting via the form, or the existing ' value is not yet assigned. Sub UpdateBuildStandard ( nPv_id, nBs_name ) Dim rsTemp, Query_String Dim new_bs_id ' get the new bs_id from the bs_name parameter new_bs_id = bs_id_from_bs_name(nBs_name) Query_String = _ " SELECT bs_id, is_build_env_required"&_ " FROM package_versions"&_ " WHERE pv_id = "& nPv_id Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0)) ' compare new bs_id to existing bs_id to see if a change has been requested If new_bs_id <> rsTemp("bs_id") OR IsNull(rsTemp("bs_id")) Then 'update fields rsTemp.Edit rsTemp.Fields("bs_id").Value = new_bs_id If UCase(nBs_name) = "NONE" Then rsTemp.Fields("is_build_env_required").Value = "N" Else rsTemp.Fields("is_build_env_required").Value = "Y" End If rsTemp.Update ' Clear out the build info table of entries for this PV_ID. Call DeletePackageBuildInfo(nPv_id) Call Log_Action ( nPv_id, "build_standard_update", "Build Standard Update: " & nBs_name ) End If rsTemp.Close Set rsTemp = nothing End Sub '---------------------------------------------------------------------------------------------------------------------- ' Updates the package_build_info table for the current PV_ID, based on the latest build_standard settings made ' by the user on the form Sub UpdatePackageBuildInfo( NNpv_id ) '--- Set Build Types --- Dim aBuildEnvList Dim OraParameter Dim nBuildMachine ' Before doing inserts for this PV_ID into the package_build_info table, we need to delete any existing ' rows for this PV_ID. This may have already been done if the user has changed the build standard, but ' there is no guarantee at this point that they have done that during this forms display. Call DeletePackageBuildInfo( NNpv_id ) OraDatabase.Parameters.Add "PV_ID", NNpv_id, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "BM_ID", 0, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "BSA_ID", 0, ORAPARM_INPUT, ORATYPE_NUMBER Set OraParameter = OraDatabase.Parameters aBuildEnvList = Split( Replace( Request("be_id_list"), " ", "" ) , ",") On Error Resume Next objEH.TryORA ( OraSession ) For Each nBuildMachine In aBuildEnvList OraParameter("BM_ID").Value = nBuildMachine OraParameter("BSA_ID").Value = Request("build_type_comb_"& nBuildMachine) If Err.Number = 0 Then OraDatabase.ExecuteSQL("begin INSERT INTO PACKAGE_BUILD_INFO ( PV_ID, BM_ID, BSA_ID ) "&_ " VALUES( :PV_ID, :BM_ID, :BSA_ID ); end;") End If Next objEH.CatchORA ( OraSession ) OraDatabase.Parameters.Remove "PV_ID" OraDatabase.Parameters.Remove "BM_ID" OraDatabase.Parameters.Remove "BSA_ID" End Sub '---------------------------------------------------------------------------------------------------------------------- ' This is the overall database update function called when the user hits the submit button on the form. ' It does some minor updates itself, but most of the work is done in subroutines. ' No attempt is made to keep the entire set of updates atomic. There really is no need to do that. Sub Update_Pkg_Info ( NNpv_id, NNdeployable, SSLabel, SSPath, SSdesc, SSoverview ) Dim rsTemp, Query_String On Error Resume Next Query_String = _ " SELECT pkg_label, src_path, pv_description, pv_overview, is_deployable "&_ " FROM package_versions"&_ " WHERE pv_id = "& NNpv_id If SSdesc = "" Then SSdesc = NULL Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0)) rsTemp.Edit ' Only update build critical sections (label, source path) if allowed If criticalSectionIsEditable Then rsTemp.Fields("pkg_label").Value = SSLabel rsTemp.Fields("src_path").Value = SSPath End If ' Update non-build critical sections rsTemp.Fields("pv_description").Value = SSdesc rsTemp.Fields("pv_overview").Value = SSoverview If NNdeployable = "1" Then rsTemp.Fields("is_deployable").Value = "Y" Else rsTemp.Fields("is_deployable").Value = NULL End If rsTemp.Update rsTemp.Close Set rsTemp = nothing ' Only update build critical sections if allowed If criticalSectionIsEditable Then ' Update the VCS if necessary for this PV_ID Call UpdateVCS( NNpv_id, objFormCollector.Item("vcs_type_id"), objFormCollector.Item("vcs_name"), objFormCollector.Item("vcs_tag") ) ' Update the build standard if necessary for this PV_ID Call UpdateBuildStandard( NNpv_id, objFormCollector.Item("bs_name") ) ' Update the 'is build_env_required' flag for this PV_ID Call UpdateIsBuildEnvRequired( NNpv_id, objFormCollector.Item("bs_name") ) ' Update the package_build_info table for this PV_ID Call UpdatePackageBuildInfo( NNpv_id ) End If End Sub '---------------------------------------------------------------------------------------------------------------------- Function ShowHideBuildType( sBuildEnvChecked ) ShowHideBuildType = "style='display:none;'" If (sBuildEnvChecked <> "") Then ShowHideBuildType = "style='display:block;'" End If End Function '---------------------------------------------------------------------------------------------------------------------- ' Renders the HTML for the build standard addendum drop down list boxes, ie. Prod, Debug, Prod+Debug, Java 1.4, Java 1.5, etc. Sub RenderBuildTypeCombo( nBuildAddendum, nBuildMachine, nBuildStandard ) Query_String = "SELECT * FROM build_standards_addendum WHERE bs_id ="& nBuildStandard & " ORDER BY bsa_id DESC" Response.Write "" rsTemp.Close() Set rsTemp = nothing End Sub '---------------------------------------------------------------------------------------------------------------------- ' Renders the HTML for the Version Control Settings drop down list box Sub RenderVCSCombo(nTag) If IsNull(nTag) OR nTag = "" Then nTag = enum_VCS_SUBVERSION_TAG End If Query_String = "SELECT * FROM vcs_type ORDER BY name" Response.Write "" ' Create a hidden combo containing tags instead of names - we can use this to get a tag for a name without ' doing a database query Response.Write "