<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== '| | '| ADD | '| PACKAGES | '| OR DEPENDENCIES | '===================================================== %> <% Option explicit ' Good idea to set when using redirect Response.Expires = 0 ' always load the page, dont store %> <% '------------ ACCESS CONTROL ------------------ %> <% ' Make sure rtag_id is always present If Request("pv_id") = "" AND Request("rtag_id") = "" Then Call Destroy_All_Objects Response.Redirect("index.asp") End If %> <% '------------ Variable Definition ------------- Dim parAdd_type Dim parPkg_list Dim parBase_view_id Dim rsPkgs Dim HTML_pkg_list Dim parPv_id Dim parPkgfind '------------ Constants Declaration ----------- '------------ Variable Init ------------------- parAdd_type = Request("add_type") parPkg_list = Request("pkg_list") parBase_view_id = Request("base_view_id") parPv_id = Request("pv_id") parPkgfind = Request("pkgfind") Set pkgInfoHash = CreateObject("Scripting.Dictionary") '---------------------------------------------- %> <% ' ---- Action requirements ---- If parPkg_list = "" Then Call Destroy_All_Objects Response.Redirect( "form_search_result_pkgs.asp?pv_id="& parPv_id &_ "&rtag_id="& parRtag_id &_ "&pkgfind="& parPkgfind &_ "&add_type="& parAdd_type &_ "&errmsg=true" ) End If %> <% Function Page_Title ( NNadd_type ) If NNadd_type = Cstr(enum_ADD_PACKAGES) Then Page_Title = "ADD Package" ElseIf NNadd_type = Cstr(enum_ADD_DEPENDENCIES) Then Page_Title = "ADD Dependency" ElseIf NNadd_type = Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then Page_Title = "ADD Runtime Dependency" Else Page_Title = "" End If End Function ' Gets a set of records each one being unique by pkg_id, each row having (pkg_id, pkg_name, and num_of_versions) Function Get_Pkg_Names ( NNpkg_or_pvid_list, NNadd_type ) If NNadd_type = Cstr(enum_ADD_DEPENDENCIES) OR NNadd_type = Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then ' When adding dependencies, the NNpkg_or_pvid_list is a list of PV_ID's Get_Pkg_Names = _ " SELECT pkg.PKG_ID, pkg.PKG_NAME, COUNT(pv.PV_ID) AS NUM_OF_VERSIONS "&_ " FROM PACKAGE_VERSIONS pv,"&_ " PACKAGES pkg"&_ " WHERE pv.PV_ID IN ( "& NNpkg_or_pvid_list &" ) "&_ " AND pv.PKG_ID (+) = pkg.PKG_ID"&_ " GROUP BY pv.PKG_ID, pkg.PKG_ID, pkg.PKG_NAME" Else ' When adding packages, the NNpkg_or_pvid_list is a list of PKG_ID's Get_Pkg_Names = _ " SELECT pkg.PKG_ID, pkg.PKG_NAME, COUNT(pv.PV_ID) AS NUM_OF_VERSIONS "&_ " FROM PACKAGE_VERSIONS pv,"&_ " PACKAGES pkg"&_ " WHERE pkg.PKG_ID IN ( "& NNpkg_or_pvid_list &" ) "&_ " AND pv.PKG_ID (+) = pkg.PKG_ID"&_ " GROUP BY pv.PKG_ID, pkg.PKG_ID, pkg.PKG_NAME" End If End Function Sub Get_All_Base_Views ( NNnewgroup_id, nPkg_id ) Dim rsTemp, Query_String Query_String = _ " SELECT vi.view_id, vi.view_name, bv.hint "&_ " FROM views vi,"&_ " ("&_ " SELECT DISTINCT rc.BASE_VIEW_ID, '> ' AS hint"&_ " FROM release_content rc,"&_ " package_versions pv"&_ " WHERE rc.pv_id = pv.pv_id"&_ " AND pv.pkg_id IN ( "& nPkg_id &" )"&_ " ) bv"&_ " WHERE UPPER(vi.base_view) = 'Y'"&_ " AND bv.BASE_VIEW_ID (+) = vi.VIEW_ID"&_ " ORDER BY vi.view_name ASC" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) If NNnewgroup_id = Cstr( rsTemp.Fields("view_id") ) OR NOT IsNull(rsTemp("hint")) Then Response.write "" Else Response.write "" End If rsTemp.MoveNext WEnd rsTemp.Close Set rsTemp = nothing End Sub Sub Get_All_Personal_Views ( NNuser_id ) Dim rsTemp, Query_String If NNuser_id = "" Then Exit Sub Query_String = _ " SELECT vi.view_id, vi.view_name"&_ " FROM view_settings vs,"&_ " views vi"&_ " WHERE vs.view_id = vi.view_id"&_ " AND vs.user_id = vi.owner_id "&_ " AND vs.user_id = "& NNuser_id &_ " AND vi.base_view = 'N'"&_ " ORDER BY UPPER(vi.view_name)" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Response.write "" rsTemp.MoveNext WEnd rsTemp.Close Set rsTemp = nothing End Sub ' This function is only called when adding dependencies. It gets all of the items in the specified release ' and sets up dictionaries as follows: ' ' Dict Name key item ' ------------------------------------ ' DDdictPkgId pv_id pkg_id ' DDdictPkgName pv_id pkg_name ' DDdictPkgVer pv_id pkg_version ' DDdictPkgExt pv_id v_ext ' Sub Get_Versions_From_Release ( NNpv_id_list, NNrtag_id, DDdictPkgId, DDdictPkgName, DDdictPkgVer, DDdictPkgExt ) Dim rsTemp, Query_String If NNrtag_id = "" Then Exit Sub End If Query_String = _ " SELECT pv.pkg_id, pkgs.pkg_name, pv.pkg_version, pv.pv_id, pv.v_ext"&_ " FROM release_content rc,"&_ " package_versions pv,"&_ " packages pkgs"&_ " WHERE rc.pv_id = pv.pv_id"&_ " AND pkgs.pkg_id = pv.pkg_id"&_ " AND rc.rtag_id = "& NNrtag_id &_ " AND pv.pv_id IN ( "& NNpv_id_list &" )" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) DDdictPkgId.ADD Cstr(rsTemp("pv_id")), Cstr(rsTemp("pkg_id")) DDdictPkgName.ADD Cstr(rsTemp("pv_id")), Cstr(rsTemp("pkg_name")) DDdictPkgVer.ADD Cstr(rsTemp("pv_id")), Cstr(rsTemp("pkg_version")) If NOT IsNull(rsTemp("v_ext")) Then DDdictPkgExt.ADD Cstr(rsTemp("pv_id")), Cstr(rsTemp("v_ext")) Else DDdictPkgExt.ADD Cstr(rsTemp("pv_id")), Cstr("") End If rsTemp.MoveNext WEnd rsTemp.Close Set rsTemp = nothing End Sub ' This function is used when adding packages to a release. The function processes a list of package ID's ' and forms the HTML to display for each item, the name, all available full versions in a list box Sub Generate_Package_List ( NNpkg_list, SShtml_pkg_list, NNrtag_id, NNadd_type ) Dim rsPkgs, hidePatches, currRsPkg, qparPkg_list Dim spanPkgNameId Dim commonHTML hidePatches = "hidepatches=true&" If pkgInfoHash.Item ("is_patch") = "Y" Then hidePatches = "" Set rsPkgs = OraDatabase.DbCreateDynaset( Get_Pkg_Names( NNpkg_list, NNadd_type ), cint(0)) While ((NOT rsPkgs.BOF) AND (NOT rsPkgs.EOF)) currRsPkg = chr(34) & rsPkgs("pkg_id") & chr(34) qparPkg_list = chr(34) & parPkg_list & chr(34) ' Begin table row SShtml_pkg_list = SShtml_pkg_list &" " spanPkgNameId = "spanPkgName" & rsPkgs("pkg_id") ' Form package name SShtml_pkg_list = SShtml_pkg_list &" " _ & ""& rsPkgs("pkg_name") &"" ' setup some common html so that we can make the (full) Version field on the right-most column of the ' table row update on certain events taking place in the version base input box, and version extension ' drop down list box commonHTML = rsPkgs("pkg_id") & "' onblur='updateVersion(" & currRsPkg & ");'" &_ " onchange='updateVersion(" & currRsPkg & ");'" SShtml_pkg_list = SShtml_pkg_list & "" SShtml_pkg_list = SShtml_pkg_list &"" ' End table row SShtml_pkg_list = SShtml_pkg_list &"" rsPkgs.MoveNext WEnd End Sub ' This function deals with a PV_ID list, not a PKG_ID list. Hence, it is used for the ADD Dependencies user operation. ' The function was initially based on the Generate_Package_List() function, and then stripped back and reworked to use ' the result of the Get_Versions_From_Release() function, which now processes PV_ID lists also. ' Adding a dependency means taking the latest version in the release, there is no choice about it. Sub Generate_Version_List ( NNpv_id_list, SShtml_pkg_list, NNrtag_id, NNadd_type ) Dim spanPkgNameId Dim fullVersion Dim i ' dictionaries and arrays Dim dictPkgId, dictPkgVer, dictPkgExt, dictPkgName Dim pv_ids, pkg_ids, versions, pkg_names ' create dictionaries Set dictPkgId = CreateObject("Scripting.Dictionary") Set dictPkgName = CreateObject("Scripting.Dictionary") Set dictPkgVer = CreateObject("Scripting.Dictionary") Set dictPkgExt = CreateObject("Scripting.Dictionary") ' This one assigned, and populated, but currently not used thereafter ' populate dictionaries Call Get_Versions_From_Release ( NNpv_id_list, NNrtag_id, dictPkgId, dictPkgName, dictPkgVer, dictPkgExt ) ' get the columns we need from the dictionaries pv_ids = dictPkgId.Keys pkg_names = dictPkgName.Items pkg_ids = dictPkgId.Items versions = dictPkgVer.Items ' iterate through all the PV_ID's we found using the Get_Versions_From_Release() function For i = 0 to ubound(pv_ids) fullVersion = versions(i) ' Begin table row SShtml_pkg_list = SShtml_pkg_list &" " ' NOTE: the formation of this span name may result in more than one span of the same name in the HTML. ' This is because there may be >1 package version of the same package ID (eg sysbasetypes.mas, sysbasetypes.sea) ' being added as dependencies. It doesn't seem to matter though. It just reflects the ancestry of this code which ' used to be exclusively package ID focused, whereas now, it has a pv_id focus when dealing with dependencies. spanPkgNameId = "spanPkgName" & pkg_names(i) ' Form package name SShtml_pkg_list = SShtml_pkg_list & " " _ & " "& pkg_names(i) &"" ' Form the (full) Version display field SShtml_pkg_list = SShtml_pkg_list &" " If fullVersion = "" Then SShtml_pkg_list = SShtml_pkg_list &" unset " Else SShtml_pkg_list = SShtml_pkg_list &"" & fullVersion & "" End If SShtml_pkg_list = SShtml_pkg_list & " " ' End table row SShtml_pkg_list = SShtml_pkg_list &"" Next End Sub ' Create HTML to populate a form selection with versions numbers for a specified ' package. This could be done via AJAX but is currently done when the page is ' rendered. Function populateVersionList(NNpkg_id) Dim rsFind Dim Query_String Dim aVersions Dim objSortHelper Dim lastRow, i ' First one - Use as a prompt populateVersionList = "" Query_String = _ " SELECT DISTINCT pv.pkg_version, pv.dlocked "&_ " FROM PACKAGES pkg, package_versions pv"&_ " WHERE pkg.pkg_id = pv.pkg_id AND pkg.pkg_id = " & NNpkg_id Set rsFind = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If rsFind.RecordCount > 0 Then aVersions = rsFind.GetRows() lastRow = UBound( aVersions, 2 ) Set objSortHelper = New SortHelper ' Sort versions Call objSortHelper.VersionSort( aVersions, 0, lastRow, rsFind.FieldIndex("pkg_version") ) ' Descending order For i = lastRow To 0 Step -1 Dim prefix Dim text text = aVersions( rsFind.FieldIndex("pkg_version"), i ) If aVersions( rsFind.FieldIndex("dlocked"), i ) = "Y" Then prefix = "R " Else prefix = "    " End If populateVersionList = populateVersionList &_ "" Next Set objSortHelper = nothing End If rsFind.Close Set rsFind = nothing End Function %> <% If parPv_id <> "" Then Call Get_Pkg_Info ( parPv_id, NULL ) End If %> Release Manager <% 'Use the parPkg_list in two different ways. When adding dependencies, the list contains pv_id's. 'When adding packages it contains pkg_id's. Different functions deal with each situation. If ( (parAdd_type <> Cstr(enum_ADD_DEPENDENCIES)) AND (parAdd_type <> Cstr(enum_ADD_RUNTIME_DEPENDENCIES)) ) Then Call Generate_Package_List( parPkg_list, HTML_pkg_list, parRtag_id, parAdd_type ) Else Call Generate_Version_List( parPkg_list, HTML_pkg_list, parRtag_id, parAdd_type ) End If%>
<%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%>
<%ElseIf parAdd_type = Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then%> <%Else%> <%End If%>
<%=Page_Title ( parAdd_type )%>
<%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%>
To Base View

NOTE: Symbol '>' in Base Views drop-down list is a suggestion where to place selected package(s).
<%If QStrPar("Pview") <> "disable" Then%>
To Personal View
<%End If%> <%Else%>
<%=pkgInfoHash.Item ("pkg_name")%> <%=pkgInfoHash.Item ("pkg_version")%>
<%End If%>
<%=HTML_pkg_list%>
Package Name Version <%If parAdd_type <> Cstr(enum_ADD_DEPENDENCIES) AND parAdd_type <> Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then Response.Write Quick_Help("existingVersion") End If%>
<%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%> Add to Pending <%=Quick_Help("addPending")%> <%End If%>