Commit 28f1ba5b authored by sanashaikh's avatar sanashaikh

Sana S:Added on 05/03/20

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@217523 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 488e8e98
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
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.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class PayStruChgReqTrnIC extends ValidatorEJB implements PayStruChgReqTrnICLocal ,PayStruChgReqTrnICRemote
{
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
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("PayStruChgReqIC xmlString in itemChanged 1..::["+xmlString+"]");
System.out.println("PayStruChgReqIC xmlString1 in itemChanged 2..:: ["+xmlString1+"]");
System.out.println("PayStruChgReqIC xmlString2 in itemChanged 3..:: ["+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 );
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :PayStruChgReqIC [:" + e.getMessage() + ":]" );
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
System.out.println("PayStruChgReqIC 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
{
int currentFormNo = 0;
String adAllocGroup = "";
String adAllocGroupDescr = "";
String tranCancelRemarks = "";
String objName = "";
String wfStatus = "O";
String hrAction = "";
String reqStatus = "U";
String statusDateStr = "";
String empCodeAprv = "";
String empCodeAuth1 = "";
String empCodeAuth2 = "";
String empCodeAuth3 = "";
String chgUser = "";
String chgTerm = "";
String empCode = "";
String adCode = "";
String descr = "";
String empFname = "";
String empMname ="";
String empLname = "";
String siteDescr="";
String designCode="";
String designation="";
String deptCode="";
String deptDescr="";
String errString="";
String paySite = "";
String sql = "";
String amount="";
String addDateStr="";
String chgDateStr="";
String tranDateStr="";
String curDate = "";
String empNameAprv = "";
String empName = "";
String empNameAuth1 = "";
String empNameAuth2 = "";
String empNameAuth3 = "";
String haTip = "";
StringBuffer valueXmlString = new StringBuffer();
SimpleDateFormat sdfAppl = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
System.out.println("ITEMCHANGED CALLING");
conn = getConnection();
sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
String loginEmpCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" ) );
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";
}
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("currentFormNo ..:: ["+currentFormNo+"]");
objName = checkNull( getObjNameFromDom(dom,"objName",1));
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n<Errors>\r\n</Errors>\r\n" );
Date currentDate = new Date();
curDate = currentDate == null ? "" : sdfAppl.format( currentDate );
System.out.println( "curDate::::::"+curDate );
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************");
switch ( currentFormNo )
{
case 1:
{
valueXmlString.append("<Detail1 domID='1' dbID='' objContext='1' objName='"+objName+"' selected='Y'>\r\n");
if( "itm_default".equalsIgnoreCase( currentColumn.trim() ) )
{
tranDateStr = curDate;
statusDateStr = "";
addDateStr = curDate;
chgDateStr = curDate;
empCode = loginEmpCode;
sql = "select case when a.emp_fname_long is null then a.emp_fname else a.emp_fname_long end as emp_fname,case when a.emp_mname_long is null then a.emp_mname else a.emp_mname_long end as emp_mname,case when a.emp_lname_long is null then a.emp_lname else a.emp_lname_long end as emp_lname,a.dept_code,a.design_code,a.designation,a.pay_site, b.descr as site_descr from employee a , site b where a.emp_code = ? and b.site_code = a.pay_site";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, empCode );
rs = pstmt.executeQuery();
if(rs.next())
{
empFname = checkNull( rs.getString("emp_fname") );
empMname = checkNull( rs.getString("emp_mname") );
empLname = checkNull( rs.getString("emp_lname") );
deptCode = checkNull( rs.getString("dept_code") );
designCode = checkNull( rs.getString("design_code") );
designation = checkNull( rs.getString("designation") );
paySite = checkNull( rs.getString("pay_site") );
siteDescr = checkNull(rs.getString("site_descr"));
empName = empFname.trim() + " " + empMname.trim() + " " + empLname.trim();
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
sql = "select descr as dept_descr from department where dept_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, deptCode );
rs = pstmt.executeQuery();
if(rs.next())
{
deptDescr = checkNull( rs.getString("dept_descr") );
System.out.println("deptDescr>>>"+deptDescr);
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
sql = "select case when a.emp_fname_long is null then a.emp_fname else a.emp_fname_long end as emp_fname,case when a.emp_mname_long is null then a.emp_mname else a.emp_mname_long end as emp_mname,case when a.emp_lname_long is null then a.emp_lname else a.emp_lname_long end as emp_lname from employee a where a.emp_code = ?";
pstmt = conn.prepareStatement(sql);
if (empCodeAprv != null && empCodeAprv.trim().length() > 0)
{
pstmt.setString( 1, empCodeAprv );
rs = pstmt.executeQuery();
if(rs.next())
{
empFname = checkNull( rs.getString("emp_fname") );
empMname = checkNull( rs.getString("emp_mname") );
empLname = checkNull( rs.getString("emp_lname") );
empNameAprv = empFname.trim() + " " + empMname.trim() + " " + empLname.trim();
}
rs.close();
}
pstmt.clearParameters();
if (empCodeAuth1 != null && empCodeAuth1.trim().length() > 0)
{
pstmt.setString( 1, empCodeAuth1 );
rs = pstmt.executeQuery();
if(rs.next())
{
empFname = checkNull( rs.getString("emp_fname") );
empMname = checkNull( rs.getString("emp_mname") );
empLname = checkNull( rs.getString("emp_lname") );
empNameAuth1 = empFname.trim() + " " + empMname.trim() + " " + empLname.trim();
}
rs.close();
}
pstmt.clearParameters();
if (empCodeAuth2 != null && empCodeAuth2.trim().length() > 0)
{
pstmt.setString( 1, empCodeAuth2 );
rs = pstmt.executeQuery();
if(rs.next())
{
empFname = checkNull( rs.getString("emp_fname") );
empMname = checkNull( rs.getString("emp_mname") );
empLname = checkNull( rs.getString("emp_lname") );
empNameAuth2 = empFname.trim() + " " + empMname.trim() + " " + empLname.trim();
}
rs.close();
}
pstmt.clearParameters();
if (empCodeAuth3 != null && empCodeAuth3.trim().length() > 0)
{
pstmt.setString( 1, empCodeAuth3 );
rs = pstmt.executeQuery();
if(rs.next())
{
empFname = checkNull( rs.getString("emp_fname") );
empMname = checkNull( rs.getString("emp_mname") );
empLname = checkNull( rs.getString("emp_lname") );
empNameAuth3 = empFname.trim() + " " + empMname.trim() + " " + empLname.trim();
}
rs.close();
}
pstmt.close();
haTip = "";
if (adAllocGroup != null && adAllocGroup.trim().length() > 0)
{
try
{
sql = "SELECT DDF_GET_HA_TIP(?,?) AS HA_TIP FROM DUAL";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empCode );
pstmt.setString( 2, adAllocGroup );
rs = pstmt.executeQuery();
if( rs.next() )
{
haTip = checkNull(rs.getString( "HA_TIP" ));
System.out.println("HA_TIP>>>>>>>>>>>"+haTip);
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e1)
{
haTip = "";
}
}
valueXmlString.append( "<tran_date><![CDATA[").append( tranDateStr ).append("]]></tran_date>");
valueXmlString.append( "<emp_code><![CDATA[").append( empCode ).append("]]></emp_code>");
valueXmlString.append( "<wf_status><![CDATA[").append( wfStatus ).append("]]></wf_status>" );
valueXmlString.append( "<req_status><![CDATA[").append( reqStatus ).append("]]></req_status>" );
valueXmlString.append( "<status_date><![CDATA[").append( statusDateStr ).append("]]></status_date>" );
valueXmlString.append( "<emp_code__aprv><![CDATA[").append( empCodeAprv ).append("]]></emp_code__aprv>" );
valueXmlString.append( "<emp_code__auth1><![CDATA[").append( empCodeAuth1 ).append("]]></emp_code__auth1>" );
valueXmlString.append( "<emp_code__auth2><![CDATA[").append( empCodeAuth2 ).append("]]></emp_code__auth2>" );
valueXmlString.append( "<emp_code__auth3><![CDATA[").append( empCodeAuth3 ).append("]]></emp_code__auth3>" );
valueXmlString.append( "<add_date><![CDATA[").append( addDateStr ).append( "]]></add_date>" );
valueXmlString.append( "<add_user><![CDATA[").append( chgUser ).append( "]]></add_user>" );
valueXmlString.append( "<add_term ><![CDATA[").append( chgTerm ).append( "]]></add_term>" );
valueXmlString.append( "<chg_date><![CDATA[").append( chgDateStr ).append( "]]></chg_date>" );
valueXmlString.append( "<chg_user><![CDATA[").append( chgUser ).append( "]]></chg_user>" );
valueXmlString.append( "<chg_term><![CDATA[").append( chgTerm ).append( "]]></chg_term>" );
valueXmlString.append( "<dept_code><![CDATA[").append( deptCode ).append("]]></dept_code>" );
valueXmlString.append( "<emp_name><![CDATA[").append( empName ).append("]]></emp_name>" );
valueXmlString.append( "<dept_descr><![CDATA[").append( deptDescr ).append("]]></dept_descr>" );
valueXmlString.append( "<emp_code__aprv__name><![CDATA[").append( empNameAprv ).append("]]></emp_code__aprv__name>" );
valueXmlString.append( "<emp_code__auth1__name><![CDATA[").append( empNameAuth1 ).append("]]></emp_code__auth1__name>" );
valueXmlString.append( "<emp_code__auth2__name><![CDATA[").append( empNameAuth2 ).append("]]></emp_code__auth2__name>" );
valueXmlString.append( "<emp_code__auth3__name><![CDATA[").append( empNameAuth3 ).append("]]></emp_code__auth3__name>" );
valueXmlString.append( "<ad_alloc_group><![CDATA[").append( adAllocGroup ).append("]]></ad_alloc_group>" );
valueXmlString.append( "<ad_alloc_group_descr><![CDATA[").append( adAllocGroupDescr ).append("]]></ad_alloc_group_descr>" );
valueXmlString.append( "<designation><![CDATA[").append( designation ).append("]]></designation>" );
valueXmlString.append( "<design_code><![CDATA[").append( designCode ).append("]]></design_code>" );
valueXmlString.append( "<pay_site><![CDATA[").append( paySite ).append("]]></pay_site>" );
valueXmlString.append( "<site_descr><![CDATA[").append( siteDescr ).append("]]></site_descr>" );
valueXmlString.append( "<ha_tip><![CDATA[").append( haTip ).append("]]></ha_tip>" );
}
else if ("ad_alloc_group".equalsIgnoreCase( currentColumn ) )
{
haTip = "";
descr = "";
adCode = checkNull( genericUtility.getColumnValue("ad_alloc_group",dom) ) ;
empCode = checkNull( genericUtility.getColumnValue("emp_code",dom) ) ;
System.out.println("adCode in header>>>"+adCode);
if(adCode != null && adCode.length() > 0)
{
sql = "select descr as ad_alloc_group_descr,DDF_GET_HA_TIP(?,?) AS HA_TIP from ALLWDEDN where AD_CODE= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, adCode );
pstmt.setString( 2, empCode );
pstmt.setString( 3, adCode );
rs = pstmt.executeQuery();
if(rs.next())
{
descr = checkNull( rs.getString("ad_alloc_group_descr") );
haTip = checkNull(rs.getString( "HA_TIP" ));
System.out.println("HA_TIP>>>>>>>>>>>"+haTip);
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("<ad_alloc_group><![CDATA[").append( adCode ).append("]]></ad_alloc_group>");
valueXmlString.append("<ad_alloc_group_descr><![CDATA[").append( descr ).append("]]></ad_alloc_group_descr>");
valueXmlString.append( "<ha_tip><![CDATA[").append( haTip ).append("]]></ha_tip>" );
}
else if (currentColumn.trim().equals("itm_defaultedit"))
{
if (objName != null && (objName.equalsIgnoreCase("pay_stru_chg_req_hr") || objName.equalsIgnoreCase("pay_stru_chg_req_hr_wiz")))
{
hrAction = checkNull( genericUtility.getColumnValue("hr_action",dom) ) ;
wfStatus = checkNull( genericUtility.getColumnValue("wf_status",dom) ) ;
tranCancelRemarks = checkNull( genericUtility.getColumnValue("cancel_remarks",dom) ) ;
if (!hrAction.trim().equalsIgnoreCase("P"))
{
valueXmlString.append("<hr_action protect ='1'><![CDATA[").append(hrAction).append("]]></hr_action>");
valueXmlString.append("<cancel_remarks protect ='1'><![CDATA[").append(tranCancelRemarks).append("]]></cancel_remarks>");
}
}
}
}
valueXmlString.append("</Detail1>\r\n");
break;
case 2 :
{
valueXmlString.append("<Detail2>\r\n");
System.out.println("*Before itm_default OF CASE 2:"+currentColumn);
if(currentColumn.trim().equals("itm_default"))
{
}
else if (currentColumn.trim().equals("itm_defaultedit"))
{
}
else if (currentColumn.trim().equals("amount"))
{
amount = checkNull(genericUtility.getColumnValue("amount", dom));
System.out.println("@S@ amount_decl str_amount>>"+amount);
if (amount.length() == 0) {
valueXmlString.append("<amount><![CDATA[0]]></amount>");
}
}
}
valueXmlString.append("</Detail2>\r\n");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println( "Exception :PayStruChgReqIC [itemChanged(String xmlString)] : ==>\n"+e.getMessage());
System.out.println("errString after getErrorXmlString: "+errString);
valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) );
throw new ITMException(e);
}
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("[PayStruChgReqIC][itemChanged]Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
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 );
System.out.println("errString in val data>>>"+errString);
}
catch(Exception e)
{
System.out.println("Exception : [PayStruChgReqIC][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
errString = genericUtility.createErrorString(e);
throw new ITMException(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");
int currentFormNo = 0;
int childNodeListLength = 0;
int ctr = 0;
int count = 0;
String errString = "";
String childNodeName = "";
String sql = "";
String userId = "" ;
String adCode = "";
String retString = "";
String empCode = "";
Node parentNode = null;
Node childNode = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccess = null;
try
{
conn = getConnection();
itmDBAccess = new ITMDBAccessEJB();
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" ) );
System.out.println("loginCode::::::["+loginCode+"]");
System.out.println("loginSiteCode::::::["+loginSiteCode+"]");
switch( currentFormNo )
{
case 1:
{
parentNodeList = dom.getElementsByTagName( "Detail"+currentFormNo );
parentNode = parentNodeList.item( 0 );
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.print("childNodeListLength["+childNodeListLength+"]");
for( ctr = 0; ctr < childNodeListLength; ctr++ )
{
childNode = childNodeList.item( ctr );
childNodeName = childNode.getNodeName();
System.out.println("childNodeName["+childNodeName+"]");
if( "ad_alloc_group".equalsIgnoreCase( childNodeName ) )
{
count = 0;
adCode = checkNull( genericUtility.getColumnValue( "ad_alloc_group", dom) );
empCode = checkNull( genericUtility.getColumnValue( "emp_code", dom) ); // 28/02/2020
System.out.println("adCode got in the validation ..::["+adCode+"]");
if( adCode == null || adCode.trim().length() == 0 )
{
System.out.println("Invalid adCode ::::");
retString = itmDBAccess.getErrorString( "", "VTPAYALC01", userId, "", conn );
return retString;
}
else
{
sql = " SELECT COUNT (1) FROM ALLWDEDN WHERE AD_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, adCode );
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( "", "VTPAYALC02", userId, "", conn );
return retString;
}
String tranId = checkNull( genericUtility.getColumnValue( "tran_id", dom) );
if (tranId == null || tranId.trim().length() == 0)
{
tranId = "*";
}
count = 0;
sql = " SELECT COUNT (1) AS CNT FROM PAY_STRU_CHG_REQ_HDR WHERE TRAN_ID <> ? AND EMP_CODE = ? AND AD_ALLOC_GROUP = ? AND REQ_STATUS NOT IN ('A','C') ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, tranId );
pstmt.setString( 2, empCode );
pstmt.setString( 3, adCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt( "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( "", "VTPAYALC15", userId, "", conn );
return retString;
}
}
}
else if( "hr_action".equalsIgnoreCase( childNodeName ) )
{
String hrAction = checkNull( genericUtility.getColumnValue( "hr_action", dom) );
String cancelRemarks = checkNull( genericUtility.getColumnValue( "cancel_remarks", dom) );
if (hrAction.equalsIgnoreCase("R") && (cancelRemarks == null || cancelRemarks.trim().length() == 0))
{
retString = itmDBAccess.getErrorString( "", "VTPAYALC21", userId, "", conn );
return retString;
}
}
}
}
break;
case 2 :
{
String amountType="";
double totalAmt=0d, totalAmtOrg=0d, amount = 0d;
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("amount_type"))
{
amountType = checkNull( genericUtility.getColumnValue("amount_type",dom )) ;
}
else if(childNodeName.equalsIgnoreCase("amount"))
{
String amountStr = checkNull( genericUtility.getColumnValue("amount",dom )) ;
amountType = checkNull( genericUtility.getColumnValue("amount_type",dom )) ;
amount = 0d;
try
{
amount = Double.parseDouble(amountStr);
}
catch(Exception e1)
{
System.out.println( "Exception : [PayStruChgReqIC][wfValData(String xmlString)] : ==>\n"+e1.getMessage());
e1.printStackTrace();
System.out.println("Exception in parsing the amount");
retString = itmDBAccess.getErrorString( "", "VTPAYALC03", userId, "", conn );
return retString;
}
if(amount < 0.00 )
{
System.out.println("amount1 --["+amount+"]");
retString = itmDBAccess.getErrorString( "", "VTPAYALC03", userId, "", conn );
return retString;
}
else if (amount > 0)
{
double k = amount % 1;
if (k > 0d)
{
retString = itmDBAccess.getErrorString( "", "VTPAYALC22", userId, "", conn );
return retString;
}
}
String amountOrgStr = checkNull( genericUtility.getColumnValue("amount_orig",dom )) ;
double amountOrg = 0d;
if (amountOrgStr != null && amountOrgStr.trim().length() > 0)
{
try
{
amountOrg = Double.parseDouble(amountOrgStr);
}
catch(Exception e1)
{
amountOrg = 0d;
}
}
if (amountOrg == amount)
{
retString = itmDBAccess.getErrorString( "", "VTPAYALC23", userId, "", conn );
return retString;
}
String empCode1 = checkNull(genericUtility.getColumnValue("emp_code",dom1 ));
String parValue = "";
sql = " SELECT DDF_HR_SITE_ENV_VALUE(?,FN_SYSDATE(),'HEAD_ALLOC_AMT_RANGE') as par_value from dual";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, empCode1 );
rs = pstmt.executeQuery();
if( rs.next() )
{
parValue = checkNull(rs.getString( "par_value" ));
System.out.println("parValue>>>>>>>>>>>"+parValue);
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
String paramArr[] = parValue.split(":");
double parValFrom = 0d;
double parValTo = 99d;
try
{
parValFrom = Double.parseDouble(paramArr[0]);
parValTo = Double.parseDouble(paramArr[1]);
}
catch(Exception e)
{
parValFrom = 0d;
parValTo = 99d;
}
if ((amount < parValFrom) || (amount > parValTo))
{
retString = itmDBAccess.getErrorString( "", "VTPAYALC24", userId, "", conn );
return retString;
}
if(amountType.equals("Fixed"))
{
totalAmt=totalAmt+amount;
System.out.println("totalamt---["+totalAmt+"]");
System.out.println("amount---["+amount+"]");
}
}
else if(childNodeName.equalsIgnoreCase("amount_orig"))
{
if(amountType.equals("Fixed"))
{
String amountOrg = checkNull( genericUtility.getColumnValue("amount_orig",dom )) ;
amount = 0d;
if (amountOrg != null && amountOrg.trim().length() > 0)
{
try
{
amount = Double.parseDouble(amountOrg);
}
catch(Exception e1)
{
amount = 0d;
}
totalAmtOrg=totalAmtOrg+amount;
System.out.println("totalamt---["+totalAmtOrg+"]");
System.out.println("amount---["+amountOrg+"]");
}
}
}
}
/*
if(totalAmtOrg != totalAmt)
{
System.out.println("::: total amount not equal for fixed type :::");
errString = checkNull(itmDBAccess.getErrorString("", "VTPAYALC11",userId, "", conn));
}
*/
break;
}
}
}
catch(Exception e)
{
System.out.println( "Exception : [PayStruChgReqIC][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
System.out.println("errString after getErrorXmlString: "+errString);
throw new ITMException(e);
}
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 : [PayStruChgReqIC][wfValData] : ==>\n"+e1.getMessage());
System.out.println("errString after getErrorXmlString: "+errString);
throw new ITMException(e1);
}
}
return errString;
}
private String checkNull( String input )
{
if ( input == null || "null".equalsIgnoreCase(input) )
{
input= "";
}
return input.trim();
}
private String getObjNameFromDom( Document dom, String attribute , int currFormNo) throws ITMException
{
String objName = "";
try
{
NodeList detailList = null;
Node currDetail = null;
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail" + currFormNo);
detailListLength = detailList.getLength();
for (int ctr = 0; ctr < detailListLength; ctr++)
{
currDetail = detailList.item(ctr);
objName = currDetail.getAttributes().getNamedItem(attribute).getNodeValue();
System.out.println("objNameobjName>>>::asjhdg::["+objName+"]");
break;
}
if(objName == null || objName.trim().length() == 0)
{
NodeList objNameList = dom.getElementsByTagName("objName");
if(objNameList != null && objNameList.getLength() > 0)
{
Node objNameNode = objNameList.item(0);
if(objNameNode != null && objNameNode.getFirstChild() != null)
{
objName = checkNull(objNameNode.getFirstChild().getNodeValue());
System.out.println("objNameobjName>>> in anothere if null ::asjhdg::["+objName+"]");
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return objName;
}
}
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