%@LANGUAGE="VBSCRIPT"%> <% '===================================================== ' UPDATE dependencies ' _update_dependencies.asp ' --- PROCESS FORM --- '===================================================== %> <% Option explicit ' Good idea to set when using redirect Response.Expires = 0 ' always load the page, dont store %> <% ' Set rfile parameter. This is a return page after Login Call objPMod.StoreParameter ( "rfile", "dependencies.asp" ) '------------ ACCESS CONTROL ------------------ %> <% '------------ Variable Definition ------------- Dim depArray() Dim array_is_empty '------------ Constants Declaration ----------- Const enumlocal_DONOT_DELETE_OLD_DEPENDENCIES = 0 Const enumlocal_DELETE_OLD_DEPENDENCIES = 1 Const COL_pkg_name = 0 Const COL_pkg_version = 1 Const COL_build_type = 2 '------------ Variable Init ------------------- '---------------------------------------------- %> <% ' ' Populate from a form ' Assumes that items are seqentially numbered starting at 0 Sub Populate_depArray_from_Import ( ARRdep, BBarray_is_empty ) Dim recCnt, pkg_name, pkg_version, build_type recCnt=0 BBarray_is_empty = true Do While TRUE pkg_name = Request("btName" & recCnt) pkg_version = Request("pkgn" & recCnt) build_type = Request("bt" & recCnt) ' Proceed only if: ' pkg name is not empty, ' pkg version is not empty, If ( pkg_name <> "" ) AND ( pkg_version <> "" ) Then ReDim Preserve ARRdep( 2, recCnt ) ARRdep( COL_pkg_name, recCnt ) = pkg_name ARRdep( COL_pkg_version, recCnt ) = pkg_version ARRdep( COL_build_type, recCnt ) = build_type recCnt = recCnt + 1 BBarray_is_empty = FALSE Else Exit Do End If Loop End Sub ' This function is called when update_type is "add_custom". This is only the case when adding dependencies ' The list given via the actual parameter pkg_list is in fact a list of pv_id's supplied from the form_search_result_pkgs.asp ' and form_add_pkg_versions.asp files. In the past, it only ever used to be a list of package IDs, but this has now been ' changed so that users can only add package versions from the relevant release as dependencies to a packge also in that ' release, and to do this, the list has to hold pv_id's instead of pkg_id's, to cater for situations where a release ' contains 2 instances of a package, each one having different extensions (eg .mas, .sea). Sub Populate_depArray_from_ADD_Custom ( NNpv_id_list, ARRdep, BBarray_is_empty ) Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT Dim rsTemp, Query_String, PkgBaseView PkgBaseView = Get_Pkg_Base_View_ID ( Request("pv_id"), Request("rtag_id") ) Query_String = _ " SELECT pkgs.pkg_id, pkgs.pkg_name, pv.pv_id, pv.pkg_version"&_ " FROM packages pkgs, package_versions pv"&_ " WHERE pv.pv_id IN ("& NNpv_id_list &")"&_ " AND pv.pkg_id = pkgs.pkg_id" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) recCnt = 0 While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) ReDim Preserve ARRdep( 2, recCnt ) ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name") ARRdep( COL_pkg_version, recCnt ) = rsTemp("pkg_version") '// Dependencies comming from custom dependency add are set to LinkPkgArchive by default, unless it is a product If PkgBaseView = enumBASE_VIEW_PRODUCTS Then ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE Else ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE End If recCnt = recCnt + 1 BBarray_is_empty = FALSE rsTemp.MoveNext WEnd rsTemp.Close Set rsTemp = nothing End Sub Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock ) Dim i, OraParameter, sComments OraDatabase.Parameters.Add "PV_ID", NNpv_id, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "PKG_NAME", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "PKG_VERSION", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "BUILD_TYPE", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "USER_ID", NNuser_id, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "DELETE_PV_ID", NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type, ORAPARM_INPUT, ORATYPE_VARCHAR2 Set OraParameter = OraDatabase.Parameters For i = 0 To UBound( ARRdep, 2 ) If not i = 0 Then sComments = sComments & ", " End If sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i ) OraParameter("PKG_NAME").Value = ARRdep( COL_pkg_name, i ) OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i ) OraParameter("BUILD_TYPE").Value = ARRdep( COL_build_type, i ) OraDatabase.ExecuteSQL "BEGIN Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID ); END;" Next Set OraParameter = Nothing If sAction_type = "depend_add" Then OraDatabase.Parameters.Add "COMMENTS", sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2 Else If Len(sDependBlock) <= 4000 Then OraDatabase.Parameters.Add "COMMENTS", sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2 Else OraDatabase.Parameters.Add "COMMENTS", "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2 End If End If OraDatabase.ExecuteSQL _ "BEGIN Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS ); END;" OraDatabase.Parameters.Remove "PV_ID" OraDatabase.Parameters.Remove "PKG_NAME" OraDatabase.Parameters.Remove "PKG_VERSION" OraDatabase.Parameters.Remove "BUILD_TYPE" OraDatabase.Parameters.Remove "USER_ID" OraDatabase.Parameters.Remove "DELETE_PV_ID" OraDatabase.Parameters.Remove "ACTION_TYPE_NAME" OraDatabase.Parameters.Remove "COMMENTS" End Sub Sub Remove_Old_Dependencies ( SSpv_id ) OraDatabase.Parameters.Add "PV_ID", SSpv_id, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID" OraDatabase.Parameters.Remove "PV_ID" End Sub Sub Update_Mod_Details ( SSpv_id ) OraDatabase.Parameters.Add "PV_ID", SSpv_id, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"), ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.ExecuteSQL _ " UPDATE package_versions "&_ " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_ " WHERE pv_id = :PV_ID" If Request("rtag_id") <> "" Then ' Package in release view OraDatabase.ExecuteSQL _ "BEGIN "&_ " Touch_Release ( :RTAG_ID ); "&_ "END; " Else ' Package view OraDatabase.ExecuteSQL _ "BEGIN "&_ " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_ "END; " End If OraDatabase.Parameters.Remove "PV_ID" OraDatabase.Parameters.Remove "RTAG_ID" OraDatabase.Parameters.Remove "USER_ID" End Sub %> <% '----------------------- MAIN LINE --------------------------- 'Response.Write "
------------
" 'Dim Item 'For Each Item In Request.Form ' Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "
" 'Next 'Response.Write "------------
" Dim sDependBlock '--- Process submition --- If (QStrPar("pv_id") <> "") Then ' All mandatory parameters FOUND Err.Clear On Error Resume Next OraSession.BeginTrans ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might ' be the result of some problem in the database, further database commands are not performed, achieved by making them ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback array_is_empty = TRUE If Request("update_type") = "add_custom" Then '---- ADD CUSTOM dependency ---- ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation ' (see form_search_pkgs.asp and form_search_result_pkgs.asp) returns a list called "pkg_list", it actually contains a pv_id list in these ' special cases. Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty ) If ((NOT array_is_empty) AND (Err.number = 0)) Then Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null ) End If ElseIf Request("update_type") = "edit_import" Then '-- JATS,ANT dependency import after being edited Call Populate_depArray_from_Import ( depArray, array_is_empty ) Call Remove_Old_Dependencies ( Request("pv_id") ) If ((NOT array_is_empty) AND (Err.number = 0)) Then Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") ) End If Else '---- Unknown input type Response.write "Internal error. Unknown update_type!" & "
" 'TODO Err.number = 1 End If If Err.number = 0 Then Call Update_Mod_Details ( Request("pv_id") ) End If If Err.number <> 0 Then OraSession.RollBack Call RaiseMsg ( enum_MSG_ERROR, Err.description &"
"& Err.Source ) Else OraSession.CommitTrans End If Call Destroy_All_Objects Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id")) Else Response.write "Some mandatory parameters are missing!" & "
" 'TODO Response.write QSTR_FullQuery End If %>