Commit 5c932317 authored by vlagad's avatar vlagad

Java component for allowdedn_drop

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@212577 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8e201102
This diff is collapsed.
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.w3c.dom.Document;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.webitm.ejb.adm.AllowDeductionDropPrConf;
import ibase.webitm.ejb.adm.HRLogWriter;
import ibase.webitm.ejb.adm.PayrollSplitgenAccPrc;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
public class AllowDeductionDropPrAppr extends ValidatorEJB
{
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
AdmCommon admCommon = new AdmCommon();
UtilMethods utilMethod = new UtilMethods();
String userId = "",loginEmpCode = "",runMode = "",chgTerm = "";
public String approve(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
BaseLogger.log("2",null,null,"Inside AllowDeductionDropPrAppr Approve.........");
String retString = null;
Connection conn = null;
try
{
conn = getConnection();
BaseLogger.log("3",null,null,"Conn==>[" + conn + "]");
retString = gbfPostLogic(tranId, tranId,xtraParams,forcedFlag,conn);
BaseLogger.log("3",null,null,"returning String from AllowDeductionDropPrAppr :approve():==>[" + retString + "]");
if(retString == null || retString.trim().length() == 0)
{
conn.commit();
}
else
{
conn.rollback();
}
}
catch(Exception e)
{
BaseLogger.log("0",null,null,"Exception :AllowDeductionDropPrAppr :approve() :" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return retString;
}
private String gbfPostLogic(String tranId, String tranId2, String xtraParams, String forcedFlag, Connection conn)
{
String retString = null;
Connection logConn = null;
try
{
HRLogWriter hrLogWriter = new HRLogWriter();
logConn = getConnection();
BaseLogger.log("3",null,null,"Conn==>[" + conn + "]");
retString =gbfPostLogic( tranId, tranId2, xtraParams, forcedFlag, conn, hrLogWriter, logConn);
BaseLogger.log("3",null,null,"returning String from AllowDeductionDropPrAppr :gbfPostLogic():==>[" + retString + "]");
if(E12GenericUtility.checkNull(retString).length() == 0)
{
logConn.commit();
}
else
{
logConn.rollback();
}
}
catch(Exception e)
{
BaseLogger.log("0",null,null,"Exception :AllowDeductionDropPrAppr :gbfPostLogic() :" + e.getMessage() + ":");
e.printStackTrace();
try
{
throw new ITMException(e);
}
catch (ITMException e1)
{
e1.printStackTrace();
}
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return retString;
}
//This method is in nvo_bo_ad_drop_approve [start]
public String gbfPostLogic(String tranIdFrom,String tranIdTo,String xtraParams,String forcedFlag,Connection conn,HRLogWriter hrLog ,Connection logConn) throws ITMException
{
String sql="",valueXmlStr="",currentDatestr="";
PreparedStatement pstmt = null;
Timestamp currDate =null;
ResultSet rs = null;
String errorString = "",confirmed = "", ls_tranid = "", prd = "", ls_emp = "";
StringBuffer valueXmlString = null;
StringBuffer valueXmlString1 = null;
StringBuffer valueXmlStringArr = null;
Document arrHeaderDom =null ;
PayrollSplitgenAccPrc payRoll = null;
AdmCommon admCommon = null;
try
{
userId = E12GenericUtility.checkNull((genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode")));
chgTerm = E12GenericUtility.checkNull((genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId")));
loginEmpCode = E12GenericUtility.checkNull((genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode")));
runMode = E12GenericUtility.checkNull((genericUtility.getValueFromXTRA_PARAMS(xtraParams, "runMode")));
Calendar cal = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
currentDatestr = formatter.format(cal.getTime());
admCommon = new AdmCommon();
if(currentDatestr != null && currentDatestr.trim().length() > 0)
{
currDate = admCommon.getTimeStampValue(currentDatestr);
}
BaseLogger.log("3",null,null,"currDate "+currDate);
valueXmlString = new StringBuffer("<DocumentRoot><description>Datawindow Root</description><group0>");
valueXmlString.append("<description>Group0 description</description>").append("<Header0>");
valueXmlString.append("<description>Header0 members</description>");
valueXmlString.append("<Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"allowdedn_drop\">");
valueXmlString.append("<attribute pkNames=\"\" selected=\"\" status=\"\" updateFlag=\"\"/>");
valueXmlStr = valueXmlString.toString();
if (tranIdFrom.equalsIgnoreCase(tranIdTo))
{
ls_tranid = tranIdFrom;
}
sql = "select confirmed, prd_code__ded, emp_code from allowdedn_drop where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_tranid);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = rs.getString("confirmed");
prd = rs.getString("prd_code__ded");
ls_emp = rs.getString("emp_code");
}
else
{
errorString = E12GenericUtility.checkNull(itmDBAccessEJB.getErrorString("", "VTMCONF20", userId, "", conn));
}
if("Y".equalsIgnoreCase(confirmed))
{
errorString = E12GenericUtility.checkNull(itmDBAccessEJB.getErrorString("", "VTMCONF1", userId, "", conn));
}
AllowDeductionDropPrConf ad = new AllowDeductionDropPrConf();
if( errorString.trim().length() == 0)
{
errorString = E12GenericUtility.checkNull(ad.gbfAllowDedDropApprv(ls_tranid, "Y", xtraParams,conn));
}
if( errorString.trim().length() == 0)
{
valueXmlString1 = new StringBuffer();
valueXmlString1.append("<type><![CDATA[").append("PY").append("]]></type>");
valueXmlString1.append("<prd_code__fr><![CDATA[").append(prd).append("]]></prd_code__fr>");
valueXmlString1.append("<prd_code__to><![CDATA[").append(prd).append("]]></prd_code__to>");
valueXmlString1.append("<dataowrite><![CDATA[").append("Y").append("]]></dataowrite>");
valueXmlString1.append("<emp_code__fr><![CDATA[").append(ls_emp).append("]]></emp_code__fr>");
valueXmlString1.append("<emp_code__to><![CDATA[").append(ls_emp).append("]]></emp_code__to>");
valueXmlString1.append("<payroll_date><![CDATA[").append(currentDatestr).append("]]></payroll_date>");
}
valueXmlString1.append("</Detail1></Header0></group0></DocumentRoot>");
valueXmlStringArr = new StringBuffer();
valueXmlStringArr.append(valueXmlStr).append(valueXmlString1);
BaseLogger.log("3",null,null,"valueXmlStringArr::: " + valueXmlStringArr);
if(valueXmlStringArr != null)
{
arrHeaderDom = genericUtility.parseString(valueXmlStringArr.toString());
}
payRoll = new PayrollSplitgenAccPrc();
errorString = payRoll.gbfProcessPayroll(arrHeaderDom, arrHeaderDom, xtraParams, hrLog, conn, logConn);
BaseLogger.log("3",null,null,"errorString ................232"+errorString);
}
catch (SQLException e1)
{
try
{
errorString = E12GenericUtility.checkNull(itmDBAccessEJB.getErrorString("", "VTMCONF20", userId, "", conn));
}
catch (RemoteException e)
{
e.printStackTrace();
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
return errorString;
}
//This method is in nvo_bo_ad_drop_approve [End]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment