Subversion Repositories DevTools

Rev

Rev 6827 | Rev 7288 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|                                                   |
'|                    ADD                            |
'|                 PACKAGES                          |
'|              OR DEPENDENCIES                      |
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="class/classSortHelper.asp"-->
<%

'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
' 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, '>&nbsp;' 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 "<option value='"& rsTemp("view_id") &"' selected>"& rsTemp("hint") & rsTemp("view_name") &"</option>"
      Else
         Response.write "<option value='"& rsTemp("view_id") &"'>"& rsTemp("hint") & rsTemp("view_name") &"</option>"
      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 "<option value='"& rsTemp.Fields("view_id") &"'>"& rsTemp.Fields("view_name") &"</option>"

      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 &"<tr> "

      spanPkgNameId = "spanPkgName" & rsPkgs("pkg_id")

      ' Form package name
      SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif' nowrap class='form_item'>" _
                                        & "<span id='" & spanPkgNameId & "'>"& rsPkgs("pkg_name") &"</span></td>"

      ' 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 & "<td><select class='form_item' id='pkgn" & commonHTML & "name='pkgn" & rsPkgs("pkg_id") & "'>"
      SShtml_pkg_list = SShtml_pkg_list & populateVersionList( rsPkgs("pkg_id") )
      SShtml_pkg_list = SShtml_pkg_list & "</select></td>"

      SShtml_pkg_list = SShtml_pkg_list  &"</td>"

      ' End table row
      SShtml_pkg_list = SShtml_pkg_list  &"</tr>"

      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 &"<tr> "

      ' 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 & " <td background='images/bg_form_lightgray.gif' nowrap class='form_item'>" _
                                        & " <span id='" & spanPkgNameId & "'>"& pkg_names(i) &"</span></td>"


      ' Form the (full) Version display field
      SShtml_pkg_list = SShtml_pkg_list &"  <td background='images/bg_form_lightgray.gif'>"

      If fullVersion = "" Then
         SShtml_pkg_list = SShtml_pkg_list &"<span nowrap class='form_item' name='spanFullVersion" & pkg_ids(i) _
                                           & "' id='spanFullVersion" & pkg_ids(i) & "'> unset </span>"
      Else
         SShtml_pkg_list = SShtml_pkg_list &"<span nowrap class='form_item' name='spanFullVersion" & pkg_ids(i) _
                                           & "' id='spanFullVersion" & pkg_ids(i) & "'>" & fullVersion & "</span>"
      End If

      SShtml_pkg_list = SShtml_pkg_list & "<input type='hidden'  id='pkgn" & pkg_ids(i) _
                                        & "' name='pkgn" & pkg_ids(i) & "' ' class='form_item' size='12' value='" & fullVersion & "'> "

      ' End table row
      SShtml_pkg_list = SShtml_pkg_list  &"</tr>"
   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 = "<option>-- Select Version --</option>"

    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&nbsp;"
            Else
                prefix = "&nbsp;&nbsp;&nbsp;&nbsp;"
            End If
            
            populateVersionList = populateVersionList &_
                "<option value='"& text &"'>" & prefix & text & "</option>"

                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
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
<link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" type="text/JavaScript">
<!--

window.onload = function()
{
  checkSeletion(document.getElementById("base_view_id"));
   var versionObjectIds = getVersionObjectIds();
   for( var iobj in versionObjectIds )
   {
      updateVersion(versionObjectIds[iobj]);
   }
}

// getVersionObjectIds is only called when adding packages to a release.
function getVersionObjectIds ()
{
   var versionObjectIds = new Array(); // Memory leak?

   <%
   Dim rsPkgs3, versionObjectId
   Set rsPkgs3 = OraDatabase.DbCreateDynaset( Get_Pkg_Names( parPkg_list, parAdd_type ), cint(0))

   While ((NOT rsPkgs3.BOF) AND (NOT rsPkgs3.EOF))
      versionObjectId = rsPkgs3("pkg_id")
      %>
      versionObjectIds.push( "<%=versionObjectId%>" );
      <%
      rsPkgs3.MoveNext
   Wend
   rsPkgs3.Close()
   %>

   return versionObjectIds;
}

// CheckVersion is only called when adding packages to a release.
// Called before the form is submitted. Can validate the form
// Simply tests that all required fields have been entered
function checkVersion ()
{
   var isValid = checkSeletion(document.getElementById("base_view_id"));
   var versionObjectIds = getVersionObjectIds();
   for( var iobj in versionObjectIds )
   {
      if (updateVersion(versionObjectIds[iobj]))
        continue;

      isValid = false;
      break;
   }

   if (isValid) {
    MM_showProgressBar();
   }
   else
   {
      // failed - exit function, returning false for the form.
      document.MM_returnValue = false;
      MM_hideProgressBar();
      vixAlert ("Complete all selections");
      return false;
   }
   return true;
}

// updateVersion is only called when adding packages to a release.
function updateVersion( myPkgId, myParPkg_list )
{
    return checkSeletion(document.getElementById("pkgn" + myPkgId));
}

//-->
</script>
<!-- DROPDOWN MENUS -->
<!--#include file="_menu_def.asp"-->
<script language="JavaScript1.2" src="images/popup_menu.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<!--#include file="_jquery_includes.asp"-->
<!-- HEADER -->
<!--#include file="_header.asp"-->
<!-- BODY ---->
<table width="100%" height="80%" border="0" cellpadding="0" cellspacing="0">
    <% '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%>
   <tr>
      <td align="center" valign="top" class='bg_grey'>
         <!-- MIDDLE ---------------------------------------->
         <div style='width:600px' class=Panel>
         <%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%>
            <form name="addpkg" id="addpkg" method="post" action="_add_pkgs_to_release.asp" onSubmit="return checkVersion();">
         <%ElseIf parAdd_type = Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then%>
            <form name="addpkg" method="post" action="_add_runtime_dependencies.asp" onSubmit="return true">
         <%Else%>
            <form name="addpkg" method="post" action="_update_dependencies.asp" onSubmit="return true">
         <%End If%>

             <div class='rounded_box_caption'>
                <%=Page_Title ( parAdd_type )%>
             </div>
             <div class='rounded_box'>
                 <div class='PanelFrame'>
                     <%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%>
                     <!-- Base View -->
                     <div class='textPanel PanelPad'>
                        <div class=PanelHead>To Base View</div>
                        <div class='PanelLine'>
                            <select name="base_view_id" id="base_view_id" class="form_item" onblur="checkSeletion(this);" onchange="checkSeletion(this);">
                            <option></option>
                            <%Call Get_All_Base_Views( parBase_view_id, parPkg_list )%>
                            </select>
                            <br>
                            <span class="rep_small">NOTE: Symbol '>' in Base Views drop-down list is a suggestion where to place selected package(s).</span>
                        </div>
                    </div>

                     <!-- --------- Private View ------------ -->
                     <%If QStrPar("Pview") <> "disable" Then%>
                     <div class='textPanel PanelPad'>
                         <div class=PanelHead> To Personal View</div>
                         <div class=PanelLine>
                            <select name="personal_view_id" class="form_item">
                                     <option value="">None</option>
                                     <%Call Get_All_Personal_Views( objAccessControl.UserId )%>
                                  </select>
                         </div>
                     </div>
                     <%End If%>
                     <%Else%>
                     <div class='textPanel PanelPad'>
                        <b><%=pkgInfoHash.Item ("pkg_name")%>&nbsp;<%=pkgInfoHash.Item ("pkg_version")%></b>
                     </div>
                     <%End If%>
                     <!-- --------- Package List ------------ -->
                    <div class=PanelPad>
                        <table width="100%" border="0" cellspacing="1" cellpadding="2" class=stdGrey>
                           <thead>
                              <th nowrap width='1%'>Package Name</th>
                              <th>Version
                              <%If parAdd_type <> Cstr(enum_ADD_DEPENDENCIES) AND parAdd_type <> Cstr(enum_ADD_RUNTIME_DEPENDENCIES) Then
                                   Response.Write Quick_Help("existingVersion")
                                End If%>
                              </th>
                           </thead>
                           <%=HTML_pkg_list%>
                        </table>
                    </div>
                 </div>
                 <!-- Buttons  -->
                <div class='buttonPanel'>
                    <span id="ProgressBar" name="ProgressBar" style="visibility:hidden;">
                       <img src="images/i_processing.gif" width="11" height="17" align="absmiddle" hspace="3">Processing...
                    </span>
                    <input type="reset" name="btn" value="&laquo; Back" onClick="history.back();">
                    <input type="reset" name="btn" value="Cancel" onClick="history.go(-3);">
                    <input type="submit" name="btn" value="  Add  " >
                    <%If parAdd_type = Cstr(enum_ADD_PACKAGES) Then%>
                    <span><input type="checkbox" name="iMode" value="pending">Add to Pending</span>
                    <%End If%>
                    <input type="hidden" name="update_type" value="add_custom">
                    <input type="hidden" name="pv_id" value="<%=parPv_id%>">
                    <input type="hidden" name="rtag_id" value="<%=parRtag_id%>">
                    <input type="hidden" name="pkg_list" value="<%=parPkg_list%>">
                </div>
             </div>
         </form>
         </div>
         <!-------------------------------------------------->
      </td>
   </tr>
 <!-- FOOTER -->
 <!--#include file="_footer.asp"-->
</table>
</body>
</html>