package xxcus.oracle.apps.per.wpm.objectives.webui;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAFwkConstants;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.per.wpm.objectives.webui.DuplicateObjectivePageCO;
public class DuplicateObjectivePageCOEx extends DuplicateObjectivePageCO {
public DuplicateObjectivePageCOEx() {
}
public void processFormRequest(OAPageContext pc, OAWebBean wb) {
//super.initTransactionDefaults(pc);
String str3 = null;
Integer istr3 = 0;
Integer totalwt = 0;
Integer l_totalwt = 0;
Integer objcount = 0;
String event = pc.getParameter("event");
String scorecardId = pc.getDecryptedParameter("pScorecardId");
if ("Apply".equals(event)) {
try {
Connection conn =
pc.getApplicationModule(wb).getOADBTransaction().getJdbcConnection();
String Query =
"select sum(totalwt) totalwt, count(1) objcount\n" +
"from ( \n" +
" SELECT (decode(extractvalue(VALUE(xx_row), \n" +
" '/ObjectiveEORow/WeightingPercent'), \n" +
" '(null)', 0, \n" +
" '', 0, \n" +
" extractvalue(VALUE(xx_row), '/ObjectiveEORow/WeightingPercent'))) AS totalwt \n" +
" FROM HR_API_TRANSACTIONS xx_api, \n" +
" TABLE(xmlsequence(extract(xmlparse(document transaction_document wellformed),\n" +
" '/Transaction/TransCache/AM/TXN/EO/ObjectiveEORow'))) xx_row \n" +
" WHERE xx_api.transaction_ref_id = :1\n" +
"union all \n" +
" SELECT po.weighting_percent AS totalwt\n" +
" FROM per_objectives po, per_people_f ppf\n" +
" WHERE po.scorecard_id = NVL (:2, po.scorecard_id)\n" +
" AND ppf.person_id(+) = po.owning_person_id\n" +
" AND TRUNC (SYSDATE) BETWEEN ppf.effective_start_date(+) AND ppf.effective_end_date(+)\n" +
" AND appraisal_id IS NULL\n" +
" )\n" +
" ";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1, scorecardId);
stmt.setString(2, scorecardId);
for (ResultSet resultset = stmt.executeQuery();
resultset.next(); ) {
totalwt = resultset.getInt("totalwt");
objcount = resultset.getInt("objcount");
}
} catch (Exception exception) {
throw new OAException("Error in Weight Extension " + exception, OAException.ERROR);
}
//weighting scale 5 - 30 validation
str3 = pc.getParameter("Weighting");
if (str3 != "") {
istr3 = Integer.parseInt(str3);
}
if (istr3 < 5 || istr3 > 30) {
throw new OAException(" Objective Weighting should be between 5 and 30", OAException.ERROR);
}
//total weight validation
l_totalwt = totalwt + istr3;
if (l_totalwt > 100) {
throw new OAException("Total Weights exceed 100. Total Weight " +
"including current objective is:" + l_totalwt,OAException.ERROR);
}
pc.writeDiagnostics(this, "printing total weight " + totalwt, OAFwkConstants.STATEMENT);
}
super.processFormRequest(pc, wb);
} // end pfr
}
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAFwkConstants;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.per.wpm.objectives.webui.DuplicateObjectivePageCO;
public class DuplicateObjectivePageCOEx extends DuplicateObjectivePageCO {
public DuplicateObjectivePageCOEx() {
}
public void processFormRequest(OAPageContext pc, OAWebBean wb) {
//super.initTransactionDefaults(pc);
String str3 = null;
Integer istr3 = 0;
Integer totalwt = 0;
Integer l_totalwt = 0;
Integer objcount = 0;
String event = pc.getParameter("event");
String scorecardId = pc.getDecryptedParameter("pScorecardId");
if ("Apply".equals(event)) {
try {
Connection conn =
pc.getApplicationModule(wb).getOADBTransaction().getJdbcConnection();
String Query =
"select sum(totalwt) totalwt, count(1) objcount\n" +
"from ( \n" +
" SELECT (decode(extractvalue(VALUE(xx_row), \n" +
" '/ObjectiveEORow/WeightingPercent'), \n" +
" '(null)', 0, \n" +
" '', 0, \n" +
" extractvalue(VALUE(xx_row), '/ObjectiveEORow/WeightingPercent'))) AS totalwt \n" +
" FROM HR_API_TRANSACTIONS xx_api, \n" +
" TABLE(xmlsequence(extract(xmlparse(document transaction_document wellformed),\n" +
" '/Transaction/TransCache/AM/TXN/EO/ObjectiveEORow'))) xx_row \n" +
" WHERE xx_api.transaction_ref_id = :1\n" +
"union all \n" +
" SELECT po.weighting_percent AS totalwt\n" +
" FROM per_objectives po, per_people_f ppf\n" +
" WHERE po.scorecard_id = NVL (:2, po.scorecard_id)\n" +
" AND ppf.person_id(+) = po.owning_person_id\n" +
" AND TRUNC (SYSDATE) BETWEEN ppf.effective_start_date(+) AND ppf.effective_end_date(+)\n" +
" AND appraisal_id IS NULL\n" +
" )\n" +
" ";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1, scorecardId);
stmt.setString(2, scorecardId);
for (ResultSet resultset = stmt.executeQuery();
resultset.next(); ) {
totalwt = resultset.getInt("totalwt");
objcount = resultset.getInt("objcount");
}
} catch (Exception exception) {
throw new OAException("Error in Weight Extension " + exception, OAException.ERROR);
}
//weighting scale 5 - 30 validation
str3 = pc.getParameter("Weighting");
if (str3 != "") {
istr3 = Integer.parseInt(str3);
}
if (istr3 < 5 || istr3 > 30) {
throw new OAException(" Objective Weighting should be between 5 and 30", OAException.ERROR);
}
//total weight validation
l_totalwt = totalwt + istr3;
if (l_totalwt > 100) {
throw new OAException("Total Weights exceed 100. Total Weight " +
"including current objective is:" + l_totalwt,OAException.ERROR);
}
pc.writeDiagnostics(this, "printing total weight " + totalwt, OAFwkConstants.STATEMENT);
}
super.processFormRequest(pc, wb);
} // end pfr
}
No comments:
Post a Comment