Commit f3322021 authored by sanashaikh's avatar sanashaikh

Sana S: Added by Sana S on 04/03/20

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@217496 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 413f344e
package ibase.webitm.ejb.adm.adv;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
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.Date;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
@Stateless
public class PayStruChgReqDefault extends ActionHandlerEJB implements PayStruChgReqDefaultLocal, PayStruChgReqDefaultRemote {
E12GenericUtility genericUtility = new E12GenericUtility();
@Override
public String actionHandler(String actionType, String xmlString, String xmlString1,String objContext, String xtraParams)throws RemoteException, ITMException
{
System.out.println("actionType[" + actionType + "]\n\txmlString[" + xmlString + "]\n\tobjContext[" + objContext + "]\n\txtraParams[" + xtraParams);
Document dom = null,dom1=null;
String retString = "";
try{
xmlString = xmlString == null ? "" : xmlString.trim();
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 );
}
if (actionType.equalsIgnoreCase("Default"))
{
retString = defaultData(dom, dom1,objContext, xtraParams);
System.out.print("retString in actionHandler>>>>"+retString);
System.out.print("Welcome in JAVA");
}
System.out.println(genericUtility.serializeDom(dom));
} catch (Exception e) {
System.out.println("Exception in " + this.getClass().getSimpleName() + ":" + e.getMessage());
}
System.out.println("Returning from " + this.getClass().getSimpleName() + "[" + retString + "]");
return retString;
}
public String defaultData( Document dom, Document dom1, String objContext, String xtraParams) throws ITMException, RemoteException
{
String sql = "", adCodeNew = "", adDescr = "",adCode="",empCode="";
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn=null;
String amtType="";
double amt=0.0,amtOrig=0.0;
java.sql.Date effDate=null;
StringBuffer valueXmlBuff = new StringBuffer( "<?xml version=\"1.0\"?>\r\n" );
valueXmlBuff.append( "<Root>\r\n" );
try
{
SimpleDateFormat sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
conn=getConnection();
adCode = checkNull(genericUtility.getColumnValue("ad_alloc_group",dom1) ) ;
empCode = checkNull( genericUtility.getColumnValue("emp_code",dom1) ) ;
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;
String effDateOrig = "";
while(rs.next())
{
lineNo++;
adCodeNew = checkNull(rs.getString("ad_code"));
adDescr = checkNull(rs.getString("DESCR"));
amt = rs.getDouble("amount");
amtOrig = rs.getDouble("amount");
effDate=rs.getDate("eff_date");
if(effDate.equals(null))
{
effDateOrig="";
}
else
{
effDateOrig=sdf.format(effDate);
}
amtType=checkNull(rs.getString("TYPE"));
valueXmlBuff.append("<Detail>\r\n >");
valueXmlBuff.append("<line_no>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>");
valueXmlBuff.append("<ad_code>").append("<![CDATA[" + adCodeNew + "]]>").append("</ad_code>");
valueXmlBuff.append("<ad_descr>").append("<![CDATA[" + adDescr + "]]>").append("</ad_descr>");
valueXmlBuff.append("<amount_type>").append("<![CDATA[" + amtType + "]]>").append("</amount_type>");
valueXmlBuff.append("<amount>").append("<![CDATA[" + String.format("%.0f", amt) + "]]>").append("</amount>");
valueXmlBuff.append("<amount_type_orig>").append("<![CDATA[" + amtType + "]]>").append("</amount_type_orig>");
valueXmlBuff.append("<amount_orig>").append("<![CDATA[" + String.format("%.0f", amtOrig) + "]]>").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("</Detail>");
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++;
adCodeNew = checkNull(rs.getString("ad_code"));
adDescr = checkNull(rs.getString("DESCR"));
amt = rs.getDouble("amount");
amtOrig = rs.getDouble("amount");
effDate=rs.getDate("eff_date");
if(effDate.equals(null))
{
effDateOrig="";
}
else
{
effDateOrig=sdf.format(effDate);
}
amtType=checkNull(rs.getString("TYPE"));
valueXmlBuff.append("<Detail>\r\n");
valueXmlBuff.append("<line_no>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>");
valueXmlBuff.append("<ad_code>").append("<![CDATA[" + adCodeNew + "]]>").append("</ad_code>");
valueXmlBuff.append("<ad_descr>").append("<![CDATA[" + adDescr + "]]>").append("</ad_descr>");
valueXmlBuff.append("<amount_type>").append("<![CDATA[" + amtType + "]]>").append("</amount_type>");
valueXmlBuff.append("<amount>").append("<![CDATA[" + String.format("%.0f", amt) + "]]>").append("</amount>");
valueXmlBuff.append("<amount_type_orig>").append("<![CDATA[" + amtType + "]]>").append("</amount_type_orig>");
valueXmlBuff.append("<amount_orig>").append("<![CDATA[" + String.format("%.0f", amtOrig) + "]]>").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("</Detail>");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
valueXmlBuff.append("</Root>\r\n");
System.out.println("Returning from " + getClass().getSimpleName() +" : " + valueXmlBuff.toString());
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(pstmt != null) {
pstmt.close();
pstmt = null;
}
if(conn != null) {
conn.close();
conn = 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();
}
private static String checkNull(String value) {
return value == null ? "" : value.trim();
}
@Override
public String actionHandler(String actoinType, Document dom, Document dom1, String objContext, String xtraParams)
throws RemoteException, ITMException {
return null;
}
}
\ No newline at end of file
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