Commit 283bbc66 authored by dpawar's avatar dpawar

update java files


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92360 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1948f232
...@@ -232,9 +232,12 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -232,9 +232,12 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
bondAmt = genericUtility.getColumnValue("bond_amt",dom); bondAmt = genericUtility.getColumnValue("bond_amt",dom);
recAmtDone= genericUtility.getColumnValue("recovery_amt__done",dom); recAmtDone= genericUtility.getColumnValue("recovery_amt__done",dom);
System.out.println("Actual amt :"+recAmtAct+" recAmtDue :"+recAmtDue);
double recAmountAct=0.0,recAmountDue=0.0,bondAmount=0.0,recAmountDone=0.0; double recAmountAct=0.0,recAmountDue=0.0,bondAmount=0.0,recAmountDone=0.0;
if (recAmtAct == null || recAmtAct.trim().length() == 0 ) if (recAmtAct == null || recAmtAct.trim().length() == 0 )
{ {
System.out.println(" recAmtAct Null value........");
errCode = "VBACTAMT"; errCode = "VBACTAMT";
errString = getErrorString("recovery_amt__act",errCode,userId); errString = getErrorString("recovery_amt__act",errCode,userId);
break; break;
...@@ -248,6 +251,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -248,6 +251,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
System.out.println("bondAmount :-->>"+bondAmount+" recAmountDone : "+recAmountDone); System.out.println("bondAmount :-->>"+bondAmount+" recAmountDone : "+recAmountDone);
if(bondAmount == recAmountDone) if(bondAmount == recAmountDone)
{ {
System.out.println("equality condition true -------");
errCode="VRECAMTGRT"; errCode="VRECAMTGRT";
errString = getErrorString("recovery_amt__done",errCode,userId); errString = getErrorString("recovery_amt__done",errCode,userId);
break; break;
...@@ -465,6 +469,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -465,6 +469,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
System.out.println("IN EMP CODE OF ITEM CHANGE"); System.out.println("IN EMP CODE OF ITEM CHANGE");
empCode = genericUtility.getColumnValue("emp_code",dom); empCode = genericUtility.getColumnValue("emp_code",dom);
System.out.println("Employee Code in item change ---->>>"+empCode); System.out.println("Employee Code in item change ---->>>"+empCode);
sql = " Select e.emp_fname,e.emp_mname,e.emp_lname,e.dept_code,d.descr,e.acct_code__sal,e.CCTR_CODE__SAL,e.date_join,e.RELIEVE_DATE,e.BOND_AMT__RECO from "+ sql = " Select e.emp_fname,e.emp_mname,e.emp_lname,e.dept_code,d.descr,e.acct_code__sal,e.CCTR_CODE__SAL,e.date_join,e.RELIEVE_DATE,e.BOND_AMT__RECO from "+
" employee e,department d "+ " employee e,department d "+
" where e.dept_code = d.dept_code and e.emp_code = ? "; " where e.dept_code = d.dept_code and e.emp_code = ? ";
...@@ -510,6 +515,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -510,6 +515,7 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
pstmt = null; pstmt = null;
rs = null; rs = null;
if (dateRelieve !=null && dateJoin !=null&& dateRelieve.length()>0 && dateJoin.length()>0) if (dateRelieve !=null && dateJoin !=null&& dateRelieve.length()>0 && dateJoin.length()>0)
{ {
StringTokenizer st = new StringTokenizer(dateJoin, "/"); StringTokenizer st = new StringTokenizer(dateJoin, "/");
...@@ -586,7 +592,9 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon ...@@ -586,7 +592,9 @@ public class BondRecovery extends ValidatorEJB implements BondRecoveryLocal, Bon
{ {
bondAmtDue= bondAmtDue+rs.getDouble(1); bondAmtDue= bondAmtDue+rs.getDouble(1);
} }
System.out.println("After while bond amt due------->>>>"+bondAmtDue);
bondAmtDone=bondAmtDue; bondAmtDone=bondAmtDue;
bondAmtDue=bondAmt-bondAmtDue; bondAmtDue=bondAmt-bondAmtDue;
valueXmlString.append("<amt__due>").append("<![CDATA["+bondAmtDue+"]]>").append("</amt__due>"); valueXmlString.append("<amt__due>").append("<![CDATA["+bondAmtDue+"]]>").append("</amt__due>");
......
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import java.rmi.RemoteException; import java.rmi.RemoteException;
......
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import java.rmi.RemoteException; import java.rmi.RemoteException;
......
package ibase.webitm.ejb.adm;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.SysCommon;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.sys.UtilMethods;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Date;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import java.text.SimpleDateFormat;
import java.text.DecimalFormat;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
import ibase.webitm.ejb.ITMDBAccessEJB;
import org.w3c.dom.CDATASection;
import java.text.*;
import java.sql.*;
@Stateless // added for ejb3
public class EmpBondDefinition extends ValidatorEJB implements EmpBondDefinitionLocal,EmpBondDefinitionRemote
{
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
System.out.println("\n\n xmlString in wfValData \n:" + xmlString + "\n");
System.out.println("\n\n xmlString1 in wfValData \n :" + xmlString1 +"\n");
System.out.println("\n\n xmlString2 in wfValData \n :" + xmlString2 +"\n");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0)
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
//errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
//ADDED FOR INVOIKING VALIDATION IN WORKFLOW
if( objContext != null && Integer.parseInt(objContext) == 1 )
{
parentNodeList = dom2.getElementsByTagName("Header0");
parentNode = parentNodeList.item(1);
childNodeList = parentNode.getChildNodes();
for(int x=0;x<childNodeList.getLength();x++)
{
childNode = childNodeList.item(x);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("Detail1"))
{
errString = wfValData(dom,dom1,dom2,"1",editFlag,xtraParams);
if(errString != null && errString.trim().length() > 0)
break;
}
else if(childNodeName.equalsIgnoreCase("Detail2"))
{
errString = wfValData(dom,dom1,dom2,"2",editFlag,xtraParams);
if(errString != null && errString.trim().length() > 0)
break;
}
else if(childNodeName.equalsIgnoreCase("Detail3"))
{
errString = wfValData(dom,dom1,dom2,"3",editFlag,xtraParams);
if(errString != null && errString.trim().length() > 0)
break;
}
}
}
else
{
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception : ChangecontrolEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag) throws RemoteException,ITMException
{
return "";
}
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
return "";
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag) throws RemoteException,ITMException
{
return "";
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("in wfValData........");
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0,cnt = 0;
String childNodeName = null;
String errString = "";
String errCode = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String userId = "";
int currentFormNo=0,i=0;
int childNodeListLength;
String empCode="",bondamt="",bondprd="",siteCode = "";
SimpleDateFormat simpleDateFormat = null;
try
{
System.out.println("in try.....");
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("in switch.....");
parentNodeList = dom.getElementsByTagName("Detail1");
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("emp_code"))
{
empCode = getColumnValue("emp_code",dom);
if (empCode == null || empCode.trim().length() == 0 )
{
errCode = "VNULEMPC";
errString = getErrorString("emp_code",errCode,userId);
break;
}
else
{
sql = "select count(1) from employee where emp_code = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "VMEMPCD1 ";
errString = getErrorString("emp_code",errCode,userId);
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = getColumnValue("site_code",dom);
if (siteCode == null || siteCode.trim().length() == 0 )
{
errCode = "VMSITENULL";
errString = getErrorString("site_code",errCode,userId);
break;
}
else
{
sql = "select count(1) from site where site_code = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "VMSITENVAL";
errString = getErrorString("site_code",errCode,userId);
break;
}
}
}
}// for loop end
break;
case 2:
System.out.println("in detail 2 ------>>>>>>>>");
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("bond_amt"))
{
bondamt = genericUtility.getColumnValue("bond_amt",dom);
if (bondamt == null )
{
errCode = "VMBAMTNULL";
errString = getErrorString("bond_amt",errCode,userId);
break;
}
}
if (childNodeName.equalsIgnoreCase("bond_prd"))
{
bondprd = genericUtility.getColumnValue("bond_prd",dom);
if (bondprd == null || bondprd.trim().length() == 0 )
{
errCode = "VMBPRDNULL";
errString = getErrorString("bond_prd",errCode,userId);
break;
}
}
}// for loop end
break;
} //end switch
}//end try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return errString;
}
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 valueXmlString = "";
//System.out.println("\n\n xmlString in ItemChanged \n:" + xmlString + "\n");
//System.out.println("\n\n xmlString1 In ItemChanged \n :" + xmlString1 +"\n");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ChangeControlEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
int ctr=0;
String childNodeName = null;
String columnValue = null;
int currentFormNo = 0;
String deptCode="",empCode="",deptDescr = "";
String sql = "",descr = "",empfname = "", empmname = "", emplname = "";
ConnDriver connDriver = new ConnDriver();
String tranDate="",loginEmpCode="";
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver=null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
switch(currentFormNo)
{
case 1 :
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
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));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("in itm chnaged.....");
String confirmed="N";
tranDate = simpleDateFormat.format(timestamp).toString();
System.out.println("Tran Date 111: "+tranDate.toString());
valueXmlString.append("<tran_date>").append("<![CDATA["+tranDate.trim()+"]]>").append("</tran_date>");
valueXmlString.append("<confirmed>").append("<![CDATA["+confirmed+"]]>").append("</confirmed>");
String loginSiteCode = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,loginSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_code>").append("<![CDATA["+loginSiteCode+"]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA["+descr+"]]>").append("</site_descr>");
loginEmpCode = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
sql = " SELECT E.EMP_FNAME,E.EMP_MNAME,E.EMP_LNAME,E.DEPT_CODE,D.DESCR FROM "+
" EMPLOYEE E,DEPARTMENT D WHERE D.DEPT_CODE = E.DEPT_CODE AND "+
" E.EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginEmpCode);
rs = pstmt.executeQuery();
while(rs.next())
{
empfname = rs.getString(1) == null ? "" : rs.getString(1).trim();
empmname = rs.getString(2) == null ? "" : rs.getString(2).trim();
emplname = rs.getString(3) == null ? "" : rs.getString(3).trim();
deptCode = rs.getString(4) == null ? "" : rs.getString(4).trim();
deptDescr = rs.getString(5) == null ? "" : rs.getString(5).trim();
valueXmlString.append("<emp_code>").append("<![CDATA["+ loginEmpCode +"]]>").append("</emp_code>");
valueXmlString.append("<emp_fname>").append("<![CDATA["+empfname +"]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA["+empmname +"]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA["+emplname +"]]>").append("</emp_lname>");
valueXmlString.append("<dept_code>").append("<![CDATA["+ deptCode +"]]>").append("</dept_code>");
valueXmlString.append("<department_descr>").append("<![CDATA["+ deptDescr +"]]>").append("</department_descr>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
else if(currentColumn.trim().equalsIgnoreCase("site_code"))
{
System.out.println("site code change...");
String siteCode = getColumnValue("site_code",dom);
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
descr = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_descr>").append("<![CDATA["+descr.trim()+"]]>").append("</site_descr>");
}
else if(currentColumn.trim().equalsIgnoreCase("emp_code"))
{
empCode = genericUtility.getColumnValue("emp_code",dom);
sql = " Select e.emp_fname,e.emp_mname,e.emp_lname,e.dept_code,d.descr from "+
" employee e,department d "+
" where e.dept_code = d.dept_code and e.emp_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,empCode);
rs = pstmt.executeQuery();
while(rs.next())
{
empfname = rs.getString(1) == null ? "" : rs.getString(1);
empmname = rs.getString(2) == null ? "" : rs.getString(2);
emplname = rs.getString(3) == null ? "" : rs.getString(3);
deptCode = rs.getString(4) == null ? "" : rs.getString(4);
descr = rs.getString(5) == null ? "" : rs.getString(5);
valueXmlString.append("<emp_fname>").append("<![CDATA["+empfname+"]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA["+empmname+"]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA["+emplname+"]]>").append("</emp_lname>");
valueXmlString.append("<dept_code>").append("<![CDATA["+deptCode+"]]>").append("</dept_code>");
valueXmlString.append("<department_descr>").append("<![CDATA["+descr+"]]>").append("</department_descr>");
System.out.println("First Name :"+empfname+" Middle Name :"+empmname+" Last Name :"+emplname);
System.out.println("Dept code :"+deptCode+" descr : "+descr);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
valueXmlString.append("</Detail1>");
break;
}// end switch
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
System.out.println("Return xml ---->>>>"+valueXmlString.toString());
return valueXmlString.toString();
}
}//end class
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
......
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; import javax.ejb.Remote; // added for ejb3
public interface EmpBondDefinitionRemote extends ValidatorLocal{ public interface EmpBondDefinitionRemote extends ValidatorLocal{
public String wfValData() throws RemoteException,ITMException; public String wfValData() 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