Wednesday, November 20, 2019

OAF Customization

package oracle.apps.eam.workorder.webui;

import java.sql.Timestamp;
import java.util.Calendar;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;

public class XXCreateUpdateWOCO
  extends CreateUpdateWOCO
{
  public static final String RCS_ID = "$Header: CreateUpdateWOCO.java 120.15.12010000.5 2008/12/31 08:26:12 dsingire ship $";
  public static final boolean RCS_IDRECORDED = VersionInfo.recordClassVersion("$Header: CreateUpdateWOCO.java 120.15.12010000.5 2008/12/31 08:26:12 dsingire ship $", "oracle.apps.eam.workorder.webui");
 
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
   

    OAMessageChoiceBean priority = (OAMessageChoiceBean)webBean.findChildRecursive("Priority");
    pageContext.writeDiagnostics(pageContext, " priority " + priority, 4);
    if (priority != null) {
      priority.setFireActionForSubmit("prioritySelected", null, null, true);
    }
    OAApplicationModule rootAM = pageContext.getRootApplicationModule();
    OAViewObject createUpdateVO = (OAViewObject)rootAM.findViewObject("WOCreateUpdateVO");
    if ((createUpdateVO != null) && (createUpdateVO.getCurrentRow() != null))
    {
      Row row = createUpdateVO.getCurrentRow();
      if ((row.getAttribute("RequestNumber") != null) && (row.getAttribute("InstanceNumber") != null))
      {
        String sqlQueryStatement = null;
        if (row.getAttribute("AssetActivity") == null) {
          sqlQueryStatement = "SELECT  xxasas_updatewo_pkg.get_customer_name ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_customer_number ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "')" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "')" + " FROM DUAL ";
        } else {
          sqlQueryStatement = "SELECT  xxasas_updatewo_pkg.get_customer_name ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_customer_number ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " FROM DUAL ";
        }
        if (rootAM.findViewObject("XXGetCustDtlsVO") != null) {
          rootAM.findViewObject("XXGetCustDtlsVO").remove();
        }
        ViewObject getCustDtlsVO = rootAM.createViewObjectFromQueryStmt("XXGetCustDtlsVO", sqlQueryStatement);
        getCustDtlsVO.executeQuery();
       
        pageContext.writeDiagnostics(pageContext, " getRowCount " + getCustDtlsVO.getRowCount(), 4);
        if (getCustDtlsVO.first() != null)
        {
          row.setAttribute("Attribute1", getCustDtlsVO.first().getAttribute(0));
          row.setAttribute("Attribute2", getCustDtlsVO.first().getAttribute(1));
          row.setAttribute("Attribute3", getCustDtlsVO.first().getAttribute(2));
          row.setAttribute("Attribute4", getCustDtlsVO.first().getAttribute(3));
        }
      }
    }
  }
 
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    pageContext.writeDiagnostics(pageContext, " LovInputSourceId " + pageContext.getLovInputSourceId(), 4);
    OAApplicationModule rootAM = pageContext.getRootApplicationModule();
    OAViewObject createUpdateVO = (OAViewObject)rootAM.findViewObject("WOCreateUpdateVO");
    if ("prioritySelected".equals(pageContext.getParameter("event")))
    {
      if ((createUpdateVO != null) && (createUpdateVO.getCurrentRow() != null))
      {
        oracle.jbo.domain.Date startDate = (oracle.jbo.domain.Date)createUpdateVO.getCurrentRow().getAttribute("ScheduledStartDate");
        pageContext.writeDiagnostics(pageContext, " startDate " + startDate.timestampValue(), 4);
        pageContext.writeDiagnostics(pageContext, " priority " + createUpdateVO.getCurrentRow().getAttribute("Priority"), 4);
       

        Calendar cal = Calendar.getInstance();
        cal.setTime(new java.util.Date(startDate.timestampValue().getTime()));
        String sqlQueryStatement = "SELECT DESCRIPTION  FROM fnd_lookup_values_vl WHERE lookup_code = " + createUpdateVO.getCurrentRow().getAttribute("Priority") + "  AND lookup_type = 'WIP_EAM_ACTIVITY_PRIORITY' ";
        if (rootAM.findViewObject("XXGetSCDforPriorityVO") != null) {
          rootAM.findViewObject("XXGetSCDforPriorityVO").remove();
        }
        ViewObject getTimeVO = rootAM.createViewObjectFromQueryStmt("XXGetSCDforPriorityVO", sqlQueryStatement);
        getTimeVO.executeQuery();
       
        pageContext.writeDiagnostics(pageContext, " getRowCount " + getTimeVO.getRowCount(), 4);
        if (getTimeVO.first() != null) {
          cal.add(10, Integer.parseInt(getTimeVO.first().getAttribute(0) + ""));
        }
        pageContext.writeDiagnostics(pageContext, " endDate " + cal.getTime(), 4);
       

        oracle.jbo.domain.Date newDate = new oracle.jbo.domain.Date(new Timestamp(cal.getTime().getTime()));
        createUpdateVO.getCurrentRow().setAttribute("ScheduledCompletionDate", newDate);
       
        pageContext.writeDiagnostics(pageContext, " newDate " + newDate, 4);
       
        pageContext.writeDiagnostics(pageContext, " SCD " + createUpdateVO.getCurrentRow().getAttribute("ScheduledCompletionDate"), 4);
      }
    }
    else if ((pageContext.isLovEvent()) && ("AssetNumber".equals(pageContext.getLovInputSourceId())))
    {
      if ((createUpdateVO != null) && (createUpdateVO.getCurrentRow() != null))
      {
        Row row = createUpdateVO.getCurrentRow();
        pageContext.writeDiagnostics(pageContext, " InstanceNumber " + createUpdateVO.getCurrentRow().getAttribute("InstanceNumber"), 4);
       
        String sqlQueryStatement = null;
        if (row.getAttribute("AssetActivity") == null) {
          sqlQueryStatement = "SELECT  xxasas_updatewo_pkg.get_customer_name ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_customer_number ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "')" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "')" + " FROM DUAL ";
        } else {
          sqlQueryStatement = "SELECT  xxasas_updatewo_pkg.get_customer_name ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_customer_number ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " FROM DUAL ";
        }
        if (rootAM.findViewObject("XXGetCustDtlsVO") != null) {
          rootAM.findViewObject("XXGetCustDtlsVO").remove();
        }
        ViewObject getCustDtlsVO = rootAM.createViewObjectFromQueryStmt("XXGetCustDtlsVO", sqlQueryStatement);
        getCustDtlsVO.executeQuery();
       
        pageContext.writeDiagnostics(pageContext, " getRowCount " + getCustDtlsVO.getRowCount(), 4);
        if (getCustDtlsVO.first() != null)
        {
          row.setAttribute("Attribute1", getCustDtlsVO.first().getAttribute(0));
          row.setAttribute("Attribute2", getCustDtlsVO.first().getAttribute(1));
          row.setAttribute("Attribute3", getCustDtlsVO.first().getAttribute(2));
          row.setAttribute("Attribute4", getCustDtlsVO.first().getAttribute(3));
        }
      }
    }
    else if ((pageContext.isLovEvent()) && ("Activity".equals(pageContext.getLovInputSourceId()))) {
      if ((createUpdateVO != null) && (createUpdateVO.getCurrentRow() != null))
      {
        Row row = createUpdateVO.getCurrentRow();
        pageContext.writeDiagnostics(pageContext, " InstanceNumber " + createUpdateVO.getCurrentRow().getAttribute("InstanceNumber"), 4);
        pageContext.writeDiagnostics(pageContext, " AssetActivity " + createUpdateVO.getCurrentRow().getAttribute("AssetActivity"), 4);
       

        String sqlQueryStatement = null;
        if (row.getAttribute("AssetActivity") != null) {
          sqlQueryStatement = "SELECT   xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "' ,'" + row.getAttribute("AssetActivity") + "')" + " FROM DUAL ";
        } else {
          sqlQueryStatement = "SELECT   xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "' )" + " FROM DUAL ";
        }
        if (rootAM.findViewObject("XXGetCustDtlsVO") != null) {
          rootAM.findViewObject("XXGetCustDtlsVO").remove();
        }
        ViewObject getCustDtlsVO = rootAM.createViewObjectFromQueryStmt("XXGetCustDtlsVO", sqlQueryStatement);
        getCustDtlsVO.executeQuery();
       
        pageContext.writeDiagnostics(pageContext, " getRowCount " + getCustDtlsVO.getRowCount(), 4);
        if (getCustDtlsVO.first() != null)
        {
          row.setAttribute("Attribute3", getCustDtlsVO.first().getAttribute(0));
          row.setAttribute("Attribute4", getCustDtlsVO.first().getAttribute(1));
        }
      }
    }
  }
}


=========================================================

package oracle.apps.eam.workrequest.webui;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;

public class XXWorkRequestDffCO
  extends WorkRequestDffCO
{
  public static final String RCS_ID = "$Header: WorkRequestDffCO.java 120.0.12010000.2 2009/05/27 13:18:56 somitra ship $";
  public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: WorkRequestDffCO.java 120.0.12010000.2 2009/05/27 13:18:56 somitra ship $", "oracle.apps.eam.workrequest.webui");
 
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
  }
 
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    pageContext.writeDiagnostics(pageContext, " LovInputSourceId " + pageContext.getLovInputSourceId(), 4);
    if ((pageContext.isLovEvent()) && ("AssetNumber".equals(pageContext.getLovInputSourceId())))
    {
      OAApplicationModule rootAM = pageContext.getRootApplicationModule();
      OAViewObject requestDetailsVO = (OAViewObject)rootAM.findViewObject("RequestDetailsVO");
      pageContext.writeDiagnostics(pageContext, " requestDetailsVO " + requestDetailsVO, 4);
      if ((requestDetailsVO != null) && (requestDetailsVO.getCurrentRow() != null))
      {
        Row row = requestDetailsVO.getCurrentRow();
        pageContext.writeDiagnostics(pageContext, " InstanceNumber " + requestDetailsVO.getCurrentRow().getAttribute("InstanceNumber"), 4);
       

        String sqlQueryStatement = "SELECT  xxasas_updatewo_pkg.get_customer_name ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_customer_number ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_type ( '" + row.getAttribute("InstanceNumber") + "' )" + " ,xxasas_updatewo_pkg.get_contract_supplier ( '" + row.getAttribute("InstanceNumber") + "' )" + " FROM DUAL ";
        if (rootAM.findViewObject("XXGetCustDtlsVO") != null) {
          rootAM.findViewObject("XXGetCustDtlsVO").remove();
        }
        ViewObject getCustDtlsVO = rootAM.createViewObjectFromQueryStmt("XXGetCustDtlsVO", sqlQueryStatement);
        getCustDtlsVO.executeQuery();
       
        pageContext.writeDiagnostics(pageContext, " getRowCount " + getCustDtlsVO.getRowCount(), 4);
        if (getCustDtlsVO.first() != null)
        {
          row.setAttribute("Attribute1", getCustDtlsVO.first().getAttribute(0));
          row.setAttribute("Attribute2", getCustDtlsVO.first().getAttribute(1));
          row.setAttribute("Attribute3", getCustDtlsVO.first().getAttribute(2));
          row.setAttribute("Attribute4", getCustDtlsVO.first().getAttribute(3));
        }
      }
    }
  }
}