DetailsPageGlueCO

package xxcus.oracle.apps.ap.oie.entry.lines.webui;

import com.sun.java.util.collections.ArrayList;
import com.sun.java.util.collections.HashMap;

import java.io.IOException;
import java.io.Serializable;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

import java.text.SimpleDateFormat;

import java.util.Enumeration;
import java.util.Vector;

import oracle.apps.ap.oie.common.utility.OIECommonConstants;
import oracle.apps.ap.oie.common.utility.OIENoDepsUtil;
import oracle.apps.ap.oie.utility.AttachmentsUtility;
import oracle.apps.ap.oie.utility.OIEUtil;
import oracle.apps.ap.oie.utility.TextCalculatorUtility;
import oracle.apps.ap.oie.common.server.ExpenseReportLinesVORowImpl;
import oracle.apps.ap.oie.entry.lines.webui.DetailsPageGlueCO;
import oracle.apps.ap.oie.common.server.ExpenseReportHeaderVOImpl;
import oracle.apps.fnd.common.ErrorStack;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.flexj.DescriptiveFlexfield;
import oracle.apps.fnd.flexj.FlexException;
import oracle.apps.fnd.flexj.Segment;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OADBTransactionImpl;
import oracle.apps.fnd.framework.server.OAExceptionUtils;
import oracle.apps.fnd.framework.webui.OADataBoundValueViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAPartialPageRenderUtils;
import oracle.apps.fnd.framework.webui.OAWebBeanUtils;
import oracle.apps.fnd.framework.webui.beans.OABodyBean;
import oracle.apps.fnd.framework.webui.beans.OADescriptiveFlexBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageAttachmentLinkBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
import oracle.apps.fnd.framework.webui.beans.nav.OANavigationBarBean;
import oracle.apps.fnd.framework.webui.beans.nav.OAPageButtonBarBean;
import oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean;

import oracle.cabo.ui.AttributeKey;
import oracle.cabo.ui.data.bind.ToIntegerBoundValue;

import oracle.jdbc.OracleCallableStatement;
import oracle.apps.ap.oie.common.server.DetailsPagePVORowImpl;
import oracle.apps.ap.oie.common.server.ExpenseReportHeaderVORowImpl;
import oracle.cabo.ui.RenderingContext;

public class DetailsPageGlueCOEx213 extends DetailsPageGlueCO {
    public DetailsPageGlueCOEx213() {
    }

    public void processRequest(OAPageContext pc, OAWebBean wb) {

        super.processRequest(pc, wb);
       
        OAApplicationModule rootAM = (OAApplicationModule)pc.getRootApplicationModule();
        OAApplicationModule oieAM = (OAApplicationModule)rootAM.findApplicationModule("OIECommonAM");
        OAViewObject dpvo = (OAViewObject)oieAM.findViewObject("DetailsPagePVO");
        OAViewObject erlvo = (OAViewObject)oieAM.findViewObject("ExpenseReportLinesVO");
        OAViewObject itemlinesvo = (OAViewObject)oieAM.findViewObject("ItemizedLinesVO");
        OAViewObject hdrvo = (OAViewObject) oieAM.findViewObject("ExpenseReportHeaderVO");
        
        DetailsPagePVORowImpl dpvoRow = null;
        ExpenseReportLinesVORowImpl erlvoRow = null;
        ExpenseReportLinesVORowImpl erlvoItemRow= null;
        ExpenseReportHeaderVORowImpl hdrvoRow = null;
       
        Boolean itemLine = false;
        String wpid = null;
        String wpLineid = null;
        String reportID = null;
        String dffkey = null;
       
        OADescriptiveFlexBean dff = null;
        OADescriptiveFlexBean dffChild = null;
       
        OAMessageLovInputBean dff5 = null;
        String dff5_val = null;
        OAMessageLovInputBean dff5Child = null;
        String dff5_valChild = null;
       
        OAMessageTextInputBean dff6 = null;
        OAMessageTextInputBean dff6Child = null;
       
        Enumeration x = null;
       
        //get report type ID
        if(hdrvo!=null)
        {
            hdrvoRow = (ExpenseReportHeaderVORowImpl) hdrvo.getCurrentRow();
            if (hdrvoRow!=null) reportID = hdrvoRow.getExpenseReportId().toString();
            {
                //get expenseTypeID
                try {
                        Connection conn1 =
                            pc.getApplicationModule(wb).getOADBTransaction().getJdbcConnection();              
                                        String Query1 =
                                        "select parameter_id \n" +
                                        "from AP_EXPENSE_REPORT_PARAMS_ALL   \n" +
                                        "where 1=1\n" +
                                        "and CATEGORY_CODE = 'AIRFARE'\n " +
                                        "and upper(prompt) like 'AIR%'\n " +
                                        "and expense_report_id = " + reportID;
   
                        PreparedStatement stmt1 = conn1.prepareStatement(Query1);
                        ResultSet resultset1 = stmt1.executeQuery();   
                        resultset1.next();
                        dffkey = resultset1.getString("parameter_id");

                               
                    } catch (Exception exception) {
                            throw new OAException("Unable to find Expense Report  Type" + exception,
                                      OAException.ERROR);}
            }
           
        }
        pc.writeDiagnostics(wb,"my exp report id:" + reportID,1);
       
        //Normal Lines
         if (erlvo!=null)
         {
            erlvoRow=(ExpenseReportLinesVORowImpl)erlvo.getCurrentRow();  
            if (erlvoRow!=null && erlvoRow.getAttribute("WebParameterId")!=null)
                wpid = erlvoRow.getAttribute("WebParameterId").toString();
            pc.writeDiagnostics(wb,"my normal lineType: "+wpid, 1);
         }

        //Itemized
         if(dpvo!=null)
         {
             dpvoRow=(DetailsPagePVORowImpl)dpvo.getCurrentRow();
             if(dpvoRow!=null) itemLine = (Boolean)dpvoRow.getAttribute("IsItemizedLine");
             pc.writeDiagnostics(wb,"my itemized line boolean: "+itemLine, 1);
         }

        //Itemized expensetype
        if(itemlinesvo!=null)
        {
            erlvoItemRow =(ExpenseReportLinesVORowImpl)itemlinesvo.getCurrentRow();
            if(erlvoItemRow!=null && erlvoItemRow.getAttribute("WebParameterId")!=null)
                wpLineid = erlvoItemRow.getAttribute("WebParameterId").toString();
            pc.writeDiagnostics(wb,"my itemLine type: "+wpLineid, 1);
        }
       
               
        //not itemized               
        if (wpid != null && !itemLine)
        {
            if (dffkey.equals(wpid))
            {
                dff = (OADescriptiveFlexBean)wb.findIndexedChildRecursive("DFF_"+dffkey);
               
                dff.processFlex(pc);
                RenderingContext con = (RenderingContext) pc.getRenderingContext();
                //x = dff.getChildNames(con);
                x=dff.getAttributeNames(con).toString();
                Integer i = 0;
                pc.writeDiagnostics(wb,"my enum:" +x,1);
                if(x!=null)
                {
                    while (x.hasMoreElements())
                    {
                        pc.writeDiagnostics(wb,"myDFF Elements-"+i+":"+(String)x.nextElement(),1);
                    }
                }
               
                dff5 = (OAMessageLovInputBean)dff.findChildRecursive("DFF_"+dffkey+"5");
                if (dff5.getValue(pc) != null) {
                    dff5_val = dff5.getValue(pc).toString();
                }
                dff6 = (OAMessageTextInputBean)dff.findChildRecursive("DFF_"+dffkey+"6");

                if (dff5_val == null || dff5_val == "") {
                    dff6.setRendered(false);
                    //dff6.setRequired("no");
                }

                if ((dff5_val != null || dff5_val != "") &&
                    "Other".equals(dff5_val)) {
                    dff6.setRendered(true);
                    //dff6.setRequired("yes");
                }

                if ((dff5_val != null || dff5_val != "") &&
                    !"Other".equals(dff5_val)) {
                    dff6.setRendered(false);
                    //dff6.setRequired("no");
                }
            }
        }
       
        //itemized
        if (wpLineid!=null && itemLine)
        {
             if (dffkey.equals(wpLineid))
             {
                 dffChild = (OADescriptiveFlexBean)wb.findChildRecursive("ChildDFF_"+dffkey);
                 dff5Child = (OAMessageLovInputBean)dffChild.findChildRecursive("ChildDFF_"+dffkey+"5");
                 if (dff5Child.getValue(pc) != null)
                 {
                     dff5_valChild = dff5Child.getValue(pc).toString();
                 }
                 dff6Child = (OAMessageTextInputBean)dffChild.findChildRecursive("ChildDFF_"+dffkey+"6");
   
                 if (dff5_valChild == null || dff5_valChild == "")
                 {
                     dff6Child.setRendered(false);
                     //dff6.setRequired("no");
                 }
   
                 if ((dff5_valChild != null || dff5_valChild != "") && "Other".equals(dff5_val))
                 {
                     dff6Child.setRendered(true);
                     //dff6.setRequired("yes");
                 }
   
                 if ((dff5_valChild != null || dff5_valChild != "") && !"Other".equals(dff5_val)) {
                     dff6Child.setRendered(false);
                     //dff6.setRequired("no");
                 }
             }
         }
    }

   
    public void processFormRequest(OAPageContext pc, OAWebBean wb)
    {
   
        super.processFormRequest(pc, wb);
       
        OAApplicationModule am = (OAApplicationModule)pc.getApplicationModule(wb);
        OADBTransaction tr = am.getOADBTransaction();       
     
        OAApplicationModule rootAM = (OAApplicationModule)pc.getRootApplicationModule();
        OAApplicationModule oieAM = (OAApplicationModule)rootAM.findApplicationModule("OIECommonAM");
        OAViewObject dpvo = (OAViewObject)oieAM.findViewObject("DetailsPagePVO");
        OAViewObject erlvo = (OAViewObject)oieAM.findViewObject("ExpenseReportLinesVO");
        OAViewObject itemlinesvo = (OAViewObject)oieAM.findViewObject("ItemizedLinesVO");
        OAViewObject hdrvo = (OAViewObject) oieAM.findViewObject("ExpenseReportHeaderVO");
       
        OAMessageDateFieldBean startdate = null;
       
        DetailsPagePVORowImpl dpvoRow = null;
        ExpenseReportLinesVORowImpl erlvoRow = null;
        ExpenseReportLinesVORowImpl erlvoItemRow= null;
        ExpenseReportHeaderVORowImpl hdrvoRow = null;
       
        Boolean itemLine = false;
        String wpid = null;
        String wpLineid = null;
        String reportID = null;
        String dffkey = null;
       
        OADescriptiveFlexBean dff = null;
        OAMessageLovInputBean dff5 = null;
        OAMessageTextInputBean dff6 = null;
        OAMessageLovInputBean dff8 = null;
        OAMessageTextInputBean dff10 = null;
        OAMessageTextInputBean dff11 = null;

        String dff5_val = null;
        String dff6_val = null;
        String dff8_val = null;
        String dff10_val = null;
        String dff11_val = null;
       
        Integer param1 = pc.getUserId();
        String param2 = null;
        String param3 = null;
        String param4 = null;
        String param5 = null;
        String eligibility = null;
        String variance = null;
       
        if (pc.isLovEvent())
        {
            //get report type ID
            if(hdrvo!=null)
            {
                hdrvoRow = (ExpenseReportHeaderVORowImpl) hdrvo.getCurrentRow();
                if (hdrvoRow!=null) reportID = hdrvoRow.getExpenseReportId().toString();
                {
                    //get expenseTypeID
                    try {
                            Connection conn1 =
                                pc.getApplicationModule(wb).getOADBTransaction().getJdbcConnection();              
                                            String Query1 =
                                            "select parameter_id \n" +
                                            "from AP_EXPENSE_REPORT_PARAMS_ALL   \n" +
                                            "where 1=1\n" +
                                            "and CATEGORY_CODE = 'AIRFARE'\n " +
                                            "and upper(prompt) like 'AIR%'\n " +
                                            "and expense_report_id = " + reportID;
           
                            PreparedStatement stmt1 = conn1.prepareStatement(Query1);
                            ResultSet resultset1 = stmt1.executeQuery();   
                            resultset1.next();
                            dffkey = resultset1.getString("parameter_id");

                                   
                        } catch (Exception exception) {
                                throw new OAException("Unable to find Expense Report  Type" + exception,
                                          OAException.ERROR);}
                }
               
            }
            pc.writeDiagnostics(wb,"my exp report id:" + reportID,1);
           
            //Normal Lines
             if (erlvo!=null)
             {
                erlvoRow=(ExpenseReportLinesVORowImpl)erlvo.getCurrentRow();  
                if (erlvoRow!=null) wpid = erlvoRow.getAttribute("WebParameterId").toString();
                pc.writeDiagnostics(wb,"my pfr normal lineType: "+wpid, 1);
             }
   
            //Itemized
             if(dpvo!=null)
             {
                 dpvoRow=(DetailsPagePVORowImpl)dpvo.getCurrentRow();
                 if(dpvoRow!=null) itemLine = (Boolean)dpvoRow.getAttribute("IsItemizedLine");
                 pc.writeDiagnostics(wb,"my pfr itemized line boolean: "+itemLine, 1);
             }
   
            //Itemized expensetype
            if(itemlinesvo!=null)
            {
                erlvoItemRow =(ExpenseReportLinesVORowImpl)itemlinesvo.getCurrentRow();
                if(erlvoItemRow!=null) wpLineid = erlvoItemRow.getAttribute("WebParameterId").toString();
                pc.writeDiagnostics(wb,"my pfr itemLine type: "+wpLineid, 1);
            }
                      
           
           
            /////not itemized               
            if (wpid != null && !itemLine)
            {
                pc.writeDiagnostics(wb,"my pfr: "+wpid+","+itemLine,1);
                if (dffkey.equals(wpid))
                {
                  dff = (OADescriptiveFlexBean)wb.findIndexedChildRecursive("DFF_"+dffkey);
                  if (dff!= null)
                  {
                    dff5 = (OAMessageLovInputBean)dff.findChildRecursive("DFF_"+dffkey+"5");
                    dff6 = (OAMessageTextInputBean)dff.findChildRecursive("DFF_"+dffkey+"6");
                    dff8 = (OAMessageLovInputBean)dff.findChildRecursive("DFF_"+dffkey+"8");
                    dff10 = (OAMessageTextInputBean)dff.findChildRecursive("DFF_"+dffkey+"10");
                    dff11 = (OAMessageTextInputBean)dff.findChildRecursive("DFF_"+dffkey+"11");
                   
                    //StartDate -param4
                    startdate = (OAMessageDateFieldBean)wb.findChildRecursive("StartDate");
                    if (startdate.getValue(pc) != null)
                    {
                        try
                        {
                            param4 = startdate.getValue(pc).toString();
                            //pc.writeDiagnostics(wb, "myLine Start Date: " + param4, 1);
                        } catch (Exception e) {e.printStackTrace();}
                    }               
                   
                    //business reason -param5
                    if (dff8.getValue(pc) != null) {
                        dff8_val = dff8.getValue(pc).toString();
                        param5 = dff8_val;
                    }               
                   
                    if (pc.getParameter("AirTravelType") != null &&
                        pc.getParameter("AirTicketClass") != null &&
                        param4 != null && param5!=null)
                    {
                        param2 = pc.getParameter("AirTicketClass").toString();
                        param3 = pc.getParameter("AirTravelType").toString();
                       
                        try {
                                CallableStatement cs = null;
                                String stmt =
                                    "BEGIN XXAB_IEX_VARIANCE_PKG.XXAB_IEX_AF_VARIANCE_PRC(?,?,?,?,?,?,?); END;";
                                cs = (OracleCallableStatement)tr.createCallableStatement(stmt,0);
                                cs.registerOutParameter(6, Types.VARCHAR);
                                cs.registerOutParameter(7, Types.VARCHAR);
                                cs.setInt(1, param1);
                                cs.setString(2, param2);
                                cs.setString(3, param3);
                                cs.setString(4, param4);
                                cs.setString(5, param5);
                                cs.execute();
                                //dff.setFlexContext(pc, "Airfare");
                                //dff.processFlex(pc);
   
                                if (cs.getString(6)!=null && cs.getString(7)!=null)
                                {
                                    eligibility = cs.getString(6).toString();
                                    variance = cs.getString(7).toString();
                                    dff10.setText("");
                                    dff11.setText("");
                                    dff10.setText(eligibility.toString());
                                    dff11.setText(variance.toString());
                                }
           
                                cs.close();
                                tr.commit();
                           } catch (SQLException s) {throw new OAException("my error:" + s.getMessage()); }
                    }
                   
                    //set other destination               
                    if (dff5.getValue(pc) != null) {
                        dff5_val = dff5.getValue(pc).toString();
                    }
   
                    if (dff5_val == null || dff5_val == "") {
                        dff6.setRendered(false);
                        //dff6.setRequired("no");
                    }
   
                    if ((dff5_val != null || dff5_val != "") &&
                        "Other".equals(dff5_val)) {
                        dff6.setRendered(true);
                        //dff6.setRequired("yes");
                    }
   
                    if ((dff5_val != null || dff5_val != "") &&
                        !"Other".equals(dff5_val)) {
                        dff6.setRendered(false);
                        //dff6.setRequired("no");
                    }
                    //end other destination
                  }
                }
            } ////end non-itemized      
         
             /////itemized               
             if (wpLineid!=null && itemLine)
             {
                pc.writeDiagnostics(wb,"my pfr: "+wpLineid+","+itemLine,1);
                 if (dffkey.equals(wpLineid))
                 {
                    dff = (OADescriptiveFlexBean)wb.findIndexedChildRecursive("ChildDFF_"+dffkey);
                    if (dff!=null)
                    {
                     dff5 = (OAMessageLovInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"5");
                     dff6 = (OAMessageTextInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"6");
                     dff8 = (OAMessageLovInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"8");
                     dff10 = (OAMessageTextInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"10");
                     dff11 = (OAMessageTextInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"11");
                    
                     //StartDate -param4
                     startdate = (OAMessageDateFieldBean)wb.findChildRecursive("ChildStartDate");
                     if (startdate.getValue(pc) != null)
                     {
                         try
                         {
                             param4 = startdate.getValue(pc).toString();
                             pc.writeDiagnostics(wb, "myLineItemized Start Date: " + param4, 1);
                         } catch (Exception e) {e.printStackTrace();}
                     }               
                    
                     //business reason -param5
                     dff8 = (OAMessageLovInputBean)dff.findChildRecursive("ChildDFF_"+dffkey+"8");
                     if (dff8.getValue(pc) != null) {
                         dff8_val = dff8.getValue(pc).toString();
                         param5 = dff8_val;
                     }               
                    
                     if (pc.getParameter("ChildAirTravelType") != null &&
                         pc.getParameter("ChildAirTicketClass") != null &&
                         param4 != null && param5!=null)
                     {
                         param2 = pc.getParameter("ChildAirTicketClass").toString();
                         param3 = pc.getParameter("ChildAirTravelType").toString();
                        
                         try {
                                 CallableStatement cs = null;
                                 String stmt =
                                     "BEGIN XXAB_IEX_VARIANCE_PKG.XXAB_IEX_AF_VARIANCE_PRC(?,?,?,?,?,?,?); END;";
                                 cs = (OracleCallableStatement)tr.createCallableStatement(stmt, 0);
                                 cs.registerOutParameter(6, Types.VARCHAR);
                                 cs.registerOutParameter(7, Types.VARCHAR);
                                 cs.setInt(1, param1);
                                 cs.setString(2, param2);
                                 cs.setString(3, param3);
                                 cs.setString(4, param4);
                                 cs.setString(5, param5);
                                 cs.execute();
             //                        dff.setFlexContext(pc, "Airfare");
             //                        dff.processFlex(pc);
                                 eligibility = cs.getString(6);
                                 variance = cs.getString(7);
                
                                 dff10.setText("");
                                 dff11.setText("");
                                 dff10.setText(eligibility.toString());
                                 dff11.setText(variance.toString());
            
                                 cs.close();
                                 tr.commit();
                            } catch (SQLException s) {throw new OAException("my error:" + s.getMessage()); }
                     }
                    
                     //set other destination               
                     if (dff5.getValue(pc) != null) {
                         dff5_val = dff5.getValue(pc).toString();
                     }
           
                     if (dff5_val == null || dff5_val == "") {
                         dff6.setRendered(false);
                         //dff6.setRequired("no");
                     }
           
                     if ((dff5_val != null || dff5_val != "") &&
                         "Other".equals(dff5_val)) {
                         dff6.setRendered(true);
                         //dff6.setRequired("yes");
                     }
           
                     if ((dff5_val != null || dff5_val != "") &&
                         !"Other".equals(dff5_val)) {
                         dff6.setRendered(false);
                         //dff6.setRequired("no");
                     }
                   }
                     //end other destination
                 }
            } ////end itemized 
             pc.writeDiagnostics(wb,"my param1: "+param1
             +", param2: " +param2
             +",param3:"+param3
             +",param4:"+param4
             +",param5:"+param5
             +", param6:"+eligibility
             +",param7:"+variance,
             1);
        }
    }
}

1 comment:

Marlon Jayanka said...

Can I know the DOCUMENT PATH which DetailsPageGlueCOEx213 should attached in Oracle EBS R12

Post a Comment