<!--
 * Copyright (c) 2001, 2006, Oracle. All rights reserved.  
 *
 *      NAME
 *       patchCacheAdd.uix
 *
 *      NOTES
 *       define a new Patch for the Patch Cache
 *
 *
 * MODIFIED   (MM/DD/YY)  VERSION
 *  summukhe   05/15/07 - 
 *  spahuja    02/09/06 - enabling component creation 
 *  pdasika    11/21/05 - Backport pdasika_bug-4690073 from main 
 *  pdasika    11/07/05 - bug 3825247 
 *  nitijain   08/19/05 - correcting lov display for mozilla browsers
 *  spahuja    07/25/05 - disabling component creation check box for 10.2 release 
 *  spahuja    07/11/05 - add check box for component creation 
 *  mningomb   06/03/05 - Make release alert message locale-aware 
 *  kchiasso   10/09/03 - 
 *  kchiasso   07/10/03 - bugfix 2966548
 *  kchiasso   05/16/03 - bugfix 2937651
 *  kchiasso   11/20/02 - bugfix-2677323
 *  kchiasso   10/16/02 - ui review cleanup
 *  kchiasso   10/09/02 - ecm_patch_oct0902
 *  kchiasso   10/02/02 - ADA compliant
 *  mgoodric   09/10/02 - Fix Patch wizard selection
 *  kchiasso   05/30/02 - root url
 *  kchiasso   05/28/02 -
 *  kchiasso   04/23/02 - bugfix 2150967
 *
 *  @author  kChiasson
 *
-->

<page xmlns="http://bali.us.oracle.com/cabo/baja"
      xmlns:baja="http://bali.us.oracle.com/cabo/baja"
      xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
      xmlns:marlin="http://bali.us.oracle.com/cabo/marlin"
      xmlns:html="http://www.w3.org/TR/REC-html40"
      xmlns:data="http://bali.us.oracle.com/cabo/marlin">

  <baja:head  xmlns="http://bali.us.oracle.com/cabo/marlin"
              xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
              xmlns:html="http://www.w3.org/TR/REC-html40">
     <dataScope>
      <contents>
               <html:title>
                  <data:text>
                    <boundAttribute name="text">
                      <concat>
                        <dataObject select="loginTitle"
                                    source="getLoginTitle"/>
                        <fixed javaType="string">&nbsp;-&nbsp;</fixed>
                        <dataObject select="pageTitle"
                                    source="getPageTitle"/>
                     </concat>
                    </boundAttribute>
                  </data:text>
                </html:title>
     </contents>
      <provider>
        <data name="getPageTitle">
          <method class="oracle.sysman.eml.ecm.patch.PatchAddData" method="getPageTitle"/>
        </data>
        <data name="getLoginTitle">
          <method class="oracle.sysman.eml.ecm.util.EcmSessionUtil" method="getLoginTitle"/>
        </data>
      </provider>
    </dataScope>
  </baja:head>

   <!-- special handler to load help topic -->
   <handlers>
    <event name="null">
      <method class="oracle.sysman.eml.ecm.OnlineHelp"
              method="loadPatchHelpTopic"/>
    </event>
   </handlers>

  <baja:content xmlns="http://bali.us.oracle.com/cabo/marlin"
                xmlns:baja="http://bali.us.oracle.com/cabo/baja"
                xmlns:marlin="http://bali.us.oracle.com/cabo/marlin"
                xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
                xmlns:html="http://www.w3.org/TR/REC-html40">

 <body>
 <contents>

   <dataScope>
      <contents>

<script>
	<html:noScript>
	JavaScript is not supported by your browser. Oracle requires JavaScript
	support to completely render this page
	</html:noScript>
<contents>
 function delimitSpaceToCaret(chkStr)
  {
    var newStr = "";
    var cmpStr = "";
    var space = " ";
    var caret = "^";

    strBegLoc = 0;
    spcLoc = chkStr.indexOf(space);
    while ( spcLoc > -1)
    {
        newStr = newStr+chkStr.substr(strBegLoc,spcLoc)+caret;
        cmpStr = chkStr.substr(strBegLoc+spcLoc+1);
        spcLoc = cmpStr.indexOf(space);
        strBegLoc = newStr.length;
    }
    // add the last chunk
    if (cmpStr.length > 0)
        newStr = newStr+cmpStr;

    if (newStr.length > 0)
     return newStr;
    else
     return chkStr;

  }

 function setFamily()
  {
    var parentVal = "-1";
    var parentText = "";
    var parentRef = document.patchCacheAdd.product_family;

    if (parentRef!=(void 0))
    {
        parentVal = parentRef.options[parentRef.selectedIndex].value;
        parentText = parentRef.options[parentRef.selectedIndex].text;

        var clear = ""; // visual display
        // clear the currently selected release and product fields
        document.patchCacheAdd.productId.value=clear;
        document.patchCacheAdd.releaseId.value=clear;
        document.patchCacheAdd.productLov.value=clear;
        if (document.patchCacheAdd.releaseLov.value != "any")
        {
            document.patchCacheAdd.releaseLov.value=clear;
        }
    }

  }

// MUST select a valid product - any is not valid here
 function isProductSelected()
 {
    var productName = document.patchCacheAdd.productLov.value;

    var res = ((productName == null) || (productName.length == 0));
    if ( res )
    {
        // kmc: not NLS compliant 
        mesg = document.forms[0].alertMessage.value;
        alert(mesg);
        document.patchCacheAdd.productLov.focus;
        document.patchCacheAdd.productLov.select;
        return false;
    }
    else
    {
      return true;  
    }

 }

 function setProductRedirValue()
  {
    var parentRef = document.patchCacheAdd.product_family;
    var familyId = parentRef.options[parentRef.selectedIndex].value;
    var familyName = parentRef.options[parentRef.selectedIndex].text;
    var productName = document.patchCacheAdd.productLov.value;

    var contextpath = document.patchCacheAdd.contextPath.value;
    var path = contextpath + "ecm/patch/productListLov";
    var params = "$familyId="+familyId+"$familyName="+familyName+"$productName="+productName
    params = params + "$isCache=true";
    var imagepath = document.patchCacheAdd.imagePath.value;
    var redir = imagepath + "cabo/jsps/frameRedirect.jsp?redirect="+path+delimitSpaceToCaret(params);

    // set hidden param to use in openWindow
    document.patchCacheAdd.productRedir.value=redir;
    document.patchCacheAdd.productName.value=productName;
  }

 function setReleaseRedirValue()
  {
    var parentRef = document.patchCacheAdd.product_family;
    var familyId = parentRef.options[parentRef.selectedIndex].value;
    var familyName = parentRef.options[parentRef.selectedIndex].text;
    var productId = document.patchCacheAdd.productId.value;
    var productName = document.patchCacheAdd.productLov.value;
    var releaseName = document.patchCacheAdd.releaseLov.value;

    res = isProductSelected();
    if (res )
    {
      var contextpath = document.patchCacheAdd.contextPath.value;
      var path = contextpath + "ecm/patch/releaseListLov";
      var params = "$familyId="+familyId+"$productId="+productId+"$productName="+productName+"$releaseName="+releaseName;
      params = params + "$isCache=true";
      var imagepath = document.patchCacheAdd.imagePath.value;
      var redir = imagepath + "cabo/jsps/frameRedirect.jsp?redirect="+path+delimitSpaceToCaret(params);

      // set hidden param to use in openWindow
//    alert("redir"+redir);
      document.patchCacheAdd.releaseRedir.value=redir;
      document.patchCacheAdd.releaseName.value=releaseName;
    }
  }

 function productListCallBack(lovwin, event)
  {
    // needed to save both the productName for display and the productId
    // for lookup

    var text = lovwin.productName;
    var value = lovwin.productId;
    if (text!=(void 0))
    {
        document.patchCacheAdd.productLov.value = text;
        // value used to lookup ARU patch
        document.patchCacheAdd.productId.value = value;

/*
        var clear="";
        // clear the currently selected release
        document.patchCacheAdd.releaseId.value=clear;
        if (document.patchCacheAdd.releaseLov.value != "any")
        {
            document.patchCacheAdd.releaseLov.value=clear;
        }
*/
    }
  }

  function releaseListCallBack(lovwin, event)
  {
    // needed to save both the productName for display and the productId
    // for lookup

    var text = lovwin.releaseName;
    var value = lovwin.releaseId;

    if (text!=(void 0))
    {
       document.patchCacheAdd.releaseLov.value = lovwin.releaseName;
       // value used to lookup ARU patch
       document.patchCacheAdd.releaseId.value = lovwin.releaseId;
    }
  }

</contents>
</script>
<html:noScript>
  "This page uses JavaScript to perform the list of values lookup. Your browser either does not support JavaScript, or it is disabled.  Please enable JavaScript, or upgrade your browser."
</html:noScript>

        <form name="patchCacheAdd" usesUpload="true" method="GET" destination="?event=SubmitJob">
        <contents>
<!-- We need to preserve the following two id values -
     They are saved in the pwo on Search, and reloaded after results are
     populated.  The LOV simply preserves the text, not the id's.
     We need the id's to do the lookup.
-->
            <formValue name="productId" uix:value="productId@loadAddData"/>
            <formValue name="releaseId" uix:value="releaseId@loadAddData"/>
            <formValue name="contextPath" uix:value="contextPath@getContextPath"/>
            <formValue name="imagePath" uix:value="imagePath@getImagePath"/>
<!-- The remaining ids are maintained for redirection.  We need
     to pass any partially defined productName or releaseName to the
     LOV popup
-->
            <formValue name="productName"/>
            <formValue name="productRedir"/>
            <formValue name="releaseName"/>
            <formValue name="releaseRedir"/>
            

          <pageLayout xmlns="http://bali.us.oracle.com/cabo/marlin"
             uix:title="pageTitle@getHeaderTitle">

          <mediumAdvertisement>
            <include baja:node="../../oemBanner" />
          </mediumAdvertisement>
          <globalButtons>
            <include baja:node="../../globalButtonBar" />
          </globalButtons>
          <marlin:tabs>
            <include baja:node="../../globalTabs" />
          </marlin:tabs>
          <marlin:pageHeader>
            <include baja:node="../../globalHeader" />
          </marlin:pageHeader>

          <marlin:location>
            <include baja:node="../../breadCrumbs" />
          </marlin:location>

          <copyright>
            <include baja:node="../../copyright"/>
          </copyright>

       <pageButtons>
        <pageButtonBar>
        <contents>

            <button value="Cancel" 
                          uix:text="BTN_CANCEL@ResourceBundle" 
                          uix:destination="contextPath@getPatchContextPath"/>

            <submitButton name="event" 
                          formSubmitted="true" value="SubmitJob" 
                          uix:text="BTN_UPLOAD@ResourceBundle"/>
        </contents>
        </pageButtonBar>
       </pageButtons>


        <contents>

	  <switcher uix:childName="swlibState@swlibUploadState">
		<case name="fail">
		 <messageBox automatic="false"
			     text="Software Library Upload Status"
			     uix:message="swlibInfo@swlibUploadState"
			     messageType="error"
		  />
		</case>
		<default>
		  <messageBox automatic="true"/>
		</default>
	  </switcher>

	  <switcher uix:childName="patchCacheState@patchCacheUploadState">
		<case name="fail">
		 <messageBox automatic="false"
			     text="Patch Cache Upload Status"
			     uix:message="patchCacheInfo@patchCacheUploadState"
			     messageType="error"
		  />
		</case>
	  </switcher>

            <!-- credentials not set -->
           <switcher data:childName="configError@configStatus">
             <case name="true">
             <messageBox messageType="warning" data:message="configMsg@configStatus">
              <contents>
                <flowLayout>
                  <contents>
                    <link data:text="CONFIG_PATCHSETUP@ResourceBundle" data:destination="configDest@configStatus" />
                  </contents>
                </flowLayout>
              </contents>
             </messageBox>
             </case>
             </switcher>


            <switcher uix:childName="status@loadAddData" childName="success">
            <case name="failure">
                <messageBox automatic="false"
                    uix:text="errHdr@loadAddData"
                    uix:message="errMsg@loadAddData"
                    messageType="error" />
            </case>
            <case name="success">

              <stackLayout>
              <contents>

                    <styledText styleClass="OraInstructionText"
                    uix:text = "PCA_MESSAGE@ResourceBundle"/>

                    <spacer height="5"/>
                    
                    <stackLayout cols="2">
                    <contents>

                      <rowLayout>
                      <contents>

                        <labeledFieldLayout width="0" fieldWidth="0" labelWidth="0" columns="1">
                        <contents>

                            <rowLayout>
                            <contents>
                              <messageFileUpload
                                uix:prompt="PCA_PATCHFILE@ResourceBundle"
                                columns="62"
                                name="patchFileName"
                                required = "yes"
                                uix:message="PCA_PATCHFFORMAT@ResourceBundle"
                                uix:text="patchFileName@loadAddData">
                              </messageFileUpload>
                             </contents>
                             </rowLayout>
<!--
                             <rowLayout>
                             <contents>
                              <messageFileUpload
                                uix:prompt="PCA_READMEFILE@ResourceBundle"
                                columns="62"
                                uix:id="PCA_README_ID@ResourceBundle"
                                name="readmeFileName"
                                uix:message="PCA_READMEFFORMAT@ResourceBundle"
                                uix:text="readmeFileName@loadAddData">
                              </messageFileUpload>
                             </contents>
                             </rowLayout>
-->

                            </contents>
                            </labeledFieldLayout>

                        </contents>
                        </rowLayout>

                       </contents>
                       </stackLayout>

                        <header uix:text="PCA_PATCHATTR@ResourceBundle">
                        <contents>
                        <styledText styleClass="OraInstructionText"
                        uix:text = "PCA_MESSAGE2@ResourceBundle" />

                        <html:br> </html:br>
 

  <labeledFieldLayout labelWidth="25%"
                    fieldWidth="80%"
                    columns="1"
                    width="80%" >
  <contents>

        <messageTextInput uix:prompt="OPT_PATCHNAME@ResourceBundle"
                  name = "patchName"
                  id = "patchName"
                  required = "yes"
                  columns="16"
                  uix:text="patchName@loadAddData"/>

        <messageChoice name="patchType"
                  required = "yes"
                  uix:prompt="OPT_PATCHTYPE@ResourceBundle"
                  uix:selectedValue="patchType@loadAddData">
                  <contents >
                    <option value="Patch" uix:text="JOBTYPE_PATCH@ResourceBundle"/>
                    <option value="Patchset" uix:text="JOBTYPE_PATCHSET@ResourceBundle"/>
                  </contents>
        </messageChoice>

        <messageDateField name="createdDate"
                required = "yes"
                uix:prompt="XPDR_DATEIN@ResourceBundle"
                uix:value="createdDate@loadAddData"
                uix:tip="TIP_DATEOFPATCH@ResourceBundle"
                columns="11">
            <onSubmitValidater>
            <date dateStyle="short"/>
            </onSubmitValidater>
        </messageDateField>

        <messageTextInput uix:prompt="OPT_DESCRIPTION@ResourceBundle"
                  name = "patchDesc"
                  id = "patchDesc"
                  required = "yes"
                  columns="75"
                  uix:text="patchDesc@loadAddData"/>

        <messageChoice name="product_family" onChange="ret=setFamily();"
                  required = "yes"
                  uix:prompt="OPT_PRODUCTFAMILY@ResourceBundle"
                  uix:selectedValue="familyIdSel@loadAddData">    

            <contents uix:childData="product_familyList@loadAddData">
                <option name="optProductFamily" uix:text="product_familyName" uix:value="product_familyValue"/>
            </contents>

        </messageChoice>

        <messageLovField name="productLov"
                   required = "yes"
                   uix:text="productLovName@loadAddData"
                   columns="39"
                   uix:prompt="OPT_PRODUCT@ResourceBundle"
                   uix:shortDesc="SD_SELPROD@ResourceBundle"
                   uix:searchDesc="SD_SELPROD@ResourceBundle"
                   onClick= "   setProductRedirValue();
                                openWindow(top,
                                document.patchCacheAdd.productRedir.value,
                                'lovWindow',
                                {width:600, height:200},
                                true,
                                'dialog',
                                productListCallBack); " />

        <messageLovField name="releaseLov"
                   required = "yes"
                   uix:text="releaseLovName@loadAddData"
                   columns="39"
                   uix:prompt="OPT_RELEASE@ResourceBundle"
                   uix:shortDesc="SD_SELREL@ResourceBundle"
                   uix:searchDesc="SD_SELREL@ResourceBundle"
                   onClick="if (isProductSelected()) {
                                setReleaseRedirValue();
                                openWindow(top,
                                document.patchCacheAdd.releaseRedir.value,
                                'lovWindow',
                                {width:600, height:200},
                                true,
                                'dialog',
                                releaseListCallBack); }
                               return false;" />

         <messageChoice name="platform"
                required = "yes"
                uix:prompt="OPT_PLATFORM@ResourceBundle"
                uix:selectedValue="platformIdSel@loadAddData">
            <contents uix:childData="platformList@loadAddData">
                <option uix:text="platformName" uix:value="platformValue"/>
            </contents>
        </messageChoice>
        <formValue name="alertMessage" uix:value="CACHE_RELEASE_ALERT_MESG@ResourceBundle"/>

        <messageChoice name="language"
                required = "yes" 
                uix:prompt="OPT_LANGUAGE@ResourceBundle"
                uix:selectedValue="languageIdSel@loadAddData">
            <contents uix:childData="languageList@loadAddData">
                <option uix:text="languageName" uix:value="languageValue"/>
            </contents>
        </messageChoice>

        <messageTextInput uix:prompt="PDR_COMMENTS@ResourceBundle"
                  name = "comments"
                  id = "patchComments"
                  columns="75"
                  uix:text="patchComments@loadAddData"/>

	<!-- This part is commented by summukhe #5950883 
        	<messageCheckBox name="libraryComponent"
                uix:text="CHKPROMPT_LIBRARY_COMPONENT@ResourceBundle"
		uix:checked="createComponent@loadAddData"/>
	-->
 
	<messageCheckBox name="libraryComponent"
                uix:text="CHKPROMPT_UPLOAD_CACHE@ResourceBundle"
                uix:checked="createComponent@loadAddData"/>

    </contents>
    </labeledFieldLayout>
                       </contents>
                       </header>

              </contents>
              </stackLayout>

        </case>
        </switcher>

    </contents>
    </pageLayout>

     </contents>
     </form>

   </contents>
      <provider>

        <data name="configStatus">
          <method class="oracle.sysman.eml.ecm.util.EcmSessionUtil"
            method="getConfigStatus"/>
        </data>

        <data name="ResourceBundle">
          <bundle class = "oracle.sysman.eml.ecm.patch.util.PatchResourceBundle"/>
        </data>

        <data name="getHeaderTitle">
          <method class="oracle.sysman.eml.ecm.patch.PatchAddData" method="getPageTitle"/>
        </data>

        <data name="loadAddData">
          <method class="oracle.sysman.eml.ecm.patch.PatchAddData" method="populateAddData"/>
        </data>

        <data name="getPatchContextPath">
          <method class="oracle.sysman.eml.ecm.ContextPathData" method="getPatchCacheContextPath"/>
        </data>

        <data name="getContextPath">
          <method class="oracle.sysman.eml.ecm.ContextPathData" method="getContextPath"/>
        </data>

        <data name="getImagePath">
          <method class="oracle.sysman.eml.ecm.ContextPathData" method="getImagePath"/>
        </data>

	<data name="patchCacheUploadState">
	 <method class="oracle.sysman.eml.ecm.patch.PatchAddHandler" method="getPatchCacheStatus" />
	</data>

	<data name="swlibUploadState">
	 <method class="oracle.sysman.eml.ecm.patch.PatchAddHandler" method="getSwlibStatus" />
	</data>

      </provider>

    </dataScope>
  </contents>
  </body>

  </baja:content>

  <handlers>

    <event name="SubmitJob">
       <method class="oracle.sysman.eml.ecm.patch.PatchAddHandler"
        method="submitJob"/>
     </event>

  </handlers>

</page>
