OAF PLSQL Invocation from OAPLSQLEOImpl

package cnsi.oracle.apps.fnd.schema.server;

import java.sql.CallableStatement;
import java.sql.SQLException;

import oracle.apps.fnd.framework.server.OAEntityDefImpl;
import oracle.apps.fnd.framework.server.OAEntityImpl;

import oracle.apps.fnd.framework.server.OAPlsqlEntityImpl;

import oracle.jbo.Key;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.server.EntityDefImpl;

import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class EmpOAPlsqlEOImpl extends OAPlsqlEntityImpl {
    public static final int EMPNO = 0;
    public static final int ENAME = 1;
    public static final int JOB = 2;
    public static final int MGR = 3;
    public static final int HIREDATE = 4;
    public static final int SAL = 5;
    public static final int COMM = 6;
    public static final int DEPTNO = 7;
    private static OAEntityDefImpl mDefinitionObject;

    /**This is the default constructor (do not remove)
     */
    public EmpOAPlsqlEOImpl() {
    }

    /**Retrieves the definition object for this instance class.
     */
    public static synchronized EntityDefImpl getDefinitionObject() {
        if (mDefinitionObject == null) {
            mDefinitionObject = 
                    (OAEntityDefImpl)EntityDefImpl.findDefObject("cnsi.oracle.apps.fnd.schema.server.EmpOAPlsqlEO");
        }
        return mDefinitionObject;
    }

    /**Gets the attribute value for Empno, using the alias name Empno
     */
    public Number getEmpno() {
        return (Number)getAttributeInternal(EMPNO);
    }

    /**Sets <code>value</code> as the attribute value for Empno
     */
    public void setEmpno(Number value) {
        setAttributeInternal(EMPNO, value);
    }

    /**Gets the attribute value for Ename, using the alias name Ename
     */
    public String getEname() {
        return (String)getAttributeInternal(ENAME);
    }

    /**Sets <code>value</code> as the attribute value for Ename
     */
    public void setEname(String value) {
        setAttributeInternal(ENAME, value);
    }

    /**Gets the attribute value for Job, using the alias name Job
     */
    public String getJob() {
        return (String)getAttributeInternal(JOB);
    }

    /**Sets <code>value</code> as the attribute value for Job
     */
    public void setJob(String value) {
        setAttributeInternal(JOB, value);
    }

    /**Gets the attribute value for Mgr, using the alias name Mgr
     */
    public Number getMgr() {
        return (Number)getAttributeInternal(MGR);
    }

    /**Sets <code>value</code> as the attribute value for Mgr
     */
    public void setMgr(Number value) {
        setAttributeInternal(MGR, value);
    }

    /**Gets the attribute value for Hiredate, using the alias name Hiredate
     */
    public Date getHiredate() {
        return (Date)getAttributeInternal(HIREDATE);
    }

    /**Sets <code>value</code> as the attribute value for Hiredate
     */
    public void setHiredate(Date value) {
        setAttributeInternal(HIREDATE, value);
    }

    /**Gets the attribute value for Sal, using the alias name Sal
     */
    public Number getSal() {
        return (Number)getAttributeInternal(SAL);
    }

    /**Sets <code>value</code> as the attribute value for Sal
     */
    public void setSal(Number value) {
        setAttributeInternal(SAL, value);
    }

    /**Gets the attribute value for Comm, using the alias name Comm
     */
    public Number getComm() {
        return (Number)getAttributeInternal(COMM);
    }

    /**Sets <code>value</code> as the attribute value for Comm
     */
    public void setComm(Number value) {
        setAttributeInternal(COMM, value);
    }

    /**Gets the attribute value for Deptno, using the alias name Deptno
     */
    public Number getDeptno() {
        return (Number)getAttributeInternal(DEPTNO);
    }

    /**Sets <code>value</code> as the attribute value for Deptno
     */
    public void setDeptno(Number value) {
        setAttributeInternal(DEPTNO, value);
    }

    /**getAttrInvokeAccessor: generated method. Do not modify.
     */
    protected Object getAttrInvokeAccessor(int index, 
                                           AttributeDefImpl attrDef) throws Exception {
        switch (index) {
        case EMPNO:
            return getEmpno();
        case ENAME:
            return getEname();
        case JOB:
            return getJob();
        case MGR:
            return getMgr();
        case HIREDATE:
            return getHiredate();
        case SAL:
            return getSal();
        case COMM:
            return getComm();
        case DEPTNO:
            return getDeptno();
        default:
            return super.getAttrInvokeAccessor(index, attrDef);
        }
    }

    /**setAttrInvokeAccessor: generated method. Do not modify.
     */
    protected void setAttrInvokeAccessor(int index, Object value, 
                                         AttributeDefImpl attrDef) throws Exception {
        switch (index) {
        case EMPNO:
            setEmpno((Number)value);
            return;
        case ENAME:
            setEname((String)value);
            return;
        case JOB:
            setJob((String)value);
            return;
        case MGR:
            setMgr((Number)value);
            return;
        case HIREDATE:
            setHiredate((Date)value);
            return;
        case SAL:
            setSal((Number)value);
            return;
        case COMM:
            setComm((Number)value);
            return;
        case DEPTNO:
            setDeptno((Number)value);
            return;
        default:
            super.setAttrInvokeAccessor(index, value, attrDef);
            return;
        }
    }

    /**Creates a Key object based on given key constituents
     */
    public static Key createPrimaryKey(Number empno) {
        return new Key(new Object[]{empno});
    }

    public void setCreationDate(Date date) {
    }

    public void setCreatedBy(Number number) {
    }

    public void setLastUpdateDate(Date date) {
    }

    public void setLastUpdatedBy(Number number) {
    }

    public void setLastUpdateLogin(Number number) {
    }
    
    public void insertRow()
    { 
    
    System.out.println("Inside Insert Row ");
    
        Number empno = null , mgr= null , sal=null, comm= null, deptno= null ; 
        String empname = null,  job=null ; 
        Date hrieDate=null ; 
        String returnStatus=null, returnMsg = null ; 
        
        empno = getEmpno() ; 
        empname = getEname(); 
        job = getJob(); 
        mgr = getMgr(); 
        hrieDate = getHiredate(); 
        sal = getSal(); 
        comm = getComm(); 
        deptno = getDeptno() ; 
        
          String sql = "BEGIN  xxcus_oaf_emp_utils.insert_emp("
                         +"P_EMPNO       =>:1,"
                         +"P_ENAME        =>:2,"
                         +"P_JOB        => :3 , "
                         +"P_MGR        => :4 , "
                         +"P_HIREDATE        => :5 , "
                         +"P_SAL        => :6 , "
                         +"P_COMM        => :7 , "                  
                         +"P_DEPTNO        => :8 , "          
                         +"x_return_status    => :9,"
                         +"x_message => :10); END;";
        
        CallableStatement cstmt = getOADBTransaction().createCallableStatement(sql,1) ;


          try {
              
              cstmt.setInt(1,empno.intValue());
              cstmt.setString(2,empname);
              
              if(job!=null)
                  cstmt.setString(3,job);
              else
                  cstmt.setNull(3,OracleTypes.NULL);
              
              if(mgr!=null)    
              cstmt.setInt(4,mgr.intValue());
              else
              cstmt.setNull(4,OracleTypes.NULL);
              
              if(hrieDate!=null)
              cstmt.setDate(5,hrieDate.dateValue());
              else
              cstmt.setNull(5,OracleTypes.NULL);
              
              if(sal!=null)
              cstmt.setInt(6,sal.intValue());
              else
              cstmt.setNull(6,OracleTypes.NULL);
              
              if(comm!=null)
              cstmt.setInt(7,comm.intValue());
              else
              cstmt.setNull(7,OracleTypes.NULL);
              
              if(deptno!=null)
              cstmt.setInt(8,deptno.intValue());
              else
              cstmt.setNull(8,OracleTypes.NULL);
              
              
              ((OracleCallableStatement)cstmt).registerOutParameter(9, OracleTypes.VARCHAR, 0, 10);
              ((OracleCallableStatement)cstmt).registerOutParameter(10, OracleTypes.VARCHAR, 0, 4000);
              cstmt.execute();

              returnStatus = cstmt.getString(9);  
              returnMsg = cstmt.getString(10);
              
              cstmt.close();
        
              
          } catch (SQLException e) {
          
              // throw new OAException("error while calling plsql insert"+ e.getMessage());
              // TODO
          }
          
    
    
    }

    public void updateRow()
    
    {
    System.out.println("Inside Update Row ");
    
        Number empno = null , mgr= null , sal=null, comm= null, deptno= null ; 
        String empname = null,  job=null ; 
        Date hrieDate=null ; 
        String returnStatus=null, returnMsg = null ; 
        
        empno = getEmpno() ; 
        empname = getEname(); 
        job = getJob(); 
        mgr = getMgr(); 
        hrieDate = getHiredate(); 
        sal = getSal(); 
        comm = getComm(); 
        deptno = getDeptno() ; 
        
          String sql = "BEGIN  xxcus_oaf_emp_utils.update_emp("
                         +"P_EMPNO       =>:1,"
                         +"P_ENAME        =>:2,"
                         +"P_JOB        => :3 , "
                         +"P_MGR        => :4 , "
                         +"P_HIREDATE        => :5 , "
                         +"P_SAL        => :6 , "
                         +"P_COMM        => :7 , "                  
                         +"P_DEPTNO        => :8 , "          
                         +"x_return_status    => :9,"
                         +"x_message => :10); END;";
        
        CallableStatement cstmt = getOADBTransaction().createCallableStatement(sql,1) ;


          try {
              
              cstmt.setInt(1,empno.intValue());
              cstmt.setString(2,empname);
              
              if(job!=null)
                  cstmt.setString(3,job);
              else
                  cstmt.setNull(3,OracleTypes.NULL);
              
              if(mgr!=null)    
              cstmt.setInt(4,mgr.intValue());
              else
              cstmt.setNull(4,OracleTypes.NULL);
              
              if(hrieDate!=null)
              cstmt.setDate(5,hrieDate.dateValue());
              else
              cstmt.setNull(5,OracleTypes.NULL);
              
              if(sal!=null)
              cstmt.setInt(6,sal.intValue());
              else
              cstmt.setNull(6,OracleTypes.NULL);
              
              if(comm!=null)
              cstmt.setInt(7,comm.intValue());
              else
              cstmt.setNull(7,OracleTypes.NULL);
              
              if(deptno!=null)
              cstmt.setInt(8,deptno.intValue());
              else
              cstmt.setNull(8,OracleTypes.NULL);
              
              
              ((OracleCallableStatement)cstmt).registerOutParameter(9, OracleTypes.VARCHAR, 0, 10);
              ((OracleCallableStatement)cstmt).registerOutParameter(10, OracleTypes.VARCHAR, 0, 4000);
              cstmt.execute();

              returnStatus = cstmt.getString(9);  
              returnMsg = cstmt.getString(10);
              
              cstmt.close();
        
              
          } catch (SQLException e) {
          
              // throw new OAException("error while calling plsql insert"+ e.getMessage());
              // TODO
          }
        
    
    }

    public void deleteRow()
     { 
      
      System.out.println("Inside Delete Row Method");
      
       Number empNo = getEmpno(); 
       
         String sql = "BEGIN  xxcus_oaf_emp_utils.delete_emp("
                            +"p_emp_id       =>:1); END;";
         
         CallableStatement cstmt = getOADBTransaction().createCallableStatement(sql,1) ;
         try {
             cstmt.setInt(1,empNo.intValue());
             cstmt.execute();
         } catch (SQLException e) 
          {
             // TODO
          }
     
     }
}

Leave a Reply

Your email address will not be published.