You are on page 1of 7

package oracle.apps.icx.por.cancelreq.

webui;

import java.io.Serializable;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.*;
import oracle.apps.fnd.framework.webui.*;
import oracle.apps.fnd.framework.webui.beans.OABodyBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OADefaultDoubleColumnBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.table.OATableBean;
import oracle.apps.icx.por.cancelreq.server.CancelRequisitionUtil;
import oracle.apps.icx.por.common.PorSystemInfo;
import oracle.apps.icx.por.common.webui.ClientUtil;
import oracle.apps.icx.por.common.webui.DisplayUtil;
import oracle.cabo.ui.data.DataObjectList;
import oracle.cabo.ui.data.DictionaryData;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;

public class CrqRvwCO extends OAControllerImpl


{

public static final String RCS_ID = "$Header: CrqRvwCO.java 120.6.12020000.3


2013/06/19 09:55:36 rparise ship $";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion("$Header: CrqRvwCO.java 120.6.12020000.3 2013/06/19
09:55:36 rparise ship $", "oracle.apps.icx.por.cancelreq.webui");

public CrqRvwCO()
{
}

public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)


{
oapagecontext.startTimedProcedure(this, "processRequest");
OAWebBean oawebbean1 = oapagecontext.getRootWebBean();
if(oawebbean1 instanceof OABodyBean)
{
((OABodyBean)oawebbean1).setBlockOnEverySubmit(true);
}
super.processRequest(oapagecontext, oawebbean);
if(!TransactionUnitHelper.isTransactionUnitInProgress(oapagecontext,
"cancelOrChange", true))
{
oapagecontext.redirectToDialogPage(new OADialogPage((byte)3));
}
setPageTitle(oapagecontext, oawebbean);
executePageVO(oapagecontext, oawebbean);
manipulateUIElements(oapagecontext, oawebbean);
setCurrencyFormatting(oawebbean,
ClientUtil.getPorSystemInfo(oapagecontext).getFunctionalCurrency());
rightAlignPriceAmountColumns(oapagecontext, oawebbean);
setDynamicColumnLabels(oapagecontext, oawebbean,
ClientUtil.getPorSystemInfo(oapagecontext).getFunctionalCurrency());
makeADACompliant(oapagecontext, oawebbean);
oapagecontext.endTimedProcedure(this, "processRequest");
}

public void processFormRequest(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
oapagecontext.startTimedProcedure(this, "processRequest");
super.processFormRequest(oapagecontext, oawebbean);
if(oapagecontext.getParameter("BackButton") != null)
{
backButtonHandler(oapagecontext, oawebbean);
} else
if(oapagecontext.getParameter("SubmitButton") != null)
{
submitButtonHandler(oapagecontext, oawebbean);
TransactionUnitHelper.endTransactionUnit(oapagecontext,
"cancelOrChange");
} else
if(oapagecontext.getParameter("CancelButton") != null)
{
cancelButtonHandler(oapagecontext, oawebbean);
}
oapagecontext.endTimedProcedure(this, "processRequest");
}

protected void cancelButtonHandler(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
oapagecontext.setForwardURL(ClientUtil.getReturnUrl(oapagecontext),
(byte)0, null, ClientUtil.getReturnUrlParams(oapagecontext), true, "N", (byte)1);
}

protected void backButtonHandler(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
oapagecontext.setForwardURL("ICXPOR_CNCLREQ_ENTER_PAGE", (byte)0, null,
null, true, "N", (byte)0);
}

protected void submitButtonHandler(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
OAApplicationModule oaapplicationmodule =
oapagecontext.getApplicationModule(oawebbean);
OAViewObject oaviewobject =
(OAViewObject)oaapplicationmodule.findViewObject("CancelRequisitionReviewLinesVO1")
;
OAViewObject oaviewobject1 =
(OAViewObject)oaapplicationmodule.findViewObject("CancelRequisitionReviewHeaderVO1"
);
String s = (String)oapagecontext.getTransactionValue("porReqHeaderId");
if(s != null)
{
OARow oarow = (OARow)oaviewobject1.first();
Number number = (Number)oarow.getAttribute("RequisitionHeaderId");
boolean flag = false;
String s1 = "Y";
if("Y".equals(oarow.getAttribute("FederalFlag")))
{
flag =
CancelRequisitionUtil.baseCopyExists(oaapplicationmodule.getOADBTransaction(),
number);
if(flag)
{
s1 =
(String)oaviewobject1.invokeMethod("createCancelAmendment");
}
}
if("Y".equals(s1))
{
Serializable aserializable[] = {
s, (String)oarow.getAttribute("UseDocGLDate"),
(Date)oarow.getAttribute("GLDate")
};
Class aclass[] = {
java/lang/String, java/lang/String, oracle/jbo/domain/Date
};
oaviewobject.invokeMethod("submitRequest", aserializable, aclass);
String s2;
if("Y".equals(oarow.getAttribute("FederalFlag")) && !
oapagecontext.dialogMessagesExist() && flag)
{
s2 = (String)oaviewobject1.invokeMethod("setAmendLinesCancel");
}
}
}
oapagecontext.setForwardURL("ICXPOR_CNCLREQ_CONF_PAGE", (byte)0, null,
null, true, "N", (byte)0);
}

protected void setDynamicColumnLabels(OAPageContext oapagecontext, OAWebBean


oawebbean, String s)
{
MessageToken amessagetoken[] = {
new MessageToken("CURRENCY", s)
};
DisplayUtil.setBeanLabel(oapagecontext, oawebbean, "UnitPrice",
"ICX_POR_UNIT_PRICE", amessagetoken);
DisplayUtil.setBeanLabel(oapagecontext, oawebbean, "LineTotal",
"ICX_POR_TOTAL_AMOUNT", amessagetoken);
DisplayUtil.setBeanLabel(oapagecontext, oawebbean, "LineTotal",
"ICX_POR_TOTAL_AMOUNT", amessagetoken);
DisplayUtil.setBeanLabel(oapagecontext, oawebbean, "Amount",
"ICX_POR_TOTAL_AMOUNT", amessagetoken);
DisplayUtil.setBeanLabel(oapagecontext, oawebbean, "Amount_Amt",
"ICX_POR_TOTAL_AMOUNT", amessagetoken);
}

protected void makeADACompliant(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
DisplayUtil.setTableSummary("LinesRN", "ICX_POR_TBL_CNCL_REQ_REVIEW", null,
oapagecontext, oawebbean);
DisplayUtil.setTableSummary("Distributions_QuantityRN",
"ICX_POR_TBL_CNCL_REQ_DISTR", null, oapagecontext, oawebbean);
DisplayUtil.setTableSummary("Distributions_AmountRN",
"ICX_POR_TBL_CNCL_REQ_DISTR", null, oapagecontext, oawebbean);
}
protected void createDetailTable(OAWebBean oawebbean)
{
OAWebBean oawebbean1 = oawebbean.findChildRecursive("LinesRN");
OAWebBean oawebbean2 =
oawebbean.findChildRecursive("Distributions_QuantityRN");
if(oawebbean1 != null)
{
oawebbean1.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,
"RequisitionLineId");
oawebbean1.setAttributeValue(VIEW_LINK_NAME,
"CancelRequisitionReviewDistributionsVL1");
}
if(oawebbean2 != null)
{
oawebbean2.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,
"RequisitionLineId");
oawebbean2.setAttributeValue(VIEW_LINK_NAME,
"CancelRequisitionReviewDistributionsVL1");
}
oawebbean2 = oawebbean.findChildRecursive("Distributions_AmountRN");
if(oawebbean2 != null)
{
oawebbean2.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,
"RequisitionLineId");
oawebbean2.setAttributeValue(VIEW_LINK_NAME,
"CancelRequisitionReviewDistributionsVL1");
}
}

protected void setCurrencyFormatting(OAWebBean oawebbean, String s)


{
DisplayUtil.setCurrencyFormat(oawebbean, "TrxAmount", s);
DisplayUtil.setCurrencyFormat(oawebbean, "Amount", s);
DisplayUtil.setCurrencyFormat(oawebbean, "TrxAmount_Amt", s);
DisplayUtil.setCurrencyFormat(oawebbean, "Amount_Amt", s);
DisplayUtil.setCurrencyFormat(oawebbean, "LineTotal", s);
DisplayUtil.setCurrencyFormat(oawebbean, "CurLineTotal", s);
}

protected void setPageTitle(OAPageContext oapagecontext, OAWebBean oawebbean)


{
MessageToken amessagetoken[] = {
new MessageToken("REQ_NUM",
(String)oapagecontext.getTransactionValue("porReqNumber"))
};
String s = oapagecontext.getMessage("ICX", "ICX_POR_CNCL_REV_PAGE_TITLE",
amessagetoken);
((OAPageLayoutBean)oawebbean).setTitle(s);
}

private void hideColumnsByReqType(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
String s =
(String)oapagecontext.getTransactionValue("porContractorRequisitionFlag");
String s1 = (String)oapagecontext.getTransactionValue("porTrxRequisition");
if("Y".equals(s))
{
DisplayUtil.hideBean(oawebbean, "NeedByDate");
DisplayUtil.hideBean(oawebbean, "Quantity");
DisplayUtil.hideBean(oawebbean, "UnitPrice");
DisplayUtil.hideBean(oawebbean, "CurUnitPriceFlow");
DisplayUtil.hideBean(oawebbean, "OrderType");
if(!"Y".equals(s1))
{
DisplayUtil.hideBean(oawebbean, "CurLineTotalFlow");
DisplayUtil.hideBean(oawebbean, "TrxAmountFlow");
DisplayUtil.hideBean(oawebbean, "TrxAmountFlow_Amt");
}
} else
{
DisplayUtil.hideBean(oawebbean, "StartDate");
DisplayUtil.hideBean(oawebbean, "EndDate");
DisplayUtil.hideBean(oawebbean, "RateFlow");
DisplayUtil.hideBean(oawebbean, "ContractorName");
if(!"Y".equals(s1))
{
DisplayUtil.hideBean(oawebbean, "CurLineTotalFlow");
DisplayUtil.hideBean(oawebbean, "TrxAmountFlow");
DisplayUtil.hideBean(oawebbean, "TrxAmountFlow_Amt");
}
}
}

protected void manipulateUIElements(OAPageContext oapagecontext, OAWebBean


oawebbean)
{
createDetailTable(oawebbean);
formatHeaderRegion(oawebbean);
hideReasonColumn(oapagecontext, oawebbean);
setWrapDisabled(oawebbean);
hideColumnsByReqType(oapagecontext, oawebbean);
handleFederalUI(oapagecontext, oawebbean);
}

protected void formatHeaderRegion(OAWebBean oawebbean)


{
OADefaultDoubleColumnBean oadefaultdoublecolumnbean =
(OADefaultDoubleColumnBean)oawebbean.findChildRecursive("HeaderRN");
if(oadefaultdoublecolumnbean != null)
{
oadefaultdoublecolumnbean.setHeaderDisabled(true);
oadefaultdoublecolumnbean.setLabelCellWidth("35%");
}
}

protected void executePageVO(OAPageContext oapagecontext, OAWebBean oawebbean)


{
OAApplicationModule oaapplicationmodule =
oapagecontext.getApplicationModule(oawebbean);
String s = (String)oapagecontext.getTransactionValue("porReqHeaderId");
if(s != null)
{
OAViewObject oaviewobject =
(OAViewObject)oaapplicationmodule.findViewObject("CancelRequisitionReviewHeaderVO1"
);
if(!oaviewobject.isPreparedForExecution() ||
"Y".equals(oapagecontext.getParameter("executeReviewHeaderVO")))
{
Serializable aserializable[] = {
s
};
oaviewobject.invokeMethod("executeQuery", aserializable);
}
oaapplicationmodule.invokeMethod("CopyAttributesToReviewRow");
}
}

private void hideReasonColumn(OAPageContext oapagecontext, OAWebBean oawebbean)


{
String s =
(String)oapagecontext.getTransactionValue("porSomeLinesAreOnPO");
if(s != null && s.equals("N"))
{
DisplayUtil.hideBean(oawebbean, "Reason");
}
}

protected void rightAlignPriceAmountColumns(OAPageContext oapagecontext,


OAWebBean oawebbean)
{
OATableBean oatablebean =
(OATableBean)oawebbean.findIndexedChildRecursive("LinesRN");
oatablebean.prepareForRendering(oapagecontext);
DataObjectList dataobjectlist = oatablebean.getColumnFormats();
DictionaryData dictionarydata = null;
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"RateFlow"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"CurUnitPriceFlow"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"CurLineTotalFlow"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"Quantity"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"LineTotal"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"UnitPrice"));
dictionarydata.put("columnDataFormat", "numberFormat");
oatablebean =
(OATableBean)oawebbean.findChildRecursive("Distributions_QuantityRN");
oatablebean.prepareForRendering(oapagecontext);
dataobjectlist = oatablebean.getColumnFormats();
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"DistQuantity"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"TrxAmountFlow"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"Amount"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"Percentage"));
dictionarydata.put("columnDataFormat", "numberFormat");
oatablebean =
(OATableBean)oawebbean.findChildRecursive("Distributions_AmountRN");
oatablebean.prepareForRendering(oapagecontext);
dataobjectlist = oatablebean.getColumnFormats();
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"TrxAmountFlow_Amt"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"Amount_Amt"));
dictionarydata.put("columnDataFormat", "numberFormat");
dictionarydata =
(DictionaryData)dataobjectlist.getItem(oapagecontext.findChildIndex(oatablebean,
"Percentage_Amt"));
dictionarydata.put("columnDataFormat", "numberFormat");
}

protected void setWrapDisabled(OAWebBean oawebbean)


{
DisplayUtil.setWrapEnabled(oawebbean, "LineNumberFlow", false);
DisplayUtil.setWrapEnabled(oawebbean, "NeedByDate", false);
DisplayUtil.setWrapEnabled(oawebbean, "StartDate", false);
DisplayUtil.setWrapEnabled(oawebbean, "EndDate", false);
DisplayUtil.setWrapEnabled(oawebbean, "RateFlow", false);
DisplayUtil.setWrapEnabled(oawebbean, "CurUnitPriceFlow", false);
DisplayUtil.setWrapEnabled(oawebbean, "CurLineTotalFlow", false);
}

private void handleFederalUI(OAPageContext oapagecontext, OAWebBean oawebbean)


{

if(!"Y".equals((String)oapagecontext.getApplicationModule(oawebbean).findViewObject
("CancelRequisitionReviewHeaderVO1").first().getAttribute("FederalFlag")))
{
DisplayUtil.hideBean(oawebbean, "CancelReason");
}
}

You might also like