Commit 9ae2223e authored by vvengurlekar's avatar vvengurlekar

EmpLvePrkBalTrfCanc.java

EmpLvePrkBalTrfCancLocal.java
EmpLvePrkBalTrfCancRemote.java
EmpLvePrkBalTrfConf.java
EmpLvePrkBalTrfConfLocal.java
EmpLvePrkBalTrfConfRemote.java
EmpLvePrkBalTrfDefault.java
EmpLvePrkBalTrfDefaultLocal.java
EmpLvePrkBalTrfDefaultRemote.java
EmpLvePrkBalTrfIC.java
EmpLvePrkBalTrfICLocal.java
EmpLvePrkBalTrfICRemote.java - emplyee leave perk transfer component committed


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187124 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9fa212e6
package ibase.webitm.ejb.adm;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;//Modified By Hemlata on[20/11/2014] [As per changes in framework to use genericUtility ]
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* PURPOSE : Validation and Itemchange for
* Leave/Park balance transfer screen
*
* @author
*
*/
@Stateless
public class EmpLvePrkBalTrfIC extends ValidatorEJB implements EmpLvePrkBalTrfICLocal ,EmpLvePrkBalTrfICRemote
{
AdmCommon admCommon = new AdmCommon();
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
System.out.println("EmpLvePrkBalTrfIC xmlString in itemChanged..::["+xmlString+"]");
System.out.println("EmpLvePrkBalTrfIC xmlString1 in itemChanged..:: ["+xmlString1+"]");
System.out.println("EmpLvePrkBalTrfIC xmlString2 in itemChanged..:: ["+xmlString2+"]");
if(xmlString != null && xmlString.length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println("EmpLvePrkBalTrfIC errString Returing at Stage 1["+errString+"]");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :EmpLvePrkBalTrfIC [:" + e.getMessage() + ":]" );
errString = genericUtility.createErrorString(e);
}
System.out.println("EmpLvePrkBalTrfIC errString returing at Stage 2[" + errString+"]");
return errString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("ITEMCHANGED CALLING");
String objNameDefault = "";
int currentFormNo = 0;
String sql = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pstmt = null;
ResultSet rs = null;
String empCodeFrom = "";
String empCodeTo = "";
String empSiteTo = "";
java.util.Date relieveDate = null;
String relieveDate1 = "";
String empNameFrom = "";
String empNameTo ="";
String siteDescrFrm = "";
String siteDescrTo = "";
String tranType = "";
String chgUser = "";
String chgTerm = "";
int ctr = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String columnValue="", errString = "";
E12GenericUtility genericUtility = new E12GenericUtility();
String loginEmpCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" ) );
String loginSiteCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode") );
chgUser = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "termId" );
if ( chgUser == null || chgUser.trim().length() == 0 )
{
chgUser = "SYSTEM";
}
if ( chgTerm == null || chgTerm.trim().length() == 0 )
{
chgTerm = "SYSTEM";
}
StringBuffer valueXmlString = new StringBuffer();
System.out.println("Login Employee got..:: ["+loginEmpCode+"]");
System.out.println("objContext ..:: ["+objContext+"]");
System.out.println("currentColumn ..:: ["+currentColumn+"]");
System.out.println("editFlag ..:: ["+editFlag+"]");
System.out.println("xtraParams ..:: ["+xtraParams+"]");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("currentFormNo ..:: ["+currentFormNo+"]");
try
{
conn = getConnection();
conn.setAutoCommit( false );
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append( editFlag ).append("</editFlag></header>");
objNameDefault = checkNull( getObjName( dom ,"1" ) );
System.out.println("objNameDefault ..:: ["+objNameDefault+"]");
SimpleDateFormat sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
Date currentDate = new Date();
String curDate = currentDate == null ? "" : sdf.format( currentDate );
System.out.println( "curDate::::::"+curDate );
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************");
switch ( currentFormNo )
{
case 1:
//{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
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("[" + currentColumn + "] ==> '" + columnValue + "'");
if( checkNull( loginSiteCode ).length() > 0 )
{
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, loginSiteCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
siteDescrFrm = checkNull( rs.getString( "DESCR" ) );
}
System.out.println("description::: [:" + siteDescrFrm+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
empCodeFrom = checkNull( genericUtility.getColumnValue( "emp_code__fr", dom, "1" ) ) ;
if( "itm_default".equalsIgnoreCase( currentColumn ) )
{
System.out.println("itm_default CALLING");
valueXmlString.append( "<tran_date protect=\"1\"><![CDATA[").append( curDate ).append("]]></tran_date>\r\n" );
valueXmlString.append( "<tran_type><![CDATA[").append( "LVE" ).append("]]></tran_type>\r\n" );
valueXmlString.append( "<tran_mode protect=\"1\"><![CDATA[").append( "I" ).append("]]></tran_mode>\r\n" );
valueXmlString.append("<emp_code__fr><![CDATA[").append( empCodeFrom ).append("]]></emp_code__fr>\r\n");
valueXmlString.append( "<site_code__fr protect=\"1\"><![CDATA[").append( loginSiteCode ).append("]]></site_code__fr>\r\n" );
valueXmlString.append( "<site_descr__fr protect=\"1\"><![CDATA[").append( siteDescrFrm ).append("]]></site_descr__fr>\r\n" );
valueXmlString.append( "<status protect=\"1\"><![CDATA[").append( "U" ).append("]]></status>\r\n" );
valueXmlString.append( "<status_date protect=\"1\"><![CDATA[").append( curDate ).append("]]></status_date>\r\n" );
valueXmlString.append( "<add_user protect=\"1\"><![CDATA[").append( chgUser ).append( "]]></add_user>\r\n" );
valueXmlString.append( "<add_term protect=\"1\"><![CDATA[").append( chgTerm ).append( "]]></add_term>\r\n" );
valueXmlString.append( "<chg_date protect=\"1\"><![CDATA[").append( curDate ).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_user protect=\"1\"><![CDATA[").append( chgUser ).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_term protect=\"1\"><![CDATA[").append( chgTerm ).append( "]]></chg_term>\r\n" );
}
else if( "itm_defaultedit".equalsIgnoreCase( currentColumn ) )
{
System.out.println("itm_defaultedit CALLING");
String tranIdEdit = checkNull( genericUtility.getColumnValue( "tran_id", dom ) );
String status = checkNull( genericUtility.getColumnValue( "status", dom ) );
tranType = checkNull( getColumnValue( "tran_type", dom, "1" ) ) ;
valueXmlString.append("<tran_id protect=\"1\"><![CDATA[").append( tranIdEdit ).append("]]></tran_id>\r\n");
valueXmlString.append("<emp_code__fr protect=\"1\"><![CDATA[").append( empCodeFrom ).append("]]></emp_code__fr>\r\n");
valueXmlString.append("<tran_type protect=\"1\"><![CDATA[").append( tranType ).append("]]></tran_type>\r\n");
valueXmlString.append( "<tran_date protect=\"1\"><![CDATA[").append( curDate ).append("]]></tran_date>\r\n" );
valueXmlString.append( "<site_code__fr protect=\"1\"><![CDATA[").append( loginSiteCode ).append("]]></site_code__fr>\r\n" );
valueXmlString.append( "<status protect=\"1\"><![CDATA[").append( status ).append("]]></status>\r\n" );
}
else if ( "emp_code__fr".equalsIgnoreCase( currentColumn ) )
{
if(empCodeFrom != null && empCodeFrom.length() > 0 )
{
sql = "SELECT RELIEVE_DATE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,empCodeFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
relieveDate = rs.getDate("RELIEVE_DATE");
}
System.out.println("relieveDate [:" + relieveDate+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( relieveDate != null )
{
relieveDate1 = sdf.format( relieveDate );
}
System.out.println("Formated relieveDate1:::::: [" + relieveDate1+ "]" );
valueXmlString.append("<balance_ason><![CDATA[").append( relieveDate1 ).append("]]></balance_ason>\r\n");
sql = "SELECT FN_GET_EMP_NAME( ? ,'X' )AS EMP_NAME__FROM FROM DUAL";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,empCodeFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
empNameFrom = checkNull(rs.getString("EMP_NAME__FROM"));
}
System.out.println("empNameFrom [:" + empNameFrom+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<emp_name__fr protect=\"1\"><![CDATA[").append( empNameFrom ).append("]]></emp_name__fr>\r\n");
}
else
{
valueXmlString.append("<emp_name__fr protect=\"1\"><![CDATA[").append( "" ).append("]]></emp_name__fr>\r\n");
}
}
else if ( "emp_code__to".equalsIgnoreCase( currentColumn ) )
{
empCodeTo = checkNull( genericUtility.getColumnValue("emp_code__to",dom,"1") ) ;
System.out.println("empCodeTo:::::: [:" + empCodeTo+ ":]" );
if(empCodeTo != null && empCodeTo.length() > 0)
{
sql = "SELECT EMP_SITE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, empCodeTo );
rs = pstmt.executeQuery();
if(rs.next())
{
empSiteTo = checkNull( rs.getString("EMP_SITE") );
}
System.out.println("empSite [:" + empSiteTo+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( checkNull( empSiteTo ).length() > 0 && !"null".equalsIgnoreCase( empSiteTo ) )
{
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empSiteTo );
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescrTo = checkNull( rs.getString( "DESCR" ) );
}
System.out.println("description::: [:" + siteDescrTo+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("<emp_code__to><![CDATA[").append( empCodeTo ).append("]]></emp_code__to>\r\n");
valueXmlString.append("<site_code__to><![CDATA[").append( empSiteTo ).append("]]></site_code__to>\r\n");
valueXmlString.append("<site_descr__to><![CDATA[").append( siteDescrTo ).append("]]></site_descr__to>\r\n");
sql = "SELECT FN_GET_EMP_NAME( ? ,'X')AS EMP_NAME__TO FROM DUAL";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empCodeTo );
rs = pstmt.executeQuery();
if(rs.next())
{
empNameTo = checkNull( rs.getString( "EMP_NAME__TO" ) );
}
System.out.println("empNameTo:::::: [:" + empNameTo+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<emp_name__to><![CDATA[").append( empNameTo ).append("]]></emp_name__to>\r\n");
}
else
{
valueXmlString.append("<emp_code__to><![CDATA[").append( "" ).append("]]></emp_code__to>\r\n");
valueXmlString.append("<site_code__to><![CDATA[").append( "" ).append("]]></site_code__to>\r\n");
valueXmlString.append("<site_descr__to><![CDATA[").append( "" ).append("]]></site_descr__to>\r\n");
valueXmlString.append("<emp_name__to><![CDATA[").append( "" ).append("]]></emp_name__to>\r\n");
}
}
valueXmlString.append("</Detail1>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println( "Exception :EmpLvePrkBalTrfIC [itemChanged(String xmlString)] : ==>\n"+e.getMessage());
//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 (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("[EmpLvePrkBalTrfIC][itemChanged]Exception ::"+e);
e.printStackTrace();
}
}
System.out.println("valueXmlString....["+valueXmlString.toString());
return valueXmlString.toString();
}
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Came Inside 1 wfValData:::Umakanta");
E12GenericUtility genericUtility = new E12GenericUtility();
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("xmlString ["+xmlString+"]");
System.out.println("xmlString1["+xmlString1+"]");
System.out.println("xmlString2["+xmlString2+"]");
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = parseString( xmlString );
}
else
{
System.out.println("xmlstring is null");
}
if( xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = parseString( xmlString1 );
}
else
{
System.out.println("xmlstring1 is null");
}
if( xmlString2 != null && xmlString2.trim().length() != 0 )
{
dom2 = parseString( xmlString2 );
}
else
{
System.out.println("xmlstring2 is null");
}
errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams );
}
catch(Exception e)
{
System.out.println("Exception : [EmpLvePrkBalTrfIC][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
errString = genericUtility.createErrorString(e);
}
return (errString);
}
public String wfValData( Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
System.out.println("Validation CALLING");
Node parentNode = null;
Node childNode = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
String errString = "";
String childNodeName = "";
int currentFormNo = 0;
int childNodeListLength = 0;
String msgType = "";
String errCode = "";
String errFldName = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int cnt = 0;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int ctr = 0;
int count = 0;
String userId = "" ;
String objName = "";
String keyFlag = "";
String tranId = "";
String empCodeFrom = "";
String empCodeTo = "";
String relieveDate1 = "";
java.util.Date relieveDate = null ;
String userLevel = "";
String siteCodeFrom = "";
String siteCodeTo = "";
java.util.Date joinDate = null ;
String tranMode = "", joinDateStr="", retString = "";
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessLocal itmDBAccess = null;
Connection conn = null;
try
{
conn = getConnection();
conn.setAutoCommit( false );
AppConnectParm appConnect = new AppConnectParm();
InitialContext ctx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
System.out.println("objContext ..:: ["+objContext+"]");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("currentFormNo ..:: ["+currentFormNo+"]");
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
String loginCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ) );
String loginSiteCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ) );
objName = checkNull( getObjName( dom , "1" ) );
System.out.println("loginCode::::::["+loginCode+"]");
System.out.println("loginSiteCode::::::["+loginSiteCode+"]");
SimpleDateFormat sdf = new SimpleDateFormat( getApplDateFormat() );
switch( currentFormNo )
{
case 1:
{
parentNodeList = dom.getElementsByTagName( "Detail"+currentFormNo );
parentNode = parentNodeList.item( 0 );
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("Umakanta::childNodeListLength["+childNodeListLength+"]");
for( ctr = 0; ctr < childNodeListLength; ctr++ )
{
childNode = childNodeList.item( ctr );
childNodeName = childNode.getNodeName();
System.out.println("Umakanta::childNodeName["+childNodeName+"]");
if( "tran_id".equalsIgnoreCase( childNodeName ) )
{
tranId = checkNull( genericUtility.getColumnValue( "tran_id", dom ) );
System.out.println("Tran ID= ["+tranId+"]");
keyFlag = getKeyFlag( conn, objName );
if( "M".equalsIgnoreCase( keyFlag ) && "A".equalsIgnoreCase( editFlag ) )
{
if( tranId.length() == 0 )
{
retString = itmDBAccess.getErrorString( "", "VTELPTRF01", userId, "", conn );
return retString;
}
else
{
sql = " SELECT COUNT (*) FROM EMP_LVEPRKBAL_TRFHDR WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, tranId );
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt( 1 );
System.out.println("count>>>>>>>>>>>"+count);
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( count > 0 )
{
retString = itmDBAccess.getErrorString( "", "VTELPTRF02", userId, "", conn );
return retString;
}
}
}
}
else if( "emp_code__fr".equalsIgnoreCase( childNodeName ) )
{
System.out.println("Umakanta::childNodeName["+childNodeName+"]");
count = 0;
empCodeFrom = checkNull( genericUtility.getColumnValue( "emp_code__fr", dom, objContext ) );
System.out.println("empCodeFrom got in the validation ..::["+empCodeFrom+"]");
if( empCodeFrom == null || empCodeFrom.length() == 0 )
{
System.out.println("Invalid empCodeFrom ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF03", userId, "", conn );
return retString;
}
else
{
sql = " SELECT COUNT(*) AS EMP_CNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, empCodeFrom );
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getInt("EMP_CNT");
}
System.out.println("count:::: "+count );
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( count <= 0 )
{
System.out.println( "Invalid empCodeFrom , empCodeFrom not present in employee master::::" );
retString = itmDBAccess.getErrorString( "", "VTELPTRF04", userId, "", conn );
return retString;
}
else
{
sql = "SELECT RELIEVE_DATE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,empCodeFrom);
rs = pstmt.executeQuery();
if( rs.next())
{
relieveDate = rs.getDate("RELIEVE_DATE");
}
System.out.println("relieveDate:::: ["+relieveDate+"]");
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( relieveDate == null )
{
System.out.println("relieveDate for empCodeFrom is not present in employee master::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF05", userId, "", conn );
return retString;
}
sql = "SELECT USR_LEV FROM USERS WHERE CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, loginCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
userLevel = checkNull( rs.getString( "USR_LEV" ) );
}
System.out.println("userLevel:::::::["+userLevel+"]");
if( Integer.parseInt( userLevel ) > 1 )
{
siteCodeFrom = checkNull( genericUtility.getColumnValue( "site_code__fr", dom, objContext ) );
System.out.println("siteCodeFrom got in the validation ..::["+siteCodeFrom+"]");
if( !( siteCodeFrom.equalsIgnoreCase( loginSiteCode ) ) )
{
System.out.println("siteCodeFrom not equal to loginSiteCode::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF06", userId, "", conn );
return retString;
}
}
}
}
}
else if("emp_code__to".equalsIgnoreCase( childNodeName ) )
{
count = 0;
empCodeTo = checkNull( genericUtility.getColumnValue( "emp_code__to", dom,objContext ) );
System.out.println("empCodeTo got in the validation ..::["+empCodeTo+"]");
if( empCodeTo == null || empCodeTo.trim().length() == 0 )
{
System.out.println("Invalid empCodeTo ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF07", userId, "", conn );
return retString;
}
else
{
relieveDate1 = checkNull( genericUtility.getColumnValue( "balance_ason", dom,objContext ) );
System.out.println("relieveDate1 got in the validation ..::["+relieveDate1+"]");
java.util.Date relieveDate2 = sdf.parse( relieveDate1 );
System.out.println("relieveDate2 After formating ..::["+relieveDate2+"]");
tranMode = checkNull( genericUtility.getColumnValue( "tran_mode",dom,objContext ) );
System.out.println("tranMode got in the validation ..::["+tranMode+"]");
if ( "R".equalsIgnoreCase( tranMode ) )
{
/*if( empCodeTo == null || empCodeTo.length() == 0 )
{ commented by Varsha v on 25-06-18
System.out.println("Invalid empCodeTo ::::");
errList.add( "VTELPTRF07" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VTELPTRF07" );
System.out.println("Umakanta::msgType4["+msgType+"]");
if ( "E".equalsIgnoreCase( msgType ) )
{
break;
}
}*/
}
else
{
if( checkNull( empCodeTo ).length() > 0 )
{
if ( empCodeTo.equalsIgnoreCase( empCodeFrom ) )
{
System.out.println("empCodeTo can not same as empCodeForm ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF08", userId, "", conn );
return retString;
}
else
{
sql = " SELECT COUNT(*) AS EMP_CNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empCodeTo );
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getInt("EMP_CNT");
}
System.out.println("count:::: "+count);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count <= 0)
{
System.out.println("Invalid empCodeTo , empCodeTo not present in employee master::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF09", userId, "", conn );
return retString;
}
else
{
sql = "SELECT DATE_JOIN FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,empCodeTo);
rs = pstmt.executeQuery();
if( rs.next())
{
joinDate = rs.getDate("DATE_JOIN");
}
System.out.println("joinDate:::: ["+joinDate+"]");
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
//condition changed by Varsha on 25-06-18 because join date relieve date can not be same
//if( joinDate.compareTo( relieveDate2 ) < 0 )
//if( joinDate.compareTo( relieveDate2 ) <= 0 )
if( joinDate.compareTo( relieveDate2 ) <= 0 )
{
System.out.println("joinDate is not greater than relieveDate ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF10", userId, "", conn );
return retString;
}
siteCodeFrom = checkNull( genericUtility.getColumnValue( "site_code__fr", dom, objContext ) );
System.out.println("siteCodeFrom got in the validation ..::["+siteCodeFrom+"]");
siteCodeTo = checkNull( genericUtility.getColumnValue( "site_code__to", dom, objContext ) );
System.out.println("siteCodeTo got in the validation ..::["+siteCodeTo+"]");
if( siteCodeFrom != null && siteCodeFrom.length() > 0 && siteCodeTo != null && siteCodeTo.length() > 0 )
{
String finEntity1 = "";
String finEntity2 = "";
List<String> finEntityList = new ArrayList<String>();
//sql = "SELECT FIN_ENTITY FROM SITE WHERE SITE_CODE = ? ";
sql = "SELECT FIN_ENTITY FROM SITE WHERE SITE_CODE in (?,?) ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, siteCodeFrom );
pstmt.setString( 2, siteCodeTo );
rs = pstmt.executeQuery();
while( rs.next())
{
//finEntity1 = rs.getString( "FIN_ENTITY" );
finEntityList.add(rs.getString( "FIN_ENTITY" ));
}
System.out.println("finEntityList:::: ["+finEntityList+"] -----> size of finEntityList: ["+finEntityList.size()+"]");
//added by Varsha V on 25-06-18 for assigning values for finentity from and to
if(finEntityList.size() >= 2)
{
finEntity1 = finEntityList.get(0);
finEntity2 = finEntityList.get(1);
}
else if(finEntityList.size() == 1)
{
finEntity1 = finEntityList.get(0);
finEntity2 = "";
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
//Commented by Varsha V on 26-06-18 for merging below sql in above sql
/*sql = "SELECT FIN_ENTITY FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, siteCodeTo );
rs = pstmt.executeQuery();
if( rs.next())
{
finEntity2 = rs.getString("FIN_ENTITY");
}
System.out.println("finEntity2:::: ["+finEntity2+"]");
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}*/
if( finEntity1.equalsIgnoreCase( finEntity2 ) )
{
System.out.println("finEntity1.equalsIgnoreCase(finEntity2) ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF11", userId, "", conn );
return retString;
}
}
}
}
}
}
}
}
}
}
break;
}
/*int errListSize = errList.size();
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = ( String )errList.get( cnt );
errFldName = ( String )errFields.get( cnt );
System.out.println("errCode ........[ "+errCode+"]" );
errString = getErrorString( errFldName, errCode, userId );
System.out.println("errString is : ::::>>>>[" +errString+"]" );
msgType = 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 ( msgType.equalsIgnoreCase("E") )
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();*/
System.out.println("Umakanta::errString["+errString+"]");
}
catch(Exception e)
{
System.out.println( "Exception : [EmpLvePrkBalTrfIC][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
errString = admCommon.getErrorMessage(e, "");
errString = admCommon.getErrorXmlString(admCommon, errString, "");
System.out.println("errString after getErrorXmlString: "+errString);
return errString;
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e1)
{
System.out.println( "Exception : [EmpLvePrkBalTrfIC][wfValData] : ==>\n"+e1.getMessage());
errString = admCommon.getErrorMessage(e1, "");
errString = admCommon.getErrorXmlString(admCommon, errString, "");
System.out.println("errString after getErrorXmlString: "+errString);
return errString;
}
}
return errString;
}
//Start of wfValData End
/**
* This Method checks if value is equal to null or object is
* equal to null then set empty("") String.
* @param input
* @return String value
*/
private String checkNull( String input )
{
if ( input == null || "null".equalsIgnoreCase(input) )
{
input= "";
}
return input.trim();
}
/**
* This method get object name from dom.
*
* @param dom
* @param objContext
* @return object name
*/
private String getObjName( Document dom, String objContext )
{
Node elementName = null;
NodeList elementList = null;
String objName = "";
elementList = dom.getElementsByTagName("Detail"+objContext);
elementName = elementList.item(0);
if ( elementName != null && ( "Detail"+objContext ).equalsIgnoreCase( elementName.getNodeName() ) )
{
NamedNodeMap etlAttributes = elementName.getAttributes();
if ( etlAttributes != null )
{
if ( etlAttributes.getNamedItem( "objName" ) != null)
{
objName = etlAttributes.getNamedItem( "objName" ).getNodeValue();
}
}
}
return objName;
}
/**
* This Method get message type from messages
* table against the message no.
*
* @param conn
* @param errorCode
* @return message type.
* @throws ITMException
* @throws RemoteException
*/
private String errorType( Connection conn , String errorCode ) throws ITMException, RemoteException
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
String retString = "";
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
retString = admCommon.getErrorMessage(ex, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
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);
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
}
return msgType;
}
/**
* This method get key flag from transetup
* against the object name.
*
* @param conn
* @param objName
* @return keyFlag
* @throws ITMException
* @throws RemoteException
*/
private String getKeyFlag( Connection conn, String objName ) throws ITMException, RemoteException
{
PreparedStatement pstmt = null ;
ResultSet rs = null;
String tranWindow = "w_" + objName;
String keyFlag = "";
String sql = "", retString = "";
try
{
sql = "select key_flag from transetup where tran_window = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, tranWindow );
rs = pstmt.executeQuery();
if(rs.next())
{
keyFlag = checkNull( rs.getString("key_flag") );
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception ex )
{
ex.printStackTrace();
retString = admCommon.getErrorMessage(ex, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
}
return keyFlag;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface EmpLvePrkBalTrfICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, 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;
}
\ No newline at end of file
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface EmpLvePrkBalTrfICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, 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;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.*;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.adm.AdmCommon;
import javax.naming.InitialContext;
/**
* PURPOSE : on click of cancel button check transaction status
* and cancel the transaction.
*
* @author Umakanta Das On dated 21-MAR-2016
*
*/
@javax.ejb.Stateless
public class EmpLvePrkBalTrfCanc extends ActionHandlerEJB implements EmpLvePrkBalTrfCancRemote, EmpLvePrkBalTrfCancLocal
{
AdmCommon admCommon = new AdmCommon();
public String actionHandler( String tranId, String xtraParams, String xmlString ) throws RemoteException,ITMException
{
Connection conn = null;
String retString="";
boolean errorFound = false;
try
{
conn = getConnection();
retString = actionHandler( tranId, xtraParams, xmlString, conn );
}
catch(Exception e)
{
errorFound = true;
System.out.println("Exception EmpLvePrkBalTrfCanc :cancel :==>");
e.printStackTrace();
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
finally
{
try
{
if( conn != null )
{
if( errorFound )
{
System.out.println("Rolling Back Changes......");
conn.rollback();
}
else
{
System.out.println("Commiting Changes......");
conn.commit();
System.out.println("Commiting Changes......11");
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("EmpLvePrkBalTrfCanc :cancel :==>\n" + e);
e.printStackTrace();
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
}
return retString;
}
public String actionHandler( String tranId, String xtraParams, String xmlString, Connection conn ) throws RemoteException,ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
ITMDBAccessLocal itmDBAccess = null;
String retString="";
String sql = "";
String status="";
String tranMode = "";
int updCnt = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
AppConnectParm appConnect = new AppConnectParm();
InitialContext ctx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" );
sql=" SELECT STATUS, TRAN_MODE FROM EMP_LVEPRKBAL_TRFHDR WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, tranId );
rs=pstmt.executeQuery();
if ( rs.next() )
{
status = checkNull( rs.getString( "STATUS" ) );
tranMode = checkNull( rs.getString( "TRAN_MODE" ) );
}
close( pstmt, rs );
if ( "R".equalsIgnoreCase( tranMode ) )
{
retString = itmDBAccess.getErrorString( "", "VTELPTRF12", userId );
}
else if ( "C".equalsIgnoreCase( status ) )
{
retString = itmDBAccess.getErrorString( "", "VTELPTRF13", userId );
}
else if( "X".equalsIgnoreCase( status ) )
{
retString = itmDBAccess.getErrorString( "", "VTELPTRF14", userId );
}
else
{
sql=" UPDATE EMP_LVEPRKBAL_TRFHDR SET STATUS = ?, STATUS_DATE = ? WHERE TRAN_ID= ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, "X" );
pstmt.setTimestamp( 2, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString( 3, tranId );
pstmt.executeUpdate();
updCnt = pstmt.executeUpdate();
if( updCnt > 0 )
{
conn.commit();
retString = itmDBAccess.getErrorString( "", "VTELPTRF15", userId );
}
close( pstmt, rs );
}
}
catch ( Exception e )
{
System.out.println("Exception Employeeaddresschange :confirm :==>");
try
{
conn.rollback();
}
catch (SQLException ex)
{
ex.printStackTrace();
retString = admCommon.getErrorMessage(ex, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
e.printStackTrace();
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, "");
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
finally
{
try
{
close( pstmt, rs );
}
catch (Exception e)
{
System.out.println("Inside Exception finally [EmpLvePrkBalTrfCanc]"+e.getMessage());
e.printStackTrace();
}
}
System.out.println(" retString.. [" + retString + "] ");
return retString;
}
private String checkNull(String input)//Method to check null string
{
if (input == null)
{
input = "";
}
else
{
input =input.trim();
}
return input;
}
/**
* This method close the PreparedStatement & ResultSet
*
* @param pstmt
* @param rs
*/
private void close( PreparedStatement pstmt, ResultSet rs )
{
try
{
if( rs != null)
{
rs.close();
rs = null;
}
if( pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}//eof class
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.*;
import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.*;
@javax.ejb.Local
public interface EmpLvePrkBalTrfCancLocal extends ActionHandlerLocal
{
public String actionHandler( String tranId, String xtraParams, String xmlString ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.*;
import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface EmpLvePrkBalTrfCancRemote extends ActionHandlerRemote
{
public String actionHandler( String tranId, String xtraParams, String xmlString ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
/**Author: Umakanta Das
* Desc:
*
*/
@Stateless
public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBalTrfConfRemote, EmpLvePrkBalTrfConfLocal {
/**
* @see ActionHandlerEJB#ActionHandlerEJB()
*/
AdmCommon admCommon = new AdmCommon();
public EmpLvePrkBalTrfConf()
{
super();
}
public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException, ITMException
{
Connection conn = null;
boolean errorFound = false;
String retStr = "";
try
{
conn = getConnection();
System.out.println("tranId:::::["+tranId+"] xtraParams::::: ["+xtraParams+"] forcedFlag::::: ["+forcedFlag+"]");
retStr = confirm( tranId, xtraParams, forcedFlag, conn);
System.out.println("Umakanta::retStr["+retStr+"]");
}
catch (Exception e)
{
errorFound = true;
System.out.println("in confirm ["+e.getMessage()+"]" );
e.printStackTrace();
}
finally
{
try
{
if( conn != null )
{
if( errorFound )
{
System.out.println("Rolling Back Changes......");
conn.rollback();
}
else
{
System.out.println("Commiting Changes......");
conn.commit();
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("EmpLvePrkBalTrfConf :confirm :==>\n" + e);
e.printStackTrace();
throw new ITMException(e);
}
}
return retStr;
}
/**
* This method handle the confirmation logic for
* leave confirmation.
*
* @param conn
* @param tranId
* @param prfmrCode
* @param rolecodeAprv
* @param prcID
* @param dom
* @return
* @throws RemoteException
* @throws SQLException
* @throws BaseException
*/
@SuppressWarnings({ "unused", "resource" })
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException
{
String retString = ""; String successString = "";
ResultSet rs = null; ResultSet rs1 = null;
PreparedStatement pStmt = null; PreparedStatement pStmt1 = null; PreparedStatement pStmt2 = null; PreparedStatement pStmt3 = null; PreparedStatement pStmt4 = null; PreparedStatement pStmt5 = null;
CallableStatement callStmt = null;
String sql = "";
Timestamp tranDate = null;
String tranType = "";
String tranMode = "";
String siteCodeFr = "";
String siteCodeTo = "";
String empCodeFr = "";
String empCodeTo = "";
String status = "";
java.sql.Date statusDate = null;
String empCodeConf = "";
String balCodeAson = "";
String balCode = "";
double lveBalance = 0.0D; double perkBalance = 0.0D;
Timestamp relieveDateTM = null; Timestamp joinDate = null;
String periodCode = "";
String chgUser = "";
String chgTerm = "";
String logEmpCode = "";
String keyString = "";
String refSer = "";
String grade = ""; String cadre = ""; String siteCode = ""; String workSite = ""; String paySite = "";
ITMDBAccessLocal itmDBAccess = null;
EmpLeaveConfLocal empLeaveConf = null;
E12GenericUtility genericUtility = new E12GenericUtility();
boolean successFlag = true;
StringBuffer xmlStringForID = null;
try
{
System.out.println("Inside confirm method of EmpLvePrkBalTrfConf");
AppConnectParm appConnect = new AppConnectParm();
InitialContext ctx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
empLeaveConf = (EmpLeaveConfLocal)ctx.lookup("ibase/EmpLeaveConf/local");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
java.util.Date currentDate = new java.util.Date();
String currDateStr = sdf.format(currentDate);
System.out.println("currDateStr::::::[" + currDateStr + "]");
Timestamp curDateTm = Timestamp.valueOf(genericUtility.getValidDateTimeString(currDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()));
System.out.println("curDateTm - [" + curDateTm + "]");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if ((chgUser == null) || (chgUser.trim().length() == 0))
{
chgUser = "SYSTEM";
}
if ((chgTerm == null) || (chgTerm.trim().length() == 0))
{
chgTerm = "SYSTEM";
}
String userId = "";
int count = 0; int updCnt = 0; int insrtStatus = 0; int selectCount = 0;
String admEnvReturn = ""; String admParameter = "";
Timestamp frDate = null; Timestamp toDate = null; Timestamp expDate = null;
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
sql = " SELECT LEAV.TRAN_DATE, LEAV.TRAN_TYPE, LEAV.TRAN_MODE, LEAV.SITE_CODE__FR , LEAV.SITE_CODE__TO, LEAV.EMP_CODE__FR, LEAV.EMP_CODE__TO, LEAV.STATUS, LEAV.STATUS_DATE, LEAV.EMP_CODE__CONF, LEAV.BALANCE_ASON, EMP.RELIEVE_DATE, EMP.PERIOD_CODE, EMP.RELIEVE_DATE, EMP.DATE_JOIN FROM EMP_LVEPRKBAL_TRFHDR LEAV INNER JOIN EMPLOYEE EMP ON LEAV.EMP_CODE__FR = EMP.EMP_CODE WHERE LEAV.TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next())
{
tranDate = rs.getTimestamp("TRAN_DATE");
tranType = checkNull(rs.getString("TRAN_TYPE"));
tranMode = checkNull(rs.getString("TRAN_MODE"));
siteCodeFr = checkNull(rs.getString("SITE_CODE__FR"));
siteCodeTo = checkNull(rs.getString("SITE_CODE__TO"));
empCodeFr = checkNull(rs.getString("EMP_CODE__FR"));
empCodeTo = checkNull(rs.getString("EMP_CODE__TO"));
status = checkNull(rs.getString("STATUS"));
statusDate = rs.getDate("STATUS_DATE");
empCodeConf = checkNull(rs.getString("EMP_CODE__CONF"));
balCodeAson = checkNull(rs.getString("BALANCE_ASON"));
relieveDateTM = rs.getTimestamp("RELIEVE_DATE");
joinDate = rs.getTimestamp("DATE_JOIN");
periodCode = checkNull(rs.getString("PERIOD_CODE"));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
String releiveDateStr = genericUtility.getValidDateTimeString(relieveDateTM.toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
System.out.println("releiveDateStr:::::[" + releiveDateStr + "]");
if ("X".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF16", userId, "", conn);
successFlag = false;
return retString;
}
if ("C".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF17", userId, "", conn);
successFlag = false;
return retString;
}
sql = " SELECT COUNT(*) AS ROW_CNT FROM EMP_LVEPRKBAL_TRFDET WHERE TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next())
{
count = rs.getInt("ROW_CNT");
}
System.out.println("count:::: [" + count + "]");
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
if (count <= 0)
{
retString = itmDBAccess.getErrorString("", "VTELPTRF18", userId, "", conn);
successFlag = false;
return retString;
}
sql = "SELECT GRADE, CADRE, EMP_SITE, WORK_SITE, PAY_SITE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, empCodeTo);
rs = pStmt.executeQuery();
if (rs.next())
{
grade = checkNull(rs.getString("GRADE"));
cadre = checkNull(rs.getString("CADRE"));
siteCode = checkNull(rs.getString("EMP_SITE"));
workSite = checkNull(rs.getString("WORK_SITE"));
paySite = checkNull(rs.getString("PAY_SITE"));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
admParameter = "TRF" + tranType.trim() + "_BLUPD_PROC";
admEnvReturn = this.admCommon.getAdmEnv(siteCode, cadre, grade, admParameter, curDateTm, conn);
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
admEnvReturn = this.admCommon.getEnv("999999", admParameter, conn);
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
admEnvReturn = "";
}
}
System.out.println("admEnvReturn:::::[" + admEnvReturn + "]");
if ("LVE".equalsIgnoreCase(tranType))
{
sql = " select key_string as keystr, ref_ser as refser from transetup where upper(tran_window) = 'W_EMPLEAVE' ";
}
else
{
sql = " select key_string as keystr, ref_ser as refser from transetup where upper(tran_window) = 'T_EMP_ADLAPSE'";
}
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery();
if (rs.next())
{
keyString = checkNull(rs.getString("keystr"));
refSer = checkNull(rs.getString("refSer"));
}
else
{
successFlag = false;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
System.out.println("keyString[" + keyString + "]============= refSer[" + refSer + "]");
if (!successFlag)
{
retString = itmDBAccess.getErrorString("", "VTSEQ", userId, "", conn);
return retString;
}
logEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("Umakanta::loginCode[" + logEmpCode + "]");
if ("LVE".equalsIgnoreCase(tranType))
{
sql = " select sum(bal_days) as baldays from leavebal where emp_code = ? and lve_code = ? and EFF_DATE = ? and UPTO_DATE = ? and EXP_DATE >= ?";
pStmt1 = conn.prepareStatement(sql);
sql = "INSERT INTO EMPLEAVE ( EMP_CODE, LVE_DATE_FR, LVE_DATE_TO, LVE_CODE, USE_FLAG, ENCH_AMT, NO_DAYS, STATUS_DATE, PRD_CODE, CHG_DATE, CHG_USER, CHG_TERM, APPL_DATE, TRAN_ID, LEAVE_STARTS, LEAVE_ENDS ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ";
pStmt2 = conn.prepareStatement(sql);
sql = "SELECT count(*) as COUNT FROM EMPLEAVE WHERE TRAN_ID = ?";
pStmt3 = conn.prepareStatement(sql);
sql = " SELECT BALANCE_CODE, FROM_DATE, TO_DATE, SUM(BALANCE) AS BALANCE FROM EMP_LVEPRKBAL_TRFDET WHERE TRAN_ID = ? GROUP BY BALANCE_CODE, FROM_DATE, TO_DATE ORDER BY BALANCE_CODE, FROM_DATE, TO_DATE ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
while (rs.next())
{
balCode = checkNull(rs.getString("BALANCE_CODE"));
lveBalance = rs.getDouble("BALANCE");
frDate = rs.getTimestamp("FROM_DATE");
toDate = rs.getTimestamp("TO_DATE");
double balDays = 0.0D;
pStmt1.setString(1, empCodeFr);
pStmt1.setString(2, balCode);
pStmt1.setTimestamp(3, frDate);
pStmt1.setTimestamp(4, toDate);
pStmt1.setTimestamp(5, relieveDateTM);
rs1 = pStmt1.executeQuery();
if (rs1.next())
{
balDays = rs1.getDouble("baldays");
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
pStmt1.clearParameters();
if (lveBalance > balDays)
{
retString = itmDBAccess.getErrorString("", "VTELPTRF20", userId, "", conn);
successFlag = false;
break;
}
xmlStringForID = new StringBuffer();
xmlStringForID.append("<Root><Detail1><appl_date>" + curDateTm + "</appl_date><lve_code>" + balCode + "</lve_code>" +
"<lve_date_fr>" + releiveDateStr + "</lve_date_fr>" +
"<work_site>" + workSite + "</work_site>" + "</Detail1></Root>");
System.out.println("xmlStringForID::::[" + xmlStringForID + "]");
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM", CommonConstants.DB_NAME);
String tranIdGen = tg.generateTranSeqID(refSer, "", keyString, conn);
System.out.println("Umakanta::uniqueKey[" + tranIdGen + "]");
pStmt2.setString(1, empCodeFr);
pStmt2.setTimestamp(2, relieveDateTM);
pStmt2.setTimestamp(3, relieveDateTM);
pStmt2.setString(4, balCode);
pStmt2.setString(5, "A");
pStmt2.setInt(6, 0);
pStmt2.setDouble(7, lveBalance);
pStmt2.setTimestamp(8, relieveDateTM);
pStmt2.setString(9, periodCode);
pStmt2.setTimestamp(10, new Timestamp(System.currentTimeMillis()));
pStmt2.setString(11, chgUser);
pStmt2.setString(12, chgTerm);
pStmt2.setTimestamp(13, curDateTm);
pStmt2.setString(14, tranIdGen);
pStmt2.setString(15, "B");
pStmt2.setString(16, "E");
insrtStatus = pStmt2.executeUpdate();
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt2.clearParameters();
if (insrtStatus > 0)
{
pStmt3.setString(1, tranIdGen);
rs1 = pStmt3.executeQuery();
if (rs1.next())
{
selectCount = rs1.getInt("COUNT");
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
System.out.println("empLeave.table::selectCount[" + selectCount + "]");
System.out.println("empLeave.table::tranIdGen[" + tranIdGen + "]");
System.out.println("empLeave.table::xtraParams[" + xtraParams + "]");
String confirmStatus = empLeaveConf.confirm(tranIdGen, xtraParams, "Y", conn);
System.out.println("empLeaveConf.confirm::confirmStatus[" + confirmStatus + "]");
if (selectCount > 0)
{
successFlag = true;
successString = confirmStatus;
}
else
{
retString = confirmStatus;
successFlag = false;
break;
}
}
else
{
successFlag = false;
break;
}
}
if (pStmt1 != null)
{
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
pStmt3.close();
pStmt3 = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
if ((retString != null) && (retString.trim().length() > 0))
{
System.out.println("retString:::::[ " + retString + " ] ");
successFlag = false;
return retString;
}
if (successFlag)
{
if ((admEnvReturn != null) && (admEnvReturn.trim().length() > 0) && (!admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
try
{
String procSql = "{call " + admEnvReturn + "(?,?,?,?,?)}";
callStmt = conn.prepareCall(procSql);
callStmt.setString(1, tranId);
callStmt.setString(2, chgUser);
callStmt.setString(3, empCodeTo);
callStmt.setString(4, chgTerm);
callStmt.registerOutParameter(5, 12);
callStmt.executeQuery();
String outParam = callStmt.getString(5);
if (callStmt != null)
{
callStmt.close();
callStmt = null;
}
if ((outParam != null) && (outParam.trim().length() > 0))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF53", userId, "", conn);
successFlag = false;
}
successFlag = true;
}
catch (SQLException se)
{
se.printStackTrace();
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
successFlag = false;
return retString;
}
}
else
{
retString = itmDBAccess.getErrorString("", "VTELPTRF52", userId, "", conn);
successFlag = false;
return retString;
}
}
}
else if ("PRK".equalsIgnoreCase(tranType))
{
if (empCodeTo.length() <= 0)
{
retString = itmDBAccess.getErrorString("", "VTELPTRF19", userId, "", conn);
successFlag = false;
return retString;
}
sql = "insert into emp_adclaimhdr (tran_id, tran_date, emp_code, claim_amt, loan_adjamt, payroll_voucher, prd_code__payroll, chg_date, chg_user, chg_term, ad_code ,confirmed) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pStmt1 = conn.prepareStatement(sql);
sql = "insert into emp_adclaim (tran_id, tran_date , payroll_voucher, emp_code, ad_code, eff_date, bal_amt, claim_amt,chg_date, chg_user, chg_term ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
pStmt2 = conn.prepareStatement(sql);
sql = " SELECT COUNT(*) AS COUNT FROM ALLOWDEDN_BAL WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
pStmt3 = conn.prepareStatement(sql);
sql = "UPDATE ALLOWDEDN_BAL set AMOUNT = AMOUNT + ?, AMT_BAL = AMT_BAL + ? WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
pStmt4 = conn.prepareStatement(sql);
sql = "Insert into ALLOWDEDN_BAL (EMP_CODE,AD_CODE,START_DATE,END_DATE,AMOUNT,AMT_ADJ,AMT_BAL,EXP_DATE,REF_TYPE,REF_NO,CHG_DATE,CHG_USER,CHG_TERM) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pStmt5 = conn.prepareStatement(sql);
String procSql = "{call " + admEnvReturn + "(?,?,?,?,?)}";
callStmt = conn.prepareCall(procSql);
sql = " SELECT ACCT_PRD, BALANCE_CODE , ENCASHABLE, LVE_UNIT, FROM_DATE, TO_DATE, EXP_DATE, BALANCE FROM EMP_LVEPRKBAL_TRFDET WHERE TRAN_ID = ? GROUP BY ACCT_PRD, BALANCE_CODE, ENCASHABLE, LVE_UNIT, FROM_DATE, to_date, exp_date, BALANCE ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
int ctr = 0;
while (rs.next())
{
balCode = checkNull(rs.getString("BALANCE_CODE"));
frDate = rs.getTimestamp("FROM_DATE");
toDate = rs.getTimestamp("TO_DATE");
expDate = rs.getTimestamp("EXP_DATE");
perkBalance = rs.getDouble("BALANCE");
xmlStringForID = new StringBuffer();
xmlStringForID.append("<Root><Detail1><pay_site>" +
paySite + "</pay_site><site_code>" + siteCode + "</site_code><ad_code>" + balCode + "</ad_code>" +
"<tran_date>" + currDateStr + "</tran_date>" +
"</Detail1></Root>");
System.out.println("xmlStringForID::::[" + xmlStringForID + "]");
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM", CommonConstants.DB_NAME);
String tranIdGen = tg.generateTranSeqID(refSer, "", keyString, conn);
System.out.println("Umakanta::uniqueKey[" + tranIdGen + "]");
pStmt1.setString(1, tranIdGen);
pStmt1.setTimestamp(2, curDateTm);
pStmt1.setString(3, empCodeFr);
pStmt1.setDouble(4, perkBalance);
pStmt1.setInt(5, 0);
pStmt1.setString(6, "L");
pStmt1.setString(7, "");
pStmt1.setTimestamp(8, new Timestamp(System.currentTimeMillis()));
pStmt1.setString(9, chgUser);
pStmt1.setString(10, chgTerm);
pStmt1.setString(11, balCode);
pStmt1.setString(12, "Y");
insrtStatus = pStmt1.executeUpdate();
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt1.clearParameters();
if (insrtStatus > 0)
{
successFlag = true;
}
else
{
successFlag = false;
break;
}
pStmt2.setString(1, tranIdGen);
pStmt2.setTimestamp(2, curDateTm);
pStmt2.setString(3, "L");
pStmt2.setString(4, empCodeFr);
pStmt2.setString(5, balCode);
pStmt2.setTimestamp(6, frDate);
pStmt2.setDouble(7, perkBalance);
pStmt2.setDouble(8, perkBalance);
pStmt2.setTimestamp(9, new Timestamp(System.currentTimeMillis()));
pStmt2.setString(10, chgUser);
pStmt2.setString(11, chgTerm);
insrtStatus = pStmt2.executeUpdate();
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt2.clearParameters();
if (insrtStatus > 0)
{
successFlag = true;
}
else
{
successFlag = false;
break;
}
System.out.println("*************admEnvReturn:::::[" + admEnvReturn + "]");
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
pStmt3.setString(1, empCodeTo);
pStmt3.setString(2, balCode);
pStmt3.setTimestamp(3, frDate);
pStmt3.setTimestamp(4, toDate);
rs1 = pStmt3.executeQuery();
if (rs1.next())
{
insrtStatus = rs1.getInt("COUNT");
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
pStmt3.clearParameters();
if (insrtStatus > 0)
{
pStmt4.setDouble(1, perkBalance);
pStmt4.setDouble(2, perkBalance);
pStmt4.setString(3, empCodeTo);
pStmt4.setString(4, balCode);
pStmt4.setTimestamp(5, frDate);
pStmt4.setTimestamp(6, toDate);
updCnt = pStmt4.executeUpdate();
pStmt4.clearParameters();
if (updCnt > 0)
{
successFlag = true;
}
else
{
successFlag = false;
break;
}
}
else
{
pStmt5.setString(1, empCodeTo);
pStmt5.setString(2, balCode);
pStmt5.setTimestamp(3, frDate);
pStmt5.setTimestamp(4, toDate);
pStmt5.setDouble(5, perkBalance);
pStmt5.setInt(6, 0);
pStmt5.setDouble(7, perkBalance);
pStmt5.setTimestamp(8, relieveDateTM);
pStmt5.setString(9, "K");
pStmt5.setString(10, null);
pStmt5.setTimestamp(11, new Timestamp(System.currentTimeMillis()));
pStmt5.setString(12, chgUser);
pStmt5.setString(13, chgTerm);
updCnt = pStmt5.executeUpdate();
System.out.println("insert executed = [" + updCnt + "]");
pStmt5.clearParameters();
if (updCnt > 0)
{
successFlag = true;
}
else
{
successFlag = false;
break;
}
}
}
else
{
try
{
callStmt.setString(1, tranId);
callStmt.setString(2, chgUser);
callStmt.setString(3, empCodeTo);
callStmt.setString(4, chgTerm);
callStmt.registerOutParameter(5, 12);
callStmt.executeQuery();
String outParam = callStmt.getString(5);
if (callStmt != null)
{
callStmt.close();
callStmt = null;
}
if ((outParam != null) && (outParam.trim().length() > 0))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF53", userId, "", conn);
successFlag = false;
break;
}
successFlag = true;
}
catch (SQLException se)
{
se.printStackTrace();
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
successFlag = false;
}
}
}
if (pStmt1 != null)
{
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
pStmt3.close();
pStmt3 = null;
}
if (pStmt4 != null)
{
pStmt4.close();
pStmt4 = null;
}
if (pStmt5 != null)
{
pStmt5.close();
pStmt5 = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
if (callStmt != null)
{
callStmt.close();
callStmt = null;
}
}
if (successFlag)
{
sql = " UPDATE EMP_LVEPRKBAL_TRFHDR SET STATUS = ?, STATUS_DATE = ?, EMP_CODE__CONF = ? WHERE TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, "C");
pStmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
pStmt.setString(3, logEmpCode);
pStmt.setString(4, tranId);
updCnt = pStmt.executeUpdate();
if (updCnt > 0)
{
successString = itmDBAccess.getErrorString("", "VTSUCC1", userId, "", conn);
successFlag = true;
System.out.println("Umakanta::retString::Confirm[" + successString + "]");
return retString;
}
successFlag = false;
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
}
catch (SQLException se)
{
se.printStackTrace();
successFlag = false;
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
return retString;
}
catch (BaseException be)
{
successFlag = false;
retString = this.admCommon.getErrorMessage(be, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
return retString;
}
catch (Exception exp)
{
System.out.println("Umakanta::Exception[" + exp.getMessage() + "]");
successFlag = false;
retString = this.admCommon.getErrorMessage(exp, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
String str1 = retString;
return str1;
}
finally
{
try
{
if (successFlag)
{
conn.commit();
}
else
{
conn.rollback();
}
if (conn != null)
{
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (pStmt1 != null)
{
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
pStmt3.close();
pStmt3 = null;
}
if (pStmt4 != null)
{
pStmt4.close();
pStmt4 = null;
}
if (pStmt5 != null)
{
pStmt5.close();
pStmt5 = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return retString;
}
private InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("ITMException :[EmpLvePrkBalTrfConf] :getInitialContext :==>");
throw itme;
}
catch(Exception e)
{
System.out.println("Exception :[EmpLvePrkBalTrfConf] :getInitialContext :==>");
throw new ITMException(e);
}
return ctx;
}
/**
* This method checks null value
*
* @param input
* @return input
*/
@SuppressWarnings("unused")
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
/**
* This Method returns msgType
*
* @param conn
* @param errorCode
* @return msgType
* @throws ITMException
*/
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();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
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;
}
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface EmpLvePrkBalTrfConfLocal extends ActionHandlerLocal {
//public String confirm(String tranId, String prfmrCode, String roleCodeAprv, String prcID ,String xmlString) throws RemoteException,ITMException;
public String confirm( String tranId, String xmlString, String xtraParams ) throws ITMException ,RemoteException;
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface EmpLvePrkBalTrfConfRemote extends ActionHandlerRemote {
//public String confirm(String tranId, String prfmrCode, String roleCodeAprv, String prcID ,String xmlString) throws RemoteException,ITMException;
public String confirm( String tranId, String xmlString, String xtraParams ) throws ITMException , RemoteException;
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
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.text.SimpleDateFormat;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
/**
* PURPOSE : System should have populate system data and set in detail screen
* by clicking on default button
*
* @author Umakanta Das
*
*/
@Stateless
public class EmpLvePrkBalTrfDefault extends ActionHandlerEJB implements EmpLvePrkBalTrfDefaultLocal, EmpLvePrkBalTrfDefaultRemote
{
AdmCommon admCommon = new AdmCommon();
//public String actionHandler( String actoinType, String tranId, String xmlString, String xtraParams, String lineNo )throws RemoteException, ITMException
public String actionHandler(String actionType, String xmlString, String xmlString1,String objContext, String xtraParams)throws RemoteException, ITMException
{
Document dom = null, dom1 = null;
E12GenericUtility genericUtility = new E12GenericUtility();
String retString="";
NodeList parentNodeList = null;
int childNodeLength=0;
System.out.println("Action Handler Method called");
System.out.println("ActionType [" + actionType + "] \nxmlString [" + xmlString + "] \nxmlString1 [" + xmlString1 + "] \nobjContext [" + objContext + "] \n\n xtraParams [" + xtraParams + "]");
try
{
System.out.println( "CALLING ACTION METHOD" );
//dom = genericUtility.parseString( xmlString );
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println( "XML String :" + xmlString );
dom = genericUtility.parseString( xmlString );
}
if( xmlString1 != null && xmlString1.trim().length() !=0 )
{
System.out.println( "XML String1 :" + xmlString1 );
dom1 = genericUtility.parseString( xmlString1 );
}
/*parentNodeList = dom.getElementsByTagName( "Detail2" );
childNodeLength=parentNodeList.getLength();
System.out.println("childNodeLength--> ["+childNodeLength+"]");
if( childNodeLength <= 1 )
{
//retString = actionHandler( actionType, tranId, dom, xtraParams, lineNo );dom, dom1,objContext, xtraParams
}
else
{
retString="<Detail></Detail>";
}*/
if (actionType.equalsIgnoreCase( "Default" ))
{
retString = actionHandler(actionType, dom, dom1,objContext, xtraParams );
}
}
catch ( Exception ex )
{
ex.printStackTrace();
}
return retString;
}
//private String actionHandler( String actoinType, String tranId, Document dom, String xtraParams, String lineNo ) throws ITMException, RemoteException
public String actionHandler( String actoinType, Document dom, Document dom1, String objContext, String xtraParams ) throws ITMException, RemoteException
{
StringBuffer valueXmlBuff = new StringBuffer();
String sql = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
E12GenericUtility genericUtility = null;
ConnDriver connDriver = new ConnDriver();
String objName = "";
String empCodeFrom = "";
String tranType = "", tranId = "";
String adCode = "";
String balCodeDescr = "";
Date startDate = null;
Date endDate = null;
String lveCode = "";
Date effDate = null;
Date uptoDate = null;
Date expDate = null;
String acctPrd = "";
String lveUnit = "";
String encashable = "";
double balance = 0.0;
String retString = "";
int totalRowCnt = 0;
int deletedRowCnt = 0;
NodeList parentNodeListDet2 = null;
objName = checkNull( getObjName( dom ,"1" ) );
System.out.println("objName ..:: ["+objName+"]");
try
{
genericUtility = new E12GenericUtility();
SimpleDateFormat sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
System.out.println("Default :---->");
conn = getConnection();
conn.setAutoCommit(false);
connDriver = null;
empCodeFrom = checkNull( genericUtility.getColumnValue( "emp_code__fr", dom, "1" ) ) ;
tranType = checkNull( genericUtility.getColumnValue( "tran_type", dom, "1" ) ) ;
tranId = checkNull( genericUtility.getColumnValue( "tran_id", dom, "1" ) ) ;
valueXmlBuff.append("<?xml version=\"1.0\"?>\r\n");
valueXmlBuff.append("<Root>\r\n");
System.out.println("INSIDE TRY");
parentNodeListDet2 = dom1.getElementsByTagName("Detail2");
totalRowCnt = parentNodeListDet2.getLength();
if (totalRowCnt > 0)
{
deletedRowCnt = getDeletedRowCnt(dom1, "2");
totalRowCnt = totalRowCnt - deletedRowCnt;
}
System.out.println("[EmpLvePrkBalTrfDefault] detail2 length==================>"+totalRowCnt);
if(totalRowCnt > 1)
{
System.out.println("INSIDE totalRowCnt == 0");
valueXmlBuff.append("</Root>\r\n");
return valueXmlBuff.toString();
}
if(totalRowCnt == 0)
{
//valueXmlBuff.append("<line_no>").append("<![CDATA[").append( lineNo ).append("]]>").append("</line_no>\r\n");
if ( "PRK".equalsIgnoreCase( tranType ) )
{
sql = " SELECT AD_CODE, START_DATE, END_DATE, AMT_BAL, FN_GET_LVEPRK_DESCR( 'PRK' , AD_CODE ) AS BALANCE_CODE_DESCR FROM ALLOWDEDN_BAL WHERE EMP_CODE= ? AND REF_TYPE='K' AND AMT_BAL <> 0 ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, empCodeFrom);
rs = pstmt.executeQuery();
while ( rs.next() )
{
adCode = checkNull( rs.getString( "AD_CODE" ) );
startDate = rs.getDate( "START_DATE" );
endDate = rs.getDate( "END_DATE" );
balance = rs.getDouble( "AMT_BAL" );
balCodeDescr = checkNull( rs.getString( "BALANCE_CODE_DESCR" ) );
}
System.out.println("balCodeDescr [:" +balCodeDescr+ "] "+"adCode [:" +adCode+ "] "+
"startDate [:" +startDate+ "] "+"endDate [:" +endDate+ "] "+
"balance [:" +balance+ "] ");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
/*sql = " SELECT FN_GET_LVEPRK_DESCR( 'PRK' , ? ) AS BALANCE_CODE_DESCR FROM DUAL ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, adCode );
rs = pstmt.executeQuery();
if ( rs.next() )
{
balCodeDescr = checkNull( rs.getString( "BALANCE_CODE_DESCR" ) );
}
System.out.println("balCodeDescr [:" +balCodeDescr+ "]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}*/
valueXmlBuff.append("<Detail>\r\n >");
valueXmlBuff.append("<balance_code>").append("<![CDATA[").append( adCode ).append("]]>").append("</balance_code>\r\n");
valueXmlBuff.append("<balance_code_descr>").append("<![CDATA[").append( balCodeDescr ).append("]]>").append("</balance_code_descr>\r\n");
valueXmlBuff.append("<from_date>").append("<![CDATA[").append( ( startDate == null ? "" : sdf.format( startDate ) ) ).append("]]>").append("</from_date>\r\n");
valueXmlBuff.append("<to_date>").append("<![CDATA[").append( endDate == null ? "" : sdf.format( endDate ) ).append("]]>").append("</to_date>\r\n");
valueXmlBuff.append("<exp_date>").append("<![CDATA[").append( endDate == null ? "" : sdf.format( endDate ) ).append("]]>").append("</exp_date>\r\n");
valueXmlBuff.append("<balance>").append("<![CDATA[").append( balance ).append("]]>").append("</balance>\r\n");
valueXmlBuff.append("<acct_prd>").append("<![CDATA[").append( "NULL" ).append("]]>").append("</acct_prd>\r\n");
valueXmlBuff.append("<lve_unit>").append("<![CDATA[").append( "NULL" ).append("]]>").append("</lve_unit>\r\n");
valueXmlBuff.append("<encashable>").append("<![CDATA[").append( "NULL" ).append("]]>").append("</encashable>\r\n");
valueXmlBuff.append("</Detail>");
}
else if ( "LVE".equalsIgnoreCase( tranType ) )
{
sql = " SELECT LEAVEBAL.LVE_CODE, LEAVEBAL.EFF_DATE, LEAVEBAL.UPTO_DATE, LEAVEBAL.EXP_DATE, LEAVEBAL.ACCT_PRD, LEAVEBAL.LVE_UNIT, LEAVEBAL.ENCASHABLE, "
+" LEAVEBAL.BAL_DAYS,FN_GET_LVEPRK_DESCR( 'LVE' , LVE_CODE) AS BALANCE_CODE_DESCR FROM LEAVEBAL LEAVEBAL INNER JOIN EMPLOYEE EMPLOYEE ON LEAVEBAL.EMP_CODE = EMPLOYEE.EMP_CODE WHERE EMPLOYEE.EMP_CODE= ? "
+" AND LEAVEBAL.EXP_DATE > EMPLOYEE.RELIEVE_DATE ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empCodeFrom );
rs = pstmt.executeQuery();
while( rs.next() )
{
lveCode = checkNull( rs.getString( "LVE_CODE" ) );
effDate = rs.getDate( "EFF_DATE" );
uptoDate = rs.getDate( "UPTO_DATE" );
expDate = rs.getDate( "EXP_DATE" );
acctPrd = checkNull( rs.getString( "ACCT_PRD" ) );
lveUnit = checkNull( rs.getString( "LVE_UNIT" ) );
encashable = checkNull( rs.getString( "ENCASHABLE" ) );
balance = rs.getDouble( "BAL_DAYS" );
balCodeDescr = checkNull( rs.getString("BALANCE_CODE_DESCR") );
valueXmlBuff.append("<Detail>\r\n ");
valueXmlBuff.append("<balance_code>").append("<![CDATA[").append( lveCode ).append("]]>").append("</balance_code>\r\n");
valueXmlBuff.append("<balance_code_descr>").append("<![CDATA[").append( balCodeDescr ).append("]]>").append("</balance_code_descr>\r\n");
valueXmlBuff.append("<from_date>").append("<![CDATA[").append( effDate == null ? "" : sdf.format( effDate ) ).append("]]>").append("</from_date>\r\n");
valueXmlBuff.append("<to_date>").append("<![CDATA[").append( uptoDate == null ? "" : sdf.format( uptoDate ) ).append("]]>").append("</to_date>\r\n");
valueXmlBuff.append("<exp_date>").append("<![CDATA[").append( expDate == null ? "" : sdf.format( expDate ) ).append("]]>").append("</exp_date>\r\n");
valueXmlBuff.append("<balance>").append("<![CDATA[").append( balance ).append("]]>").append("</balance>\r\n");
valueXmlBuff.append("<acct_prd>").append("<![CDATA[").append( acctPrd ).append("]]>").append("</acct_prd>\r\n");
valueXmlBuff.append("<lve_unit>").append("<![CDATA[").append( lveUnit ).append("]]>").append("</lve_unit>\r\n");
valueXmlBuff.append("<encashable>").append("<![CDATA[").append( encashable ).append("]]>").append("</encashable>\r\n");
valueXmlBuff.append("</Detail>");
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
/*sql = " SELECT FN_GET_LVEPRK_DESCR( 'LVE' , ? ) AS BALANCE_CODE_DESCR FROM DUAL ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, lveCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
balCodeDescr = checkNull( rs.getString("BALANCE_CODE_DESCR") );
}
System.out.println("balCodeDescr: [" +balCodeDescr+ "]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}*/
}
else
{
valueXmlBuff.append("<Detail>\r\n ");
valueXmlBuff.append("<balance_code>").append("<![CDATA[").append( "" ).append("]]>").append("</balance_code>\r\n");
valueXmlBuff.append("<balance_code_descr>").append("<![CDATA[").append( "" ).append("]]>").append("</balance_code_descr>\r\n");
valueXmlBuff.append("<from_date>").append("<![CDATA[").append( "" ).append("]]>").append("</from_date>\r\n");
valueXmlBuff.append("<to_date>").append("<![CDATA[").append( "" ).append("]]>").append("</to_date>\r\n");
valueXmlBuff.append("<exp_date>").append("<![CDATA[").append( "" ).append("]]>").append("</exp_date>\r\n");
valueXmlBuff.append("<balance>").append("<![CDATA[").append( "" ).append("]]>").append("</balance>\r\n");
valueXmlBuff.append("<acct_prd>").append("<![CDATA[").append( "" ).append("]]>").append("</acct_prd>\r\n");
valueXmlBuff.append("<lve_unit>").append("<![CDATA[").append( "" ).append("]]>").append("</lve_unit>\r\n");
valueXmlBuff.append("<encashable>").append("<![CDATA[").append( "" ).append("]]>").append("</encashable>\r\n");
valueXmlBuff.append("</Detail>");
}
valueXmlBuff.append("</Root>\r\n");
}
}
catch ( SQLException e )
{
System.out.println("Exception : EmpLvePrkBalTrfDefault : Default [" + e.getMessage()+"]");
//throw new ITMException( e );
retString = admCommon.getErrorMessage(e, "");
retString = admCommon.getErrorXmlString(admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: "+retString);
return retString;
}
catch ( Exception ex )
{
ex.printStackTrace();
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch ( SQLException sqlE )
{
System.out.println("Exception in Finally ["+sqlE.getMessage()+"]");
sqlE.printStackTrace();
}
}
System.out.println("String Generated : [" +valueXmlBuff.toString()+"]");
//valueXmlBuff.append("</Root>\r\n");
return valueXmlBuff.toString();
}
/**
* This method returns object name
*
* @param dom
* @param objContext
* @return objName
*/
private String getObjName( Document dom, String objContext )
{
Node elementName = null;
NodeList elementList = null;
String objName = "";
elementList = dom.getElementsByTagName( "Detail"+objContext );
elementName = elementList.item( 0 );
if ( elementName!=null && ( "Detail"+objContext ).equalsIgnoreCase( elementName.getNodeName() ) )
{
NamedNodeMap etlAttributes = elementName.getAttributes();
if ( etlAttributes!=null )
{
if ( etlAttributes.getNamedItem( "objName" ) != null )
{
objName = etlAttributes.getNamedItem( "objName" ).getNodeValue();
}
}
}
return objName;
}
/**
* This method checks null value
*
* @param input
* @return input
*/
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
private int getDeletedRowCnt(Document dom,String currentForm)
{
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
int delRowCount = 0;
System.out.println("**** Inside the Method :::: getDeletedRowCount ****");
try
{
parentList = dom.getElementsByTagName("Detail"+currentForm);
int parentNodeListLength = parentList.getLength();
System.out.println("ParentNodeListLength ::>>"+parentNodeListLength);
for(int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++ )
{
parentNode = parentList.item(prntCtr);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute"))
{
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("[getPlaceOfWorkValueFromDom][updateFlag]" +updateFlag);
if (updateFlag.equalsIgnoreCase("D"))
{
delRowCount = delRowCount + 1;
System.out.println("*** delRowCount ===>>> ["+delRowCount+"]");
}
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println(" *** delRowCount being returned is ::::>>>> " + delRowCount+" *** ");
return delRowCount;
}
}
package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface EmpLvePrkBalTrfDefaultLocal extends ActionHandlerLocal
{
//public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException, ITMException;
public String actionHandler(String actoinType, Document dom, Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface EmpLvePrkBalTrfDefaultRemote extends ActionHandlerRemote
{
//public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException, ITMException;
public String actionHandler(String actoinType, Document dom, Document dom1, String objContext, 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