Commit 0d215f38 authored by sanashaikh's avatar sanashaikh

Sana S: Added on 17/02/20

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@216736 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e85a93de
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 PayStruChgReqIC extends ValidatorEJB implements PayStruChgReqICLocal ,PayStruChgReqICRemote
{
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
{
System.out.println("ITEMCHANGED CALLING");
int currentFormNo = 0;
String sql = "",sql1 = "",amount="";
Connection conn = null;
PreparedStatement pstmt = null,pstmt1=null;
ResultSet rs = null,rs1 = null;
String empCode = "";
String adCode = "";
String descr = "";
String empFname = "";
String empMname ="";
String empLname = "";
String chgUser = "",loginSite="",siteDescr="",designCode="",designation="";
String chgTerm = "",deptCode="",deptDescr="",errString="";
int domID=0,ctr = 0;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
E12GenericUtility genericUtility = new E12GenericUtility();
if ( chgUser == null || chgUser.trim().length() == 0 )
{
chgUser = "SYSTEM";
}
if ( chgTerm == null || chgTerm.trim().length() == 0 )
{
chgTerm = "SYSTEM";
}
StringBuffer valueXmlString = new StringBuffer();
try
{
conn = getConnection();
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("currentFormNo ..:: ["+currentFormNo+"]");
String loginEmpCode = checkNull( genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" ) );
chgUser = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "termId" );
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
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" );
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:
{
domID++;
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr);
valueXmlString.append("<Detail1 domID='" + domID + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\" pkNames=\" \" />\r\n");
//valueXmlString.append("<attribute selected='Y' updateFlag='A' status='N' pkNames='' />");
empCode=loginEmpCode;
if( "itm_default".equalsIgnoreCase( currentColumn.trim() ) )
{
sql = "select emp_fname,emp_mname,emp_lname,dept_code,design_code,designation from employee where emp_code = ? ";
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") );
}
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 DESCR from SITE where SITE_CODE= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = checkNull(rs.getString("DESCR"));
}
String empName=empFname+" "+empMname+" "+empLname;
valueXmlString.append( "<tran_id><![CDATA[").append( "" ).append("]]></tran_id>");
valueXmlString.append( "<selectbox><![CDATA[").append( "true" ).append("]]></selectbox>");
valueXmlString.append( "<emp_code><![CDATA[").append( empCode ).append("]]></emp_code>");
valueXmlString.append( "<emp_name><![CDATA[").append( empName ).append("]]></emp_name>" );
// valueXmlString.append( "<emp_mname><![CDATA[").append( empMname ).append("]]></emp_mname>" );
// valueXmlString.append( "<emp_lname><![CDATA[").append( empLname ).append("]]></emp_lname>" );
valueXmlString.append( "<dept_code><![CDATA[").append( deptCode ).append("]]></dept_code>" );
valueXmlString.append( "<dept_descr><![CDATA[").append( deptDescr ).append("]]></dept_descr>" );
valueXmlString.append( "<design_code><![CDATA[").append( designCode ).append("]]></design_code>" );
valueXmlString.append( "<designation><![CDATA[").append( designation ).append("]]></designation>" );
valueXmlString.append( "<site_descr><![CDATA[").append( siteDescr ).append("]]></site_descr>" );
valueXmlString.append( "<status_date><![CDATA[").append( "" ).append("]]></status_date>" );
valueXmlString.append( "<tran_date><![CDATA[").append( curDate ).append("]]></tran_date>" );
valueXmlString.append( "<add_user ><![CDATA[").append( chgUser ).append( "]]></add_user>" );
valueXmlString.append( "<add_term ><![CDATA[").append( chgTerm ).append( "]]></add_term>" );
valueXmlString.append( "<add_date ><![CDATA[").append( curDate ).append( "]]></add_date>" );
valueXmlString.append( "<chg_date ><![CDATA[").append( curDate ).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( "<req_status><![CDATA[").append( "U" ).append("]]></req_status>" );
valueXmlString.append( "<wf_status><![CDATA[").append( "O" ).append("]]></wf_status>" );
}
else if ("ad_alloc_group".equalsIgnoreCase( currentColumn ) )
{
adCode = checkNull( genericUtility.getColumnValue("ad_alloc_group",dom) ) ;
System.out.println("adCode in header>>>"+adCode);
if(adCode != null && adCode.length() > 0)
{
sql = "select descr as ad_alloc_group_descr from ALLWDEDN where AD_CODE= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, adCode );
rs = pstmt.executeQuery();
if(rs.next())
{
descr = checkNull( rs.getString("ad_alloc_group_descr") );
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<ad_alloc_group_descr><![CDATA[").append( descr ).append("]]></ad_alloc_group_descr>");
}
else
{
valueXmlString.append("<ad_alloc_group><![CDATA[").append( "" ).append("]]></ad_alloc_group>");
valueXmlString.append("<ad_alloc_group_descr><![CDATA[").append( "" ).append("]]></ad_alloc_group_descr>");
}
}
}
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"))
{
adCode = checkNull(genericUtility.getColumnValue("ad_alloc_group",dom1) ) ;
empCode = checkNull( genericUtility.getColumnValue("emp_code",dom1) ) ;
System.out.println("ADCode>>>"+adCode);
System.out.println("empCode>>>"+empCode);
errString = defaultData(dom, dom1,objContext, xtraParams,conn,empCode,adCode);
System.out.println("errString for default>>>"+errString);
System.out.println("Current Date>>>>>>>"+curDate);
}
else if (currentColumn.trim().equals("itm_defaultedit"))
{
String tranId = checkNull(genericUtility.getColumnValue("tran_id", dom2));
sql="";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
valueXmlString.append("<tran_id><![CDATA[").append(tranId).append("]]></tran_id>");
valueXmlString.append("<line_no><![CDATA[").append(rs.getInt("line_no")).append("]]></line_no>");
adCode = checkNull(rs.getString("ad_code"));
valueXmlString.append("<ad_code protect ='1'><![CDATA[").append(adCode).append("]]></ad_code>");
valueXmlString.append("<amount_orig protect ='1'><![CDATA[").append(rs.getInt("amount_orig")).append("]]></amount_orig>");
valueXmlString.append("<amount><![CDATA[").append(rs.getInt("amount")).append("]]></amount>");
valueXmlString.append("<remarks><![CDATA[").append(checkNull(rs.getString("remarks"))).append("]]></remarks>");
sql1="select descr from allwdedn where ad_code= ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, adCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
valueXmlString.append("<ad_descr><![CDATA[").append(checkNull(rs.getString("descr"))).append("]]></ad_descr>");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
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>");
if(currentFormNo == 2 && currentColumn.equals("itm_default") )
{
valueXmlString= new StringBuffer(errString);
System.out.println("valueXmlString for default data>>>"+valueXmlString);
}
}
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");
Node parentNode = null;
Node childNode = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
String errString = "";
String childNodeName = "";
int currentFormNo = 0;
int childNodeListLength = 0;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int ctr = 0;
int count = 0;
String userId = "" ;
String objName = "";
String adCode = "";
String retString = "";
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccess = null;
Connection conn = 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" ) );
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.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) );
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;
}
if(adCode != (null) || adCode.trim().length()>0)
{
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;
}
}
}
}
}
break;
case 2 :
String amountType="";
double totalAmt=0,totalAmtOrg=0;
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 amount = checkNull( genericUtility.getColumnValue("amount",dom )) ;
if(Double.parseDouble(amount) < 0.00 )
{
System.out.println("amount1 --["+amount+"]");
retString = itmDBAccess.getErrorString( "", "VTPAYALC03", userId, "", conn );
return retString;
}
if(amountType.equals("Fixed"))
{
totalAmt=totalAmt+Double.parseDouble(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 )) ;
totalAmtOrg=totalAmtOrg+Double.parseDouble(amountOrg);
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 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;
}
public String defaultData( Document dom, Document dom1, String objContext, String xtraParams ,Connection conn,String empCode,String adCode) throws ITMException{
String sql = "", ad_code = "", ad_descr = "";
String userId="";
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer valueXmlBuff = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlBuff.append( "A" ).append( "</editFlag>\r\n</Header>\r\n<Errors>\r\n</Errors>\r\n" );
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
SimpleDateFormat sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
String key_flag = "";
sql = "select key_flag from transetup where tran_window = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_pay_stru_chg_req_wiz");
rs = pstmt.executeQuery();
if(rs.next()) {
key_flag = checkNull(rs.getString("key_flag")).trim();
} else {
key_flag = "A";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("A".equalsIgnoreCase(key_flag))
{
System.out.println("@S@emp_code__decl>>>>["+empCode+"]");
sql="select ALLWDEDN.AD_CODE,ALLWDEDN.DESCR,EMPLOYEE_AD.EFF_DATE,EMPLOYEE_AD.AMOUNT,EMPLOYEE_AD.Type from EMPLOYEE_AD,ALLWDEDN where EMPLOYEE_AD.emp_code= ? and ALLWDEDN.AD_CODE=EMPLOYEE_AD.AD_CODE and EMPLOYEE_AD.EFF_DATE <= TRUNC(SYSDATE) AND EMPLOYEE_AD.EXP_DATE >= TRUNC(SYSDATE) AND EMPLOYEE_AD.AD_CODE IN (?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, adCode);
rs = pstmt.executeQuery();
int lineNo = 0;
while(rs.next())
{
lineNo++;
ad_code = checkNull(rs.getString("ad_code"));
ad_descr = checkNull(rs.getString("DESCR"));
double amt = rs.getDouble("amount");
double amt_org = rs.getDouble("amount");
String effDateOrig = checkNull(sdf.format(rs.getDate("eff_date")));
String amt_type=checkNull(rs.getString("TYPE"));
System.out.println("amt_type>>>>>"+amt_type);
valueXmlBuff.append("<Detail2 domID='" + lineNo + "' selected=\"Y\">\r\n");
valueXmlBuff.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlBuff.append( "<tran_id><![CDATA[").append( "" ).append("]]></tran_id>");
valueXmlBuff.append("<line_no>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>");
valueXmlBuff.append("<ad_code>").append("<![CDATA[" + ad_code + "]]>").append("</ad_code>");
valueXmlBuff.append("<ad_descr>").append("<![CDATA[" + ad_descr + "]]>").append("</ad_descr>");
valueXmlBuff.append("<amount_type>").append("<![CDATA[" + amt_type + "]]>").append("</amount_type>");
valueXmlBuff.append("<amount>").append("<![CDATA[" + amt + "]]>").append("</amount>");
valueXmlBuff.append("<amount_type_orig>").append("<![CDATA[" + amt_type + "]]>").append("</amount_type_orig>");
valueXmlBuff.append("<amount_orig>").append("<![CDATA[" + amt_org + "]]>").append("</amount_orig>");
valueXmlBuff.append( "<remarks><![CDATA[").append( "" ).append("]]></remarks>");
valueXmlBuff.append("<eff_date>").append("<![CDATA[" + effDateOrig + "]]>").append("</eff_date>");
valueXmlBuff.append("<eff_date_orig>").append("<![CDATA[" + effDateOrig + "]]>").append("</eff_date_orig>");
valueXmlBuff.append("</Detail2>");
System.out.println("out5");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (lineNo == 0)
{
sql="select ALLWDEDN.AD_CODE,ALLWDEDN.DESCR, TRUNC(SYSDATE) AS EFF_DATE, 0 AS AMOUNT,ALLWDEDN.INPUT_TYPE AS Type from ALLWDEDN where ALLWDEDN.AD_CODE IN (?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, adCode);
rs = pstmt.executeQuery();
while(rs.next())
{
lineNo++;
ad_code = checkNull(rs.getString("ad_code"));
ad_descr = checkNull(rs.getString("DESCR"));
double amt = rs.getDouble("amount");
double amt_org = rs.getDouble("amount");
String effDateOrig = checkNull(sdf.format(rs.getDate("eff_date")));
String amt_type=checkNull(rs.getString("TYPE"));
System.out.println("amt_type>>>>>"+amt_type);
valueXmlBuff.append("<Detail2 domID='" + lineNo + "' selected=\"Y\">\r\n");
valueXmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\"/>\r\n");
valueXmlBuff.append( "<tran_id><![CDATA[").append( "" ).append("]]></tran_id>");
valueXmlBuff.append("<line_no>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>");
valueXmlBuff.append("<ad_code>").append("<![CDATA[" + ad_code + "]]>").append("</ad_code>");
valueXmlBuff.append("<ad_descr>").append("<![CDATA[" + ad_descr + "]]>").append("</ad_descr>");
valueXmlBuff.append("<amount_type>").append("<![CDATA[" + amt_type + "]]>").append("</amount_type>");
valueXmlBuff.append("<amount>").append("<![CDATA[" + amt + "]]>").append("</amount>");
valueXmlBuff.append("<amount_type_orig>").append("<![CDATA[" + amt_type + "]]>").append("</amount_type_orig>");
valueXmlBuff.append("<amount_orig>").append("<![CDATA[" + amt_org + "]]>").append("</amount_orig>");
valueXmlBuff.append("<eff_date>").append("<![CDATA[" + effDateOrig + "]]>").append("</eff_date>");
valueXmlBuff.append("<eff_date_orig>").append("<![CDATA[" + effDateOrig + "]]>").append("</eff_date_orig>");
valueXmlBuff.append( "<remarks><![CDATA[").append( "" ).append("]]></remarks>");
valueXmlBuff.append("</Detail2>");
System.out.println("out51");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
valueXmlBuff.append("</Root>\r\n");
System.out.println("Returning from " + this.getClass().getSimpleName() +" : " + valueXmlBuff.toString());
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
if(conn != null) {
conn.close();
conn = null;
}
if(rs != null) {
rs.close();
rs = null;
}
if(pstmt != null) {
pstmt.close();
pstmt = null;
}
System.out.println("Closed all Database Resource...!");
} catch (Exception e) {
System.out.println("Exception in EJB ["+this.getClass().getSimpleName()+"]::generateDefaultData::[" + e.getMessage()+"]");
}
}
return valueXmlBuff.toString();
}
}
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