Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
Option explicit
Response.Expires = 0    ' always load the page, dont store
%>
<%
'=====================================================
'                                       Import Release
'=====================================================
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/common_dbedit.asp"-->
<!--#include file="common/_popup_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim parFRpkg_id                     ' Currently selected Package
Dim parFRpv_id                      ' Currently selected Package-Version
Dim parFromPv_id
Dim parToRtag_id
Dim sMessage
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parFRpkg_id = QStrPar("FRpkg_id")
parFRpv_id = QStrPar("FRpv_id")
parFromPv_id = QStrPar("FromPv_id")
parToRtag_id = QStrPar("rtag_id")
sMessage = NULL
If parFRpkg_id = "" Then parFRpkg_id = "-1"
If parFRpv_id = ""  Then parFRpv_id = "-1"
'----------------------------------------------
%>
<%
'-------------------------------------------------
' Function:         Get_Packages   
' Description:      Generate a List Box of all package names in the system
'                   Select the 'current' package
' Arguments:        NNpkg_id - Currently selected pkg_id
'
Sub Get_Packages ( NNpkg_id )
        Dim rsTemp, Query_String, tempLINK
        Query_String = _
        "SELECT * FROM packages ORDER BY pkg_name ASC"
        Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
        
        Response.write "<select name='FRpkg_id' onChange=""MM_showProgressBar();MM_jumpMenu('window',this,0)"" class='form_item'>"
                Response.write "<option value=''>Select Package</option>"
                While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
                        tempLINK = scriptName &"?FRpkg_id="& rsTemp.Fields("pkg_id") & "&"& objPMod.ComposeURL()
                        If NNpkg_id = Cstr(rsTemp.Fields("pkg_id")) Then
                        Response.write "<option value='"& tempLINK &"' selected>"& (rsTemp.Fields("pkg_name")) &"</option>"
                Else
                                Response.write "<option value='"& tempLINK &"'>"& (rsTemp.Fields("pkg_name")) &"</option>"
            End If
                        rsTemp.MoveNext
                WEnd
        Response.write "</select>"
        
        rsTemp.Close
        Set rsTemp = nothing
End Sub

'-------------------------------------------------
' Function:         Get_Package_Versions
' Description:      Create a list box for all versions of a specified pakage
' Arguments:        NNpkg_id   - pkg_id of the base package
'                   NNrtag_id   - pv_id of the currently selected package-vesrion
'
Sub Get_Package_Versions ( NNpkg_id, NNrtag_id )
        Dim rsTemp, Query_String, tempLINK, productId
        Query_String = _
        "SELECT pv_id, pkg_version FROM package_versions WHERE pkg_id = "& NNpkg_id &" ORDER BY pkg_version ASC"
        Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
        
        Response.write "<select name='FRpv_id' onChange=""MM_showProgressBar();MM_jumpMenu('window',this,0)"" class='form_item'>"
                If NNpkg_id <> "-1" Then
                        Response.write "<option value=''>Select Package Version</option>"
                        While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
                                tempLINK = scriptName &"?FRpv_id="& rsTemp.Fields("pv_id") &"&FRpkg_id="& NNpkg_id &"&"& objPMod.ComposeURL()
                                
                                If NNrtag_id = Cstr(rsTemp.Fields("pv_id")) Then
                                Response.write "<option value='"& tempLINK &"' selected>"& (rsTemp.Fields("pkg_version")) &"</option>"
                        Else
                                        Response.write "<option value='"& tempLINK &"'>"& (rsTemp.Fields("pkg_version")) &"</option>"
                                End If
                                rsTemp.MoveNext
                        WEnd
                End If
        Response.write "</select>"
        
        rsTemp.Close
        Set rsTemp = nothing
End Sub

Function Import_Dependency ( NNFromPv_id, NNToRtag_id )
    Dim sqlStr, PvId, ii
    Dim ImportList, entry,  keys
    Set ImportList = CreateObject ("Scripting.Dictionary")

    '
    '   Generate a list of packages to be added
    '   The union will add the base package to the set - if its not present
    '
        sqlStr = "SELECT DISTINCT qry.DPV_ID"&_
    " FROM ("&_
        "               SELECT dep.PV_ID, dep.DPV_ID, LEVEL AS LEVEL_NUM"&_
        "                 FROM PACKAGE_DEPENDENCIES dep"&_
        "               START WITH dep.PV_ID IN ( :PV_ID ) "&_
        "               CONNECT BY PRIOR dep.DPV_ID = dep.PV_ID"&_
    "       UNION" &_
    "       SELECT" &_
    "           TO_NUMBER(:PV_ID), TO_NUMBER(:PV_ID), TO_NUMBER(0) " &_
    "       FROM DUAL" &_
        "       ) qry,"&_
        "       PACKAGES pkg,"&_
        "       PACKAGE_VERSIONS pv"&_
        " WHERE qry.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID"&_
        " and qry.dpv_id NOT IN (select pv_id from release_content where rtag_id = :RTAG_ID)"

        objEH.ErrorRedirect = FALSE
    objEH.TryORA ( OraSession )
    On Error Resume Next

        OraDatabase.Parameters.Add "PV_ID",   NNFromPv_id,      ORAPARM_INPUT, ORATYPE_NUMBER 
        OraDatabase.Parameters.Add "RTAG_ID", NNToRtag_id,      ORAPARM_INPUT, ORATYPE_NUMBER 
        OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId,  ORAPARM_INPUT, ORATYPE_NUMBER 
    OraDatabase.Parameters.Add "OPERATION","A", ORAPARM_INPUT, ORATYPE_CHAR

    Dim rsTemp
        Set rsTemp = OraDatabase.DbCreateDynaset( sqlStr, cint(0))
    If Err.Number = 0 Then
        While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
           entry = rsTemp("DPV_ID")
           If NOT ImportList.Exists(entry) Then
                ImportList.add entry, 1
           End If
           rsTemp.MoveNext
        WEnd
    End If
        rsTemp.Close
        Set rsTemp = nothing

    '
    '   Add each entry into the 'Pending Tab'
    '
    keys = ImportList.Keys
    For ii = 0 to ImportList.Count - 1
        entry = keys(ii)
            OraDatabase.Parameters.Remove "PV_ID"
            OraDatabase.Parameters.Add "PV_ID", entry, ORAPARM_INPUT, ORATYPE_NUMBER 
        If Err.Number = 0 Then
            OraDatabase.ExecuteSQL _
            "BEGIN  "&_
            "  PK_PLANNED.MERGE_PACKAGE ( :PV_ID, 7, :RTAG_ID, :USER_ID, :OPERATION );  "&_
            "END;"
        End If
    Next
        
        objEH.CatchORA ( OraSession )
     If objEH.Finally Then
        Call OpenInParentWindow ("dependencies.asp?rtag_id=" & NNToRtag_id)
        Call CloseWindow()
     End If

        
        OraDatabase.Parameters.Remove "PV_ID"
        OraDatabase.Parameters.Remove "RTAG_ID"
        OraDatabase.Parameters.Remove "USER_ID"
        OraDatabase.Parameters.Remove "OPERATION"

        Set ImportList = nothing

End Function

%>
<%
'Process submition
If CBool(QStrPar("action")) Then
    If NOT objAccessControl.UserLogedIn Then
        sMessage = "User is no longer logged in"
    ElseIf NOT( (parFromPv_id <> "") AND (parToRtag_id <> "")) Then
        sMessage = "Internal: Mandatory parameters are missing"
    Else
        Call Import_Dependency ( parFromPv_id, parToRtag_id )
        parFRpkg_id = "-1"
        parFRpv_id = "-1" 
    End If
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" type="text/css">
<link rel="stylesheet" href="images/navigation.css" type="text/css">
<script language="JavaScript" src="images/common.js"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
<form class="form_tight" name="importrel" method="post" action="<%=scriptName%>">
  <table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr> 
      <td valign="top" nowrap colspan="3" class="wform_ttl" background="images/bg_form_lightgray.gif"> 
         <!-- LOCAL MESSAGES ++++++++++++++++++++++++++++++++++++++++++++ -->
         <%Call Messenger ( sMessage , 3, "100%" )%>
         <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <!--#include file="messages/_msg_inline.asp"-->
        <table width="100%" border="0" cellspacing="1" cellpadding="2">
          <tr> 
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Package</td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt"> 
              <%Call Get_Packages ( parFRpkg_id )%>
            </td>
          </tr>
          <tr> 
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Package Version </td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt"> 
              <%Call Get_Package_Versions ( parFRpkg_id, parFRpv_id )%>
                          <input type="hidden" name="FromPv_id" value="<%=parFRpv_id%>">
                          <input type="hidden" name="rtag_id" value="<%=Request("rtag_id")%>">
              <input type="hidden" name="action" value="true">
            </td>
          </tr>
          <tr> 
            <td width="100%" class="form_txt" colspan="2"> 
              <p>Import all the dependencies of the specified package into the current Release in a recursive manner.
               <br>The specified package will also be import - if it is not already present.
               <p>Package Versions will be added to the 'Pending' tab of the Release. Duplicates <bold>MUST</bold> be removed from this list
                  before the versions are 'Released' into the body of the Release.
              </p>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td><%=ProgressBar()%></td>
      <td align="right"> 
        <input type="submit" name="btn" value="Import" class="form_btn_comp" onClick="MM_validateForm('FRpkg_id','Package Name','R','FRpv_id','Package Version','R');return document.MM_returnValue">
        <input type="reset" name="btn" value="Cancel" class="form_btn_comp" onclick="parent.closeIFrame();">
      </td>
    </tr>
  </table>
</form>
</body>
</html>
<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->