TerminationDetailCO

package xxhr.oracle.apps.per.selfservice.termination.webui;

import java.io.PrintStream;
import java.sql.CallableStatement;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Types;

import java.text.SimpleDateFormat;

import oracle.apps.fnd.common.MessageToken;
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.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OABodyBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
import oracle.apps.per.selfservice.termination.webui.TerminationDetailCO;
import oracle.jbo.Row;

import oracle.jdbc.OracleCallableStatement;

public class XXHRTerminationDetailCO58 extends TerminationDetailCO {
    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);

//        OAApplicationModule rootAM = pageContext.getRootApplicationModule();
//        OAApplicationModule termAM = (OAApplicationModule)rootAM.findApplicationModule("TerminationAM");
//        OAViewObject termDetailsVO= (OAViewObject)termAM.findViewObject("TerminationDetailsVO");
//        Row termDetailsVORow = termDetailsVO.getCurrentRow();
        //termDetailsVORow.setAttribute("ActualTerminationDate",);
       
        OAApplicationModule termAM = (OAApplicationModule)pageContext.getApplicationModule(webBean);
        OAViewObject termDetailsVO= (OAViewObject)termAM.findViewObject("TerminationDetailsVO");
        Row termDetailsVORow = termDetailsVO.getCurrentRow();

        OAApplicationModule aml = pageContext.getApplicationModule(webBean);
        int person_id = pageContext.getEmployeeId();
        pageContext.writeDiagnostics(webBean,
                                     "person_id in Resign Page : " + person_id,
                                     4);
        OADBTransaction tr = aml.getOADBTransaction();
        try {
            pageContext.writeDiagnostics(webBean, "After Try : ", 4);
            CallableStatement cs = null;
            String stmt =
                "BEGIN ABRAJ_EMP_RESIGN_LAST_DATE_KK(?,?,?,?,?,?); END;";
            cs = (OracleCallableStatement)tr.createCallableStatement(stmt, 0);
            cs.setInt(1, person_id);
            cs.registerOutParameter(2, Types.VARCHAR);
            cs.registerOutParameter(3, Types.NUMERIC);
            cs.registerOutParameter(4, Types.VARCHAR);
            cs.registerOutParameter(5, Types.VARCHAR);
            cs.registerOutParameter(6, Types.DATE);           
            try {
                cs.execute();
            } catch (Exception e) {
                throw new OAException(e.getMessage(), (byte)0);
            }
            try {
//                OAMessageStyledTextBean AddLastDate =
//                    (OAMessageStyledTextBean)webBean.findChildRecursive("PerTerminationDate");
//
//                pageContext.writeDiagnostics(webBean,
//                                             "After CallableStatement : ", 4);
//
//                AddLastDate.setValue(pageContext, cs.getDate(6));
            termDetailsVORow.setAttribute("ActualTerminationDate", cs.getDate(6));

                // code for sysdate
                String sysdate = cs.getString(4);
                OABodyBean bodyBean = (OABodyBean)pageContext.getRootWebBean();
                String javaS =
                    "return document.getElementById(\"HrTermNotificationDate\").value=\"" +
                    sysdate + "\"";
                bodyBean.setOnLoad(javaS);

                if (cs.getString(3).equals("30")) {
                    throw new OAException("NOTE : You have to Serve 1 Month(s) notice period.",
                                          (byte)2);
                }

                if (cs.getString(3).equals("90")) {
                    throw new OAException("NOTE : You have to Serve 3 Month(s) notice period.",
                                          (byte)2);
                }

            } catch (NullPointerException ne) {
                String s = "";
                throw new OAException(" You Have To Serve the Last Date : " +
                                      cs.getString(2), (byte)2);
            }

            cs.close();
            tr.commit();
        } catch (SQLException s) {
            System.out.println(s.getMessage());
        }
    }

    public void processFormRequest(OAPageContext pageContext,
                                   OAWebBean webBean) {

        //start getting current value        
        OAMessageDateFieldBean effDateOld =
            (OAMessageDateFieldBean)webBean.findChildRecursive("HrTermNotificationDate");
           
        SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd");           
        java.util.Date notifDate = null;
        java.util.Date sysdate = null;
        String SnotifDate = null;
        String Ssysdate = null;

        //SnotifDate = simpledateformat.format(notifDate);
        //Ssysdate = simpledateformat.format(sysdate);
         sysdate = pageContext.getCurrentDBDate();

                try {
                    notifDate = simpledateformat.parse(effDateOld.getValue(pageContext).toString());
                } catch (Exception e) {
                    e.printStackTrace();
                }                                

        SnotifDate = simpledateformat.format(notifDate);
        Ssysdate = simpledateformat.format(sysdate);
        if (!SnotifDate.equals(Ssysdate)) {
            MessageToken[] tokens = { };
            throw new OAException("PER", "XXA_ABRAJ_NTF_DATE_MSG", tokens,
                                  OAException.ERROR, null);
        }

//        if(true) {
//           
//            throw new OAException("notif date: "+SnotifDate+", sysdate: " +Ssysdate, OAException.CONFIRMATION);
//        }

        super.processFormRequest(pageContext, webBean);
    }
}

No comments:

Post a Comment