Subversion Repositories DevTools

Rev

Rev 5590 | Rev 5957 | 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
%>
<%
'=====================================================
'              Change Group
'=====================================================
%>
<!--#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"-->
<!--#include file="common/daemon_instructions.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim sMessage, sMessageType
Dim parPv_id
Dim parProj_id
Dim parNewRtag_id
Dim parRfile
Dim bPreventSubmit
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
sMessage = NULL
sMessageType = 3
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
parPv_id = QStrPar("pv_id")
parProj_id= QStrParDefault("proj_id",DB_PROJ_ID)
parNewRtag_id = QStrParDefault("new_rtag_id", parRtag_id)
parRfile = Request("rfile")
If IsNull(parProj_id) Then parProj_id = "0"
If IsNull(parNewRtag_id) Then parNewRtag_id = "0"
If IsNull(parRfile) Then parRfile = "dependencies.asp"
bPreventSubmit = false
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------------------------------------------------------------------
' Add a line of text to the System Message
'
Sub sMessageAdd(eLevel, text)
    If NOT isNull(sMessage) Then
        sMessage = sMessage & "<br>"
    End If
    sMessage = sMessage & text

    If eLevel < sMessageType  Then
        sMessageType = eLevel
    End If
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------
Sub Get_Pkg_Info_From_Rel ( SSrtag_id, SSpv_id )
   Dim rsTemp, Query_String

   Query_String = _
   " SELECT pkg.pkg_name, pv.pkg_version, wip.view_id, vi.view_name"&_
   "  FROM packages pkg, package_versions pv, work_in_progress wip, views vi"&_
   " WHERE     pkg.pkg_id = pv.pkg_id"&_
   "        AND pv.pv_id = wip.pv_id"&_
   "        AND vi.view_id = wip.view_id"&_
   "        AND wip.rtag_id = "& SSrtag_id &_
   "        AND wip.pv_id = "& SSpv_id

   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))

   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
      pkgInfoHash.Add "pkg_name", (rsTemp.Fields("pkg_name"))
      pkgInfoHash.Add "pkg_version", (rsTemp.Fields("pkg_version"))
      pkgInfoHash.Add "view_id", (rsTemp.Fields("view_id"))
      pkgInfoHash.Add "view_name", (rsTemp.Fields("view_name"))
   End If

   rsTemp.Close
   Set rsTemp = nothing
End Sub



'------------------------------------------------------------------------------------------------------------------------------------------
' Formulate the HTML for a combo box listing all the Projects, and select the one that matches
' the proj-id passed in as a parameter. If the parameter value could not be found, correct it to the first valid proj-id
' in the list.
'------------------------------------------------------------------------------------------------------------------------------------------
Function Get_Projects ( NNproj_id )
   Dim rsTemp, Query_String, projName, tempLINK, selectedFound, s

   selectedFound = False
   Query_String = "SELECT * FROM projects ORDER BY  UPPER( proj_name )"

   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))

   s = "<td class='form_field' background='images/bg_form_lightbluedark.gif' >Project</td>"
   s = s + "<td background='images/bg_form_lightbluedark.gif'><select id='proj_id_list' name='proj_id_list' class='form_item' onChange=""MM_jumpMenu('window',this,0)"">"

   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
      projName = UCase(rsTemp.Fields("proj_name"))

      tempLINK = scriptName & "?proj_id=" & rsTemp.Fields("proj_id") &_
                              "&rtag_id="& parRtag_id &_
                              "&new_rtag_id="& parNewRtag_id &_
                              "&pv_id="& parPv_id &_
                              "&rfile="& parRfile

      If ((CStr(NNproj_id) = Cstr(rsTemp.Fields("proj_id"))) OR (NNproj_id = "0")) AND (selectedFound = False) Then
         s = s + "<option value='"& tempLINK &"' selected>"& projName &"</option>"
         selectedFound = True
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
      Else
         s = s + "<option value='"& tempLINK &"'>"& projName &"</option>"
      End If

      rsTemp.MoveNext
   WEnd
   s = s + "</select>"

   ' Correct for a situation where selectedFound is still FALSE.
   If NOT selectedFound Then
      rsTemp.MoveFirst
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
      Else
         NNproj_id = "0"
      End If
   End If

   rsTemp.Close
   Set rsTemp = nothing

   s = s + "</td>"

   Get_Projects = s
End Function


'------------------------------------------------------------------------------------------------------------------------------------------
' Formulate the HTML for a combo box listing all the Release for a specified project, and select the one that matches
' the release-tag passed in as a parameter. If the parameter value could not be found, correct it to the first valid release-tag
' in the list.
'------------------------------------------------------------------------------------------------------------------------------------------
Function Get_Releases ( NNproj_id, NNrtag_id )
   Dim rsTemp, Query_String, releaseName, tempLINK, selectedFound, s, numReleases

   selectedFound = False

   numReleases = 0

   Query_String = "SELECT rtag_id, rtag_name "&_
                  "  FROM release_tags rt"&_
                  " WHERE rt.proj_id = "& NNproj_id &_
                  "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
                  " ORDER BY UPPER(rtag_name)"
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))

   s = "<select id='rtag_id_list' name='rtag_id_list' class='form_item' onChange=""MM_jumpMenu('window',this,0)"">"

   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
      releaseName = rsTemp.Fields("rtag_name")

      tempLINK = scriptName & "?proj_id="& NNproj_id &_
                              "&rtag_id="& parRtag_id &_
                              "&new_rtag_id="& rsTemp.Fields("rtag_id") &_
                              "&pv_id="& parPv_id &_
                              "&rfile="& parRfile

      If ((CStr(NNrtag_id) = CStr(rsTemp.Fields("rtag_id"))) OR (NNrtag_id = "0")) AND (selectedFound = False) Then
            s = s + "<option value='"& tempLINK &"' selected>"& releaseName &"</option>"
         selectedFound = True
         NNrtag_id = Cstr(rsTemp.Fields("rtag_id"))
      Else
         s = s + "<option value='"& tempLINK &"'>"& releaseName &"</option>"
      End If

      numReleases = numReleases + 1

      rsTemp.MoveNext
   WEnd
   s = s + "</select>"

   ' Correct for a situation where selectedFound is still FALSE.
   If NOT selectedFound Then
      rsTemp.MoveFirst
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
         NNrtag_id = CStr(rsTemp.Fields("rtag_id"))
      Else
         NNrtag_id = "0"
      End If
   End If

   ' If no releases were found then replace drop down list with some warning text and disable form submission
   If numReleases = 0 Then
      bPreventSubmit = True
      s = "<a class=err_alert>No active releases</a>"
      Call sMessageAdd( 1,  "No active releases found. The operation cannot be performed")
   End If

   rsTemp.Close
   Set rsTemp = nothing

   s = "<td class='form_field'  background='images/bg_form_lightbluedark.gif' >Release</td>" + "<td background='images/bg_form_lightbluedark.gif' >" + s + "<td>"

   Get_Releases = s
End Function

'-------------------------------------------------------------------------------------------------------
' Call stored procedures to move the WIP from the source release to the destination release
' Return false on failure
'-------------------------------------------------------------------------------------------------------
Function MoveWip(source_RtagId, destination_RtagId, pvId, viewId)

    MoveWip = False

    OraDatabase.Parameters.Add "RTAG_ID", source_RtagId,           ORAPARM_INPUT, ORATYPE_NUMBER
    OraDatabase.Parameters.Add "PV_ID",   pvId,                    ORAPARM_INPUT, ORATYPE_VARCHAR2
    OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
    OraDatabase.Parameters.Add "VIEW_ID", viewId,                  ORAPARM_INPUT, ORATYPE_NUMBER

    objEH.ErrorRedirect = FALSE
    objEH.TryORA ( OraSession )
    On Error Resume Next
    OraDatabase.ExecuteSQL _
        "BEGIN   PK_WORK_IN_PROGRESS.REMOVE_PACKAGE ( :PV_ID, :RTAG_ID, :USER_ID );   END;"

    If Err.Number = 0 Then
        ' First step is OK
        OraDatabase.Parameters.Remove "RTAG_ID"
        OraDatabase.Parameters.Add "RTAG_ID", destination_RtagId, ORAPARM_INPUT, ORATYPE_NUMBER

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

        OraDatabase.ExecuteSQL _
            "BEGIN   PK_WORK_IN_PROGRESS.ADD_PACKAGE ( :PV_ID, :VIEW_ID, :RTAG_ID, :USER_ID );   END;"

    End If

    objEH.CatchORA ( OraSession )
    If objEH.Finally Then
        MoveWip = True
    End IF

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

End Function

%>
<%
' get pkgInfoHash items for the source WIP
Call Get_Pkg_Info_From_Rel ( parRtag_id, parPv_id )

' Access control
If NOT objAccessControl.UserLogedIn Then
    Call sMessageAdd (1,"User is no longer logged in")
    bPreventSubmit = True
ElseIf NOT canActionInProject() Then
    Call sMessageAdd (1, "You have been denied permission to modify the source release")
    bPreventSubmit = True
' Make sure this WIP can be moved - prevent if it has a pending test build instruction, etc
ElseIf (DaemonInstructionPreventsEditing(Request("rtag_id"), Request("pv_id"))) Then
    bPreventSubmit = True
   Call sMessageAdd (1, "This WIP has one or more daemon instructions present.<br>"&_
                        "Please delete them or allow them to complete before moving WIPs.")
Else
   ' check for form submission
   If CBool(QStrPar("action")) AND (QStrPar("btn") = "Move") AND objAccessControl.UserLogedIn Then
      'Process submition
      If MoveWip(parRtag_id, parNewRtag_id, parPv_id, pkgInfoHash.Item("view_id")) Then
        Call OpenInParentWindow (parRfile &"?pv_id="& parPv_id &"&rtag_id="& parNewRtag_id )
        Call CloseWindow
      End If
   Else
      ' Call HTML rendering functions, but throw away the strings returned since we only want to ensure that
      ' the current state of the bPreventSubmit flag has been acquired in order to show/hide the submit button
      Call Get_Projects(parProj_id)
      Call Get_Releases(parProj_id, parNewRtag_id)
   End If
End If

' Prevent moving to myself
If (parNewRtag_id = parRtag_id) Then
    Call sMessageAdd (3,"Select a release")
    bPreventSubmit = True
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/tipster.js"></script>
<script language="JavaScript" src="images/_help_tips.js"></script>
<script language="JavaScript" src="images/common.js"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
<form name="chgroup" method="post" action="<%=scriptName%>" class="form_tight">
   <table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td>
       <!-- MESSAGE ++++++++++++++++++++++++++++++++++++++++++++++ -->
       <%Call Messenger ( sMessage , sMessageType, "100%" )%>
       <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
       <!--#include file="messages/_msg_inline.asp"-->
      </td>
      <tr>
         <td valign="top" nowrap class="wform_ttl" background="images/bg_form_lightgray.gif">
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
               <tr>
                  <td width="1%"><img src="images/h_trsp_dot.gif" width="10" height="30"></td>
                  <td width="1%" nowrap class="form_group" valign="bottom" colspan="2">WIP Details</td>
               </tr>
               <tr>
                  <td width="1%">&nbsp;</td>
                  <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">
                     <%=pkgInfoHash.Item("pkg_name")%>
                  </td>
               </tr>
               <tr>
                  <td width="1%">&nbsp;</td>
                  <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Version</td>
                  <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt">
                     <%=pkgInfoHash.Item("pkg_version")%>
                  </td>
               </tr>
               <tr>
                  <td width="1%">&nbsp;</td>
                  <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">View<a href="#" onMouseOver="formTips.show('group')" onMouseOut="formTips.hide()"></a></td>
                  <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt">
                     <%=pkgInfoHash.Item("view_name")%>
                  </td>
               </tr>

               <tr>
                  <td width="1%"><img src="images/h_trsp_dot.gif" width="10" height="30"></td>
                  <td width="1%" nowrap class="form_group" valign="bottom" colspan="2">Select Destination Release</td>
               </tr>
               <tr>
                  <td width="1%">&nbsp;</td>
                  <%=Get_Projects(parProj_id)%>
                  <td nowrap width="100%">&nbsp; </td>
               </tr>
               <tr>
                  <td width="1%">&nbsp;</td>
                  <%=Get_Releases(parProj_id, parNewRtag_id)%>
                  <td nowrap width="100%">&nbsp; </td>
               </tr>
            </table>
         </td>
      </tr>
      <tr>
         <td valign="top" nowrap class="wform_ttl" background="images/bg_form_lightgray.gif">
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
               <tr>
                  <td width="1%" wrap class="form_group" valign="bottom">
                     <img src="images/i_warning.gif" width="16" height="16">
                     The destination release may not satisfy any or all the dependencies that come with
                     the WIP you are about to move. It is your responsibility to rectify this in the
                     destination release.
                  </td>
               </tr>
            </table>
         </td>
      </tr>
      <tr>
         <td align="right">
            <input type="submit" name="btn" value="Move" <%=Iif(bPreventSubmit, "disabled", "")%> class="form_btn_comp form_btn">
            <input type="reset" name="btn" value="Cancel" class="form_btn_comp" onclick="parent.closeIFrame();">
         </td>
      </tr>
   </table>
   <input type="hidden" name="pv_id" value="<%=parPv_id%>">
   <input type="hidden" name="rtag_id" value="<%=parRtag_id%>">
   <input type="hidden" name="new_rtag_id" value="<%=parNewRtag_id%>">
   <input type="hidden" name="view_id" value="<%=pkgInfoHash.Item("view_id")%>">
   <input type="hidden" name="rfile" value="<%=parRfile%>">
   <input type="hidden" name="action" value="true">
</form>
<!-- TIPS LAYERS -------------------------------------->
<div id="formTipsLayer" style="position: absolute; z-index: 1000; visibility: hidden; left:0; top: 0; width: 10">&nbsp;</div>
<!----------------------------------------------------->
</body>
</html>


<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->