Commit 2650aa48 authored by rtelang's avatar rtelang

-Below migrated components of Create payable voucher

PayrollPostAcc.java
PayrollPostAccLocal.java
PayrollPostAccRemote.java

-Below migrated component of payroll single
PayrollSingleIC.java
PayrollSingleICLocal.java
PayrollSingleICRemote.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@197690 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d8ec5b41
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class PayrollPostAcc extends ValidatorEJB implements PayrollPostAccLocal,PayrollPostAccRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
AdmCommon admCommon = new AdmCommon();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString of PayarrToProc--> wfValData:::"+retString);
}
catch(Exception e)
{
System.out.println("::: PayarrToProc ::"+ e.getMessage());
e.getMessage();
throw new ITMException(e);
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString="",errCode = "",msgType="",lsPrdCode="",lsSitefr="",lsSiteto="";
String loginCode="";
int childNodeLength = 0;
Timestamp pval= null;
Timestamp pval1= null;
String mval="",mval1="";
int currentFormNo=0;
int ctr = 0, cnt = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
NodeList parentNodeList = null;
Node parentNode = null;
NodeList childNodeList = null;
Node childNode = null;
String childNodeName = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
String sql=null;
Timestamp mdate1=null;
Timestamp mdate2=null;
Timestamp mdate3=null;
String dateAf="";
String paydate1 = "";
String paydate3 = "";
String paydate2 = "";
String userId = null;
String empCodeAprv= null;
String loginSite = null;
String mgetval="";
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
String errorType = "";
try
{
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::"+currentFormNo);
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println(">>>>>> childNodeName: ["+childNodeName+"]");
if("payroll_date".equalsIgnoreCase(childNodeName))
{
System.out.println("INSIDE payroll_date......." );
paydate1 = checkNull(genericUtility.getColumnValue("payroll_date", dom));
System.out.println("paydate1......"+paydate1);
if(paydate1 == null || paydate1.trim().length() == 0)
{
errCode = "VEDAT2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
mdate1 = Timestamp.valueOf(genericUtility.getValidDateString(paydate1, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("VALUE OF mdate1"+mdate1);
mval = checkNull(genericUtility.getColumnValue("prd_code__to", dom));
System.out.println("prd_code__to......."+mval);
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mval);
rs = pstmt.executeQuery();
if(rs.next())
{
mdate3 = rs.getTimestamp("fr_date");
mdate2 = rs.getTimestamp("to_date");
}
System.out.println("User fr_date,to_date from period ["+mdate3+""+""+mdate2+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if((mdate1 != null && mdate2 != null) || (mdate1 != null && mdate3 != null))
{
if(mdate1.after(mdate2) || mdate1.before(mdate3))
{
errCode = "VTPAYDATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
else
{
sql = "select code from period where ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, mdate1);
rs = pstmt.executeQuery();
cnt = 0;
while(rs.next())
{
lsPrdCode = checkNull(rs.getString(1));
System.out.println("To Date From Period["+lsPrdCode+"]");
cnt++;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("cnt is:::::"+ cnt);
if(cnt == 0){
errCode = "VTPRD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
lsSitefr = checkNull(genericUtility.getColumnValue("site_code__fr", dom));
System.out.println("site_code__fr....."+lsSitefr);
lsSiteto = checkNull(genericUtility.getColumnValue("site_code__to", dom));
System.out.println("site_code__to....."+lsSiteto);
sql = "select count(*) as count from period_stat where site_code between ? and ? and prd_code = ? and stat_fin = 'N'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSitefr);
pstmt.setString(2, lsSiteto);
pstmt.setString(3, lsPrdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("cnt::::::" + cnt);
if(cnt > 0) {
errCode = "VTPRDFIN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
}
if("type".equalsIgnoreCase(childNodeName))
{
}
if("prd_code__to".equalsIgnoreCase(childNodeName)||"prd_code__fr".equalsIgnoreCase(childNodeName))
{
System.out.println("INSIDE prd_code__to & prd_code__fr......." );
mval = checkNull(genericUtility.getColumnValue(childNodeName, dom));
System.out.println("VALUE OF mval"+mval);
sql = "select count(*) as count from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mval);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("cnt....."+cnt);
if(cnt == 0)
{
errCode = "VMPRD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
mval = checkNull(genericUtility.getColumnValue("prd_code__fr", dom));
System.out.println("mval......."+mval);
mval1 = checkNull(genericUtility.getColumnValue("prd_code__to", dom));
System.out.println("mval1......."+mval1);
int period1 = 0, period2 = 0;
period1 = Integer.parseInt(checkIn(mval));
System.out.println("period1......."+period1);
period2 = Integer.parseInt(checkIn(mval));
System.out.println("period2......."+period2);
System.out.println("User prd_code__fr,prd_code__to from period ["+mval+" "+mval1+"]");
if(period1 !=0 && period2!=0)
{
if(period1 > period2)
{
errCode = "VMPRD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
}
}
break;
}
System.out.println("errList....."+errList.toString());
int errListSize = errList.size();
System.out.println("errListSize......"+errListSize);
cnt = 0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = itmDBAccessEJB.getErrorString("", errCode, userId, "", conn);
errorType = errorType( conn, errCode );
if ( errString.length() > 0)
{
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
//errString = admCommon.getErrorMessage(e, "");
// errString = admCommon.getErrorXmlString(admCommon, errString, "");
//System.out.println("errString after getErrorXmlString: "+errString);
//return errString;
}
finally
{
try {
if ( conn != null )
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("[PayrollPostAcc][wfValData]Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Came Inside 1 itemChanged:::");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errFields = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errFields = itemChanged(dom, dom1, dom2, objContext, currentColumn,editFlag, xtraParams);
System.out.println("errFields :" + errFields);
}
catch (Exception e)
{
System.out.println("Exception :PayrollPostAcc :" + e.getMessage()+ ":");
errFields = genericUtility.createErrorString(e);
throw new ITMException(e);
}
return errFields;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
System.out.println("Item Changes Call..................");
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
java.sql.Timestamp toDate = null;
java.sql.Timestamp currDate = null;
String userId = "", empCodeAprv = "", loginSite = "", mgetval="";
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql="";
StringBuffer valueXmlString = new StringBuffer();
int n;
int currentFormNo = 0;
int ctr = 0;
String errCode = "", errString = "", columnValue = "", childNodeName = "", lsDefPyCurrDate="";
int mlevl = 0;
String dateAf = "", mprdCode = "", siteDescr ="", prdDescr = "", procGroupDescr = "";
String FName =" ", LName = " ", FullName = "";
String empCode = "", prdCode = "", siteCode = "", procGroup = "";
System.out.println("xtraParams::::::::::::::::"+xtraParams);
try
{
conn = getConnection();
lsDefPyCurrDate = checkNull(admCommon.getEnv("999999", "PAYPOST_CURRDT_YN",conn));
if (!(lsDefPyCurrDate.trim().equalsIgnoreCase("Y")))
{
lsDefPyCurrDate = "N";
}
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
empCodeAprv= getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
if(mlevl==0) {
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
mlevl = rs.getInt(1);
System.out.println("User level from users ["+mlevl+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Form No:::"+currentFormNo);
switch (currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("current column="+currentColumn);
valueXmlString.append("<Detail1>");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
sql = "SELECT PRD_CODE FROM PARAMETER";
System.out.println("Parameter Query:::"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mprdCode = checkNull(rs.getString(1));
System.out.println("Period Code From Parameters ["+mprdCode+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "SELECT TO_DATE FROM PERIOD WHERE CODE = ?";
System.out.println("period Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mprdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
toDate = rs.getTimestamp(1);
System.out.println("To Date From Period["+toDate+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(toDate==null)
{
toDate = currDate;
}
if(toDate!=null)
{
if(toDate.after(currDate)|| "Y".equalsIgnoreCase(lsDefPyCurrDate)) {
System.out.println("Date From period["+toDate+"]");
System.out.println("CurrentDate["+currDate+"]");
toDate = currDate;
}
}
dateAf = getCurrdateAppFormat(toDate);
valueXmlString.append("<payroll_date><![CDATA[").append(dateAf).append("]]></payroll_date>\r\n");
valueXmlString.append("<prd_code__fr><![CDATA[").append(mprdCode).append("]]></prd_code__fr>\r\n");
valueXmlString.append("<prd_code__to><![CDATA[").append(mprdCode).append("]]></prd_code__to>\r\n");
sql ="SELECT DESCR FROM PERIOD WHERE CODE = ?";;
System.out.println("period Descr Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mprdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
prdDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_prd_descr><![CDATA[").append(prdDescr).append("]]></fr_prd_descr>\r\n");
valueXmlString.append("<to_prd_descr><![CDATA[").append(prdDescr).append("]]></to_prd_descr>\r\n");
if(loginSite != null && loginSite.trim().length() > 0)
{
valueXmlString.append("<site_code__fr><![CDATA[").append(loginSite).append("]]></site_code__fr>\r\n");
valueXmlString.append("<site_code__to><![CDATA[").append(loginSite).append("]]></site_code__to>\r\n");
sql = " SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
System.out.println("Site Descr Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_site_descr><![CDATA[").append(siteDescr).append("]]></fr_site_descr>\r\n");
valueXmlString.append("<to_site_descr><![CDATA[").append(siteDescr).append("]]></to_site_descr>\r\n");
}
if(mlevl>1) {
valueXmlString.append("<site_code__fr protect=\"1\" ><![CDATA[").append(loginSite).append("]]></site_code__fr>\r\n");
valueXmlString.append("<site_code__to protect=\"1\" ><![CDATA[").append(loginSite).append("]]></site_code__to>\r\n");
}
mgetval=checkNull(genericUtility.getColumnValue("type", dom));
if(mgetval == null || (mgetval.trim().length() == 0))
{
valueXmlString.append("<type>").append("<![CDATA["+"PP"+"]]>").append("</type>");
}else {
valueXmlString.append("<type><![CDATA[").append(mgetval).append("]]></type>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("emp_code__fr") ||currentColumn.trim().equalsIgnoreCase("emp_code__to") )
{
//empCode = currentColumn.trim();
empCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql = "SELECT EMP_FNAME, EMP_LNAME FROM EMPLOYEE WHERE EMP_CODE = ?";;
System.out.println("Emp Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
FName = checkNull(rs.getString(1));
LName = checkNull(rs.getString(2));
}
FullName = FName + " " + LName;
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("emp_code__fr"))
{
valueXmlString.append("<emp_name__fr>").append(FullName).append("</emp_name__fr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("emp_code__to"))
{
valueXmlString.append("<emp_name__to>").append(FullName).append("</emp_name__to>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("prd_code__fr") ||currentColumn.trim().equalsIgnoreCase("prd_code__to") )
{
//prdCode = currentColumn.trim();
prdCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql ="SELECT DESCR FROM PERIOD WHERE CODE = ?";;
System.out.println("period Descr Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
prdDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("prd_code__fr"))
{
valueXmlString.append("<fr_prd_descr>").append(prdDescr).append("</fr_prd_descr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("prd_code__to"))
{
valueXmlString.append("<to_prd_descr>").append(prdDescr).append("</to_prd_descr>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("site_code__fr") ||currentColumn.trim().equalsIgnoreCase("site_code__to") )
{
//siteCode = currentColumn.trim();
siteCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql ="SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
System.out.println("Site descr Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr =checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("site_code__fr"))
{
valueXmlString.append("<fr_site_descr>").append(siteDescr).append("</fr_site_descr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("site_code__to"))
{
valueXmlString.append("<to_site_descr>").append(siteDescr).append("</to_site_descr>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("proc_group__fr") ||currentColumn.trim().equalsIgnoreCase("proc_group__to") )
{
//procGroup = currentColumn.trim();
procGroup = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql =" SELECT DESCR FROM GENCODES WHERE FLD_NAME='PROC_GROUP' AND FLD_VALUE = ?";
System.out.println("PROC_GROUP Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, procGroup);
rs = pstmt.executeQuery();
if(rs.next())
{
procGroupDescr =checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("proc_group__fr"))
{
valueXmlString.append("<proc_group__fr_name>").append(procGroupDescr).append("</proc_group__fr_name>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("proc_group__to"))
{
valueXmlString.append("<proc_group__to_name>").append(procGroupDescr).append("</proc_group__to_name>\r\n");
}
}
valueXmlString.append("</Detail1>\r\n");
break;
}
}//END OF SWITCH
valueXmlString.append("</Root>");
System.out.println("valueXmlString[sepclose]"+valueXmlString);
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
private String getCurrdateAppFormat(java.sql.Timestamp ts) throws ITMException
{
String dateAf ="";
System.out.println("Comming Date[In DB Format] :::"+ts.toString());
try
{
Object date = null;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(ts.toString());
dateAf = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(date).toString();
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("Retturning Date :::"+dateAf);
return (dateAf);
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
private String checkIn(String input)
{
if (input == null || input.trim().length() == 0)
{
input = "0";
}
return input;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface PayrollPostAccLocal extends ValidatorLocal {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface PayrollPostAccRemote extends ValidatorRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import bsh.util.Util;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.util.*;
import javax.ejb.Stateless;
@Stateless
public class PayrollSingleIC extends ValidatorEJB implements PayrollSingleLocal,PayrollSingleRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
AdmCommon admCommon = new AdmCommon();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Came Inside 1 itemChanged:::");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errFields = null;
genericUtility = new E12GenericUtility();
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errFields = itemChanged(dom, dom1, dom2, objContext, currentColumn,editFlag, xtraParams);
System.out.println("errFields :" + errFields);
}
catch (Exception e)
{
System.out.println("Exception :PayrollPostAcc :" + e.getMessage()+ ":");
errFields = genericUtility.createErrorString(e);
throw new ITMException(e);
}
return errFields;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
System.out.println("Item Changes Call..................");
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql="";
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
String userId = "", empCodeAprv = "", loginSite = "", mgetval="";
int ctr = 0;
int mlevl = 0;
String errCode = "", errString = "", columnValue = "", childNodeName = "";
String FName =" ", LName = " ", FullName = "";
String empCode = "", prdCode = "", siteCode = "", procGroup = "",mtype="";
String dateAf = "", mprdCode = "", siteDescr ="", prdDescr = "", procGroupDescr = "",mprd="";
String protect = "0";
try
{
Date today = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
empCodeAprv= getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
if(mlevl==0) {
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
mlevl = rs.getInt(1);
System.out.println("User level from users ["+mlevl+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Form No:::"+currentFormNo);
switch (currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("current column="+currentColumn);
valueXmlString.append("<Detail1>");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
valueXmlString.append("<prd_code__to protect=\"1\" ><![CDATA[").append("").append("]]></prd_code__to>\r\n");
valueXmlString.append("<prd_code__arr protect=\"0\" ><![CDATA[").append("").append("]]></prd_code__arr>\r\n");
//mtype = checkNull(genericUtility.getColumnValue("type", dom));
valueXmlString.append("<type protect=\"1\" ><![CDATA[").append("PP").append("]]></type>\r\n");
/*
valueXmlString.append("<prd_code__to><![CDATA[").append("").append("]]></prd_code__to>\r\n");
valueXmlString.append("<prd_code__arr><![CDATA[").append("").append("]]></prd_code__arr>\r\n");
valueXmlString.append("<type><![CDATA[").append("").append("]]></type>\r\n");
*/
sql = "SELECT PRD_CODE FROM PARAMETER";
System.out.println("Parameter Query:::"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mprdCode = checkNull(rs.getString(1));
System.out.println("Period Code From Parameters ["+mprdCode+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<prd_code__fr><![CDATA[").append(mprdCode).append("]]></prd_code__fr>\r\n");
valueXmlString.append("<prd_code__to><![CDATA[").append(mprdCode).append("]]></prd_code__to>\r\n");
valueXmlString.append("<prd_code__arr><![CDATA[").append(mprdCode).append("]]></prd_code__arr>\r\n");
/*mtype = checkNull(genericUtility.getColumnValue("type", dom));
valueXmlString.append("<type><![CDATA[").append(mtype).append("]]></type>\r\n");*/
String todateStr = sdf.format(today);
sql ="SELECT DESCR FROM PERIOD WHERE CODE = ?";;
System.out.println("period Descr Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mprdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
prdDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_prd_descr><![CDATA[").append(prdDescr).append("]]></fr_prd_descr>\r\n");
valueXmlString.append("<to_prd_descr><![CDATA[").append(prdDescr).append("]]></to_prd_descr>\r\n");
valueXmlString.append("<payroll_date><![CDATA[").append(todateStr).append("]]></payroll_date>\r\n");
if(mlevl>1) {
valueXmlString.append("<site_code__fr protect=\"1\" ><![CDATA[").append("").append("]]></site_code__fr>\r\n");
valueXmlString.append("<site_code__to protect=\"1\" ><![CDATA[").append("").append("]]></site_code__to>\r\n");
}
if(loginSite != null && loginSite.trim().length() > 0)
{
valueXmlString.append("<site_code__fr><![CDATA[").append(loginSite).append("]]></site_code__fr>\r\n");
valueXmlString.append("<site_code__to><![CDATA[").append(loginSite).append("]]></site_code__to>\r\n");
sql = " SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
System.out.println("Site Descr Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_site_descr><![CDATA[").append(siteDescr).append("]]></fr_site_descr>\r\n");
valueXmlString.append("<to_site_descr><![CDATA[").append(siteDescr).append("]]></to_site_descr>\r\n");
}
valueXmlString.append("<consider_attd><![CDATA[").append("N").append("]]></consider_attd>\r\n");
valueXmlString.append("<cbx_ip protect=\"1\" ><![CDATA[").append("Y").append("]]></cbx_ip>\r\n");
valueXmlString.append("<cbx_pp protect=\"1\" ><![CDATA[").append("Y").append("]]></cbx_pp>\r\n");
valueXmlString.append("<cbx_py><![CDATA[").append("Y").append("]]></cbx_py>\r\n");
valueXmlString.append("<cbx_ap><![CDATA[").append("N").append("]]></cbx_ap>\r\n");
valueXmlString.append("<cbx_ap_changes><![CDATA[").append("Y").append("]]></cbx_ap_changes>\r\n");
}
else if (currentColumn.trim().equalsIgnoreCase("emp_code__fr") ||currentColumn.trim().equalsIgnoreCase("emp_code__to") )
{
empCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql = "SELECT EMP_FNAME, EMP_LNAME FROM EMPLOYEE WHERE EMP_CODE = ?";;
System.out.println("Emp Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
FName = checkNull(rs.getString(1));
LName = checkNull(rs.getString(2));
}
FullName = FName + " " + LName;
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("emp_code__fr"))
{
valueXmlString.append("<emp_name__fr>").append(FullName).append("</emp_name__fr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("emp_code__to"))
{
valueXmlString.append("<emp_name__to>").append(FullName).append("</emp_name__to>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("prd_code__fr") ||currentColumn.trim().equalsIgnoreCase("prd_code__to") )
{
prdCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql ="SELECT DESCR FROM PERIOD WHERE CODE = ?";;
System.out.println("period Descr Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
prdDescr = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("prd_code__fr"))
{
valueXmlString.append("<fr_prd_descr>").append(prdDescr).append("</fr_prd_descr>\r\n");
valueXmlString.append("<prd_code__to>").append(prdCode).append("</prd_code__to>\r\n");
valueXmlString.append("<to_prd_descr>").append(prdDescr).append("</to_prd_descr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("prd_code__to"))
{
valueXmlString.append("<to_prd_descr>").append(prdDescr).append("</to_prd_descr>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("type"))
{
mtype = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql = "select prd_code from parameter";
System.out.println("Emp Type Query:::"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mprd = checkNull(rs.getString(1));
}
if(mtype=="AR"||mtype=="AP")
{
valueXmlString.append("<prd_code__arr>").append(mprd).append("</prd_code__arr>\r\n");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if (currentColumn.trim().equalsIgnoreCase("site_code__fr") ||currentColumn.trim().equalsIgnoreCase("site_code__to") )
{
siteCode = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql ="SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
System.out.println("Site descr Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr =checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("site_code__fr"))
{
valueXmlString.append("<fr_site_descr>").append(siteDescr).append("</fr_site_descr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("site_code__to"))
{
valueXmlString.append("<to_site_descr>").append(siteDescr).append("</to_site_descr>\r\n");
}
}
else if (currentColumn.trim().equalsIgnoreCase("proc_group__from") ||currentColumn.trim().equalsIgnoreCase("proc_group__to") )
{
procGroup = checkNull(genericUtility.getColumnValue(currentColumn.trim(), dom));
sql =" SELECT DESCR FROM GENCODES WHERE FLD_NAME='PROC_GROUP' AND FLD_VALUE = ?";
System.out.println("PROC_GROUP Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, procGroup);
rs = pstmt.executeQuery();
if(rs.next())
{
procGroupDescr =checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currentColumn.trim().equalsIgnoreCase("proc_group__from"))
{
valueXmlString.append("<proc_group__fr_name>").append(procGroupDescr).append("</proc_group__fr_name>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("proc_group__to"))
{
valueXmlString.append("<proc_group__to_name>").append(procGroupDescr).append("</proc_group__to_name>\r\n");
}
}
valueXmlString.append("</Detail1>");
break;
}
}//END OF SWITCH
valueXmlString.append("</Root>");
System.out.println("valueXmlString[sepclose]"+valueXmlString);
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface PayrollSingleICLocal extends ValidatorLocal{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Remote
public interface PayrollSingleICRemote extends ValidatorLocal{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
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