Commit 0527f3f3 authored by jshaikh's avatar jshaikh

Added migrated component for emp_it_declaration (Income Tax Declaration) named...

Added migrated component for emp_it_declaration (Income Tax Declaration) named as EmpITDeclarationIC

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@201972 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 22d81c25
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class EmpITDeclarationIC extends ValidatorEJB implements EmpITDeclarationICLocal, EmpITDeclarationICRemote
{
static E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("ErrString :" + errString);
}
catch(Exception e)
{
System.out.println("Exception :EmpITDeclarationIC :wfValData(String xmlString):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("Returning from EmpITDeclarationIC wfValData");
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2,String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String userId = null;
String errString = "";
String empCode = "";
String acctPrd = "";
String sql = "";
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int counterChild = 0;
int noOfChilds = 0;
int currentFormNo = 0;
int count = 0;
String adCode = "", tranId = "";
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
empCode = genericUtility.getColumnValue("emp_code",dom);
acctPrd = genericUtility.getColumnValue("acct_prd",dom);
conn = getConnection();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
parentList = dom.getElementsByTagName("Detail" + currentFormNo);
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
System.out.println("noOfChilds == "+noOfChilds);
for(counterChild = 1; counterChild < noOfChilds; counterChild++)
{
childNode = childList.item(counterChild);
childNodeName = childNode.getNodeName();
switch(currentFormNo)
{
case 1:
System.out.println("In case 1 ::::::::");
if (childNodeName.equals("acct_prd"))
{
acctPrd = checkNull(genericUtility.getColumnValue("acct_prd", dom));
if(acctPrd == null || acctPrd.trim().length() == 0)
{
errString = getErrorString("acct_prd", "VMACCTPRD", userId);
return errString;
}
else
{
sql = "select count(*) as count from acctprd where code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("count");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ( count == 0 )
{
errString = getErrorString("acct_prd","VMACCTPRD",userId);
return errString;
}
}
}
if (childNodeName.equals("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCode == null || empCode.trim().length() == 0)
{
errString = getErrorString("emp_code", "VMEMP1", userId);
return errString;
}
else
{
count = 0;
sql = "select count(emp_code) as count from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("count");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ( count == 0 )
{
errString = getErrorString("emp_code","VMEMP1",userId);
}
}
}
if (childNodeName.equals("ad_code"))
{
adCode = checkNull(genericUtility.getColumnValue("ad_code", dom));
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
acctPrd = checkNull(genericUtility.getColumnValue("acct_prd", dom));
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
if(adCode == null || adCode.trim().length() == 0)
{
errString = getErrorString("ad_code", "VMAD1", userId);
return errString;
}
else
{
count = 0;
sql = "select count(*) as count from allwdedn where ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("count");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (count == 0)
{
errString = getErrorString("ad_code","VMAD1",userId);
return errString;
}
else if("A".equalsIgnoreCase(editFlag))
{
count = 0;
sql = "select count(*) as cnt from emp_it_declaration where acct_prd = ? and emp_code = ? "
+ "and ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, empCode);
pstmt.setString(3, adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (count > 0)
{
errString = getErrorString("ad_code","VTITDECL1",userId);
return errString;
}
}
}
}
}
}
}catch(Exception e)
{
System.out.println("Exception :EmpITDeclMultiEJB :wfValData(Document dom):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Connection...........");
if(rs != null)
{
rs.close();
rs = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e){}
}
return errString;
}
public String itemChanged(String xmlString, String xmlStringHdr, String xmlStringAll, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null, domHdr = null, domAll = null;
String valueXmlString = "";
try {
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlStringHdr != null && xmlStringHdr.trim().length() > 0)
{
domHdr = genericUtility.parseString(xmlStringHdr);
}
if (xmlStringAll != null && xmlStringAll.trim().length() > 0)
{
domAll = genericUtility.parseString(xmlStringAll);
}
valueXmlString = itemChanged(dom, domHdr, domAll, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception [" + this.getClass().getSimpleName() + "] : [itemChanged(S)] " + e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String sql = "", acctPrd = "", empCode = "", adCode = "", empFname = "", empLname = "", descr = "", status = "Y";
String tranId = "";
int currentFormNo = 0, seq_no = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer();
SimpleDateFormat sdf = null;
Calendar cal = Calendar.getInstance();
double amountOld = 0.0;
try {
conn = getConnection();
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[" + this.getClass().getSimpleName() + "] [itemChanged(D)]:currentFormNo:" + currentFormNo);
System.out.println("currentColumn:::::" + currentColumn);
valueXmlString = new StringBuffer("<?xml version=\"1.0\" encoding=''?>\r\n<Root>\r\n<header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</header>\r\n");
sdf = new SimpleDateFormat(genericUtility.getDispDateFormat());
String tranDate = sdf.format(cal.getTime());
switch (currentFormNo) {
case 1:
{
valueXmlString.append("<Detail1>\r\n");
if (currentColumn.trim().equals("itm_default"))
{
System.out.println("--------Inside itm_default--------");
System.out.println("xtraParams------- "+xtraParams);
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "emp_code");
System.out.println("empCode 1 === = "+empCode);
if(empCode == null || empCode.trim().length() == 0)
{
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("login empCode === "+empCode);
}
acctPrd = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "acct_prd");
System.out.println("acctPrd === = "+acctPrd);
if(acctPrd == null || acctPrd.trim().length() == 0)
{
sql = "select acct_prd from period where sysdate between fr_date and to_date";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
acctPrd = checkNull(rs.getString("acct_prd")).trim();
System.out.println("If acctPrd is null == "+acctPrd);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
sql = "select max(tran_id) as tran_id from emp_it_declaration where acct_prd = ? and emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctPrd);
pstmt.setString(2,empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
tranId = checkNull(rs.getString("tran_id")).trim();
if(tranId != null)
{
valueXmlString.append("<tran_id>").append("<![CDATA[" + tranId + "]]>").append("</tran_id>");
}
else
{
valueXmlString.append("<tran_id>").append("<![CDATA[" + acctPrd + "]]>").append("</tran_id>");
}
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<emp_code><![CDATA[").append(empCode).append("]]></emp_code>");
valueXmlString.append("<acct_prd><![CDATA[").append(acctPrd).append("]]></acct_prd>");
valueXmlString.append("<tran_date><![CDATA[").append(tranDate).append("]]></tran_date>");
valueXmlString.append("<status><![CDATA[").append(status).append("]]></status>");
valueXmlString.append("<emp_code protect=\"0\"><![CDATA["+empCode+"]]></emp_code>\r\n");
valueXmlString.append("<acct_prd protect=\"0\"><![CDATA["+acctPrd+"]]></acct_prd>\r\n");
valueXmlString.append("<tran_id protect=\"1\"><![CDATA["+tranId+"]]></tran_id>\r\n");
}
if (currentColumn.trim().equals("itm_defaultedit"))
{
System.out.println("******Inside itm_defaultedit******");
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom)).trim();
acctPrd = checkNull(genericUtility.getColumnValue("acct_prd", dom)).trim();
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom)).trim();
adCode = checkNull(genericUtility.getColumnValue("ad_code", dom)).trim();
//need to change
valueXmlString.append("<tran_id protect = '1'><![CDATA[").append(tranId).append("]]></tran_id>");
valueXmlString.append("<acct_prd protect = '1'><![CDATA[").append(acctPrd).append("]]></acct_prd>");
valueXmlString.append("<emp_code protect = '1'><![CDATA[").append(empCode).append("]]></emp_code>");
valueXmlString.append("<ad_code protect = '1'><![CDATA[").append(adCode).append("]]></ad_code>");
}
if (currentColumn.trim().equals("ad_code"))
{
adCode = checkNull(genericUtility.getColumnValue("ad_code", dom)).trim();
sql = "select descr from allwdedn where ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = checkNull(rs.getString("descr")).trim();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<allwdedn_descr><![CDATA[").append(descr).append("]]></allwdedn_descr>");
}
if (currentColumn.trim().equals("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom)).trim();
sql = "select emp_fname, emp_lname 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")).trim();
empLname = checkNull(rs.getString("emp_lname")).trim();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<employee_emp_fname><![CDATA[").append(empFname).append("]]></employee_emp_fname>");
valueXmlString.append("<employee_emp_lname><![CDATA[").append(empLname).append("]]></employee_emp_lname>");
}
if (currentColumn.trim().equals("amount"))
{
if("A".equalsIgnoreCase(editFlag))
{
valueXmlString.append("<amount_old><![CDATA[0]]></amount_old>");
}
else
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom)).trim();
acctPrd = checkNull(genericUtility.getColumnValue("acct_prd", dom)).trim();
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom)).trim();
adCode = checkNull(genericUtility.getColumnValue("ad_code", dom)).trim();
sql = "select amount_old from emp_it_declaration " +
"where tran_id = ? and emp_code = ? and ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, empCode);
pstmt.setString(3, adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
amountOld = rs.getDouble("amount_old");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<amount_old><![CDATA[").append(amountOld).append("]]></amount_old>");
}
}
if (currentColumn.trim().equals("amount_proof"))
{
if("A".equalsIgnoreCase(editFlag))
{
valueXmlString.append("<amount_proof_old><![CDATA[0]]></amount_proof_old>");
}
else
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom)).trim();
acctPrd = checkNull(genericUtility.getColumnValue("acct_prd", dom)).trim();
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom)).trim();
adCode = checkNull(genericUtility.getColumnValue("ad_code", dom)).trim();
sql = "select amount_proof_old from emp_it_declaration where tran_id = ? and emp_code = ? and ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, empCode);
pstmt.setString(3, adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
amountOld = rs.getDouble("amount_proof_old");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<amount_proof_old><![CDATA[").append(amountOld).append("]]></amount_proof_old>");
}
}
valueXmlString.append("</Detail1>\r\n");
}
}
valueXmlString.append("</Root>\r\n");
} catch (Exception e) {
System.out.println("Exception in EJB["+this.getClass().getSimpleName()+"]:[" + e.getMessage()+"]");
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()+"]::itemChanged::[" + e.getMessage()+"]");
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
public interface EmpITDeclarationICLocal 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() 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;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
public interface EmpITDeclarationICRemote 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() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment