Commit a6ec15b4 authored by manohar's avatar manohar

New component imported


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97232 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0bc75dbc
package ibase.webitm.ejb.adm;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.sys.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.*;
import java.sql.*;
import javax.ejb.Stateless;
import ibase.webitm.ejb.sys.UtilMethods;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class EmpComplete extends ValidatorEJB implements EmpCompleteLocal,EmpCompleteRemote
{
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("EmpComplete is Creating..........");
}
public void ejbRemove()
{
System.out.println("EmpComplete is Removing..........");
}
public void ejbActivate()
{
System.out.println("EmpComplete is Activating..........");
}
public void ejbPassivate()
{
System.out.println("EmpComplete is Passivating..........");
}*/
public String wfValData()throws RemoteException, ITMException
{
return "";
}
public String itemChanged()throws RemoteException, ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("***********************Validation Start EmpComplete**************************");
try
{
System.out.println("xmlString:::"+xmlString);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : EmpComplete : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr=0,currentFormNo =0,childNodeListLength =0,cnt =0;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String childNodeName = null,childNodeValue = null;
String errString = "";
String errCode = "";
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
String sql = "";
String userId = "";
String loginSite = "",cctrCodeSal ="",env ="";
String contactCode="",empLname = "",empFname = "",empCodeLink ="",cadre_code = "";
String relieveDateStr ="",deptCode ="",cadreCode ="",gradeCode ="";
String designCode ="",empSite ="",workSite ="",bankCode ="", stanCode ="";
String empCode ="",paySite ="",ddPayableBank ="",payMode="",projCode= "";
String accCodeSal = "",reportTo ="", nationality = "", contactState = "",curState = "",perState="";
String siteCodePayment ="",stanCodeHq ="",bankAcct = "",reportToAdmin ="";
String patternCode ="",workShift ="",gratuityDateStr ="",dateJoinStr ="",status ="";
java.util.Date dateJoin = null, gratuityDate = null;
java.util.Date today = null;
java.util.Date startDate =null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
stmt = conn.createStatement();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println(" ***********Validation for EmpComplete Detail "+currentFormNo);
switch(currentFormNo)
{
case 1 :
System.out.println("Validation for Detail 1 EmpComplete..........");
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(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("emp_code"))
{
System.out.println(" Validaion for field "+childNodeName);
empCode = genericUtility.getColumnValue("emp_code", dom);
cnt = isValueExist("employee","emp_code",empCode, conn);
if("A".equalsIgnoreCase(editFlag))
{
if(cnt > 0)
{
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("contact_code"))
{
System.out.println(" Validaion for field "+childNodeName);
contactCode = genericUtility.getColumnValue("contact_code", dom);
cnt = isValueExist("contact","contact_code",contactCode, conn);
if(cnt == 0)
{
errCode = "VMCCD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("emp_lname"))
{
System.out.println(" Validaion for field "+childNodeName);
empLname = genericUtility.getColumnValue("emp_lname", dom);
if(empLname == null || empLname.trim().length() == 0)
{
errCode = "VEEMP3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("emp_fname"))
{
System.out.println(" Validaion for field "+childNodeName);
empFname = genericUtility.getColumnValue("emp_fname", dom);
if(empFname == null || empFname.trim().length() == 0)
{
errCode = "VEEMP4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("emp_code__link"))
{
System.out.println(" Validaion for field "+childNodeName);
empCodeLink = genericUtility.getColumnValue("emp_code__link", dom);
if(empCodeLink != null && empCodeLink.trim().length() > 0)
{
cnt = isValueExist("employee","emp_code",empCodeLink, conn);
if(cnt == 0)
{
errCode = "VMEMP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
relieveDateStr = getFieldValue("relieve_date", "employee", "emp_code", empCodeLink, conn);
if(relieveDateStr == null || relieveDateStr.trim().length() == 0)
{
errCode = "VTEMPRLVDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
if(childNodeName.equalsIgnoreCase("dept_code"))
{
System.out.println(" Validaion for field "+childNodeName);
deptCode = genericUtility.getColumnValue("dept_code", dom);
cnt = isValueExist("department","dept_code",deptCode, conn);
if(cnt == 0)
{
errCode = "VMDEP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
status = getFieldValue("status", "department", "dept_code", deptCode, conn);
if("I".equalsIgnoreCase(status))
{
errCode = "VTDPINAC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("cadre_code"))
{
System.out.println(" Validaion for field "+childNodeName);
cadreCode = genericUtility.getColumnValue("cadre_code", dom);
cnt = isValueExist("cadre","cadre_code",cadreCode, conn);
if(cnt == 0)
{
errCode = "VMCAD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("grade_code"))
{
System.out.println(" Validaion for field "+childNodeName);
gradeCode = genericUtility.getColumnValue("grade_code", dom);
cnt = isValueExist("grade","grade_code",gradeCode, conn);
if(cnt == 0)
{
errCode = "VMGRA1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("design_code"))
{
System.out.println(" Validaion for field "+childNodeName);
designCode = genericUtility.getColumnValue("design_code", dom);
if(designCode != null && designCode.trim().length() > 0)
{
cnt = isValueExist("designation","design_code",designCode, conn);
if(cnt == 0)
{
errCode = "VMDESIGN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
status = getFieldValue("status", "designation", "design_code", designCode, conn);
if("I".equalsIgnoreCase(status))
{
errCode = "VTDGINAC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
if(childNodeName.equalsIgnoreCase("emp_site"))
{
System.out.println(" Validaion for field "+childNodeName);
empSite = genericUtility.getColumnValue("emp_site", dom);
cnt = isValueExist("site","site_code",empSite, conn);
if(cnt == 0)
{
errCode = "VTSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("work_site"))
{
System.out.println(" Validaion for field "+childNodeName);
workSite = genericUtility.getColumnValue("work_site", dom);
cnt = isValueExist("site","site_code",workSite, conn);
if(cnt == 0)
{
errCode = "VMWKRSITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("pay_site"))
{
System.out.println(" Validaion for field "+childNodeName);
paySite = genericUtility.getColumnValue("pay_site", dom);
cnt = isValueExist("site","site_code",paySite, conn);
if(cnt == 0)
{
errCode = "VMPAYSITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("bank_code"))
{
System.out.println(" Validaion for field "+childNodeName);
bankCode = genericUtility.getColumnValue("bank_code", dom);
if(bankCode != null && bankCode.trim().length() > 0 )
{
cnt = isValueExist("bank","bank_code",bankCode, conn);
if(cnt == 0)
{
errCode = "VMBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
stanCode = genericUtility.getColumnValue("stan_code", dom);
empCode = genericUtility.getColumnValue("emp_code", dom);
if(stanCode != null && stanCode.trim().length() > 0)
{
sql = " select count(*) from bank_stan_serv where bank_code = '"+bankCode+"' and stan_code = '"+stanCode+"' ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VTBKSTAN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
paySite = genericUtility.getColumnValue("pay_site", dom);
if(paySite != null && paySite.trim().length() > 0 )
{
sql = " select count(*) from bank_stan_serv where bank_code = '"+bankCode+"' and "
+" site_code = (select site_code__acct from site where site_code = '"+paySite+"' ) ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VTBKPAY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
if(childNodeName.equalsIgnoreCase("dd_payable_bank"))
{
System.out.println(" Validaion for field "+childNodeName);
ddPayableBank = genericUtility.getColumnValue("dd_payable_bank", dom);
if(ddPayableBank != null && ddPayableBank.trim().length() > 0)
{
cnt = isValueExist("bank","bank_code",ddPayableBank, conn);
if(cnt == 0)
{
errCode = "VTBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("stan_code"))
{
System.out.println(" Validaion for field "+childNodeName);
stanCode = genericUtility.getColumnValue("stan_code", dom);
if(stanCode != null && stanCode.trim().length() > 0)
{
cnt = isValueExist("station","stan_code",stanCode, conn);
if(cnt == 0)
{
errCode = "VESTACD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
payMode = genericUtility.getColumnValue("pay_mode", dom);
if(payMode != null && payMode.trim().length() > 0)
{
if(("D".equalsIgnoreCase(payMode)) || ("T".equalsIgnoreCase(payMode)) )
{
if(stanCode == null || stanCode.trim().length() == 0)
{
errCode = "VESTACD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
if(childNodeName.equalsIgnoreCase("proj_code"))
{
System.out.println(" Validaion for field "+childNodeName);
projCode = genericUtility.getColumnValue("proj_code", dom);
if(projCode != null && projCode.trim().length() > 0)
{
cnt = isValueExist("project","proj_code",projCode, conn);
if(cnt == 0)
{
errCode = "VTPROJCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("acct_code__sal"))
{
System.out.println(" Validaion for field "+childNodeName);
accCodeSal = genericUtility.getColumnValue("acct_code__sal", dom);
if(accCodeSal != null && accCodeSal.trim().length() > 0)
{
cnt = isValueExist("accounts","acct_code",accCodeSal, conn);
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("cctr_code__sal"))
{
//ibase.webitm.ejb.adm.AdmCommon addCommon = new ibase.webitm.ejb.adm.AdmCommon();
System.out.println(" Validaion for field "+childNodeName);
cctrCodeSal = genericUtility.getColumnValue("cctr_code__sal", dom);
//env = addCommon.getEnv("999999","CCTR_YESNO",conn);
env = getEnv("999999","CCTR_YESNO",conn);
//addCommon = null;
if (env.equalsIgnoreCase("NULLFOUND"))
{
errCode = "VSENVAR1";
}
else
{
if(cctrCodeSal.trim().length() > 1)
{
cnt = isValueExist("costctr","cctr_code",cctrCodeSal, conn);
if(cnt == 0)
{
errCode = "VMCCTR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
if("N".equalsIgnoreCase(env))
{
errCode = "VMCCTR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
// mVal = dw_edit.getitemstring(1,"cctr_code__sal")
// ls_temp = gf_getenv('999999',"CCTR_YESNO")
// if ls_temp = 'NULLFOUND' then
// errcode = 'VSENVAR1'
// else
// if Len(trim(mval)) > 0 THEN
// Select count(*) into :cnt from costctr where cctr_code = :mval;
// IF cnt = 0 THEN
// errcode = "VMCCTR1" //Invalid cost cemter code, not defined in master"
// END IF
// else
// if ls_temp = 'N' then
// errcode = "VMCCTR1" //Invalid cost cemter code, not defined in master"
// end if
// end if
// END IF
// }
if(childNodeName.equalsIgnoreCase("report_to"))
{
System.out.println(" Validaion for field "+childNodeName);
reportTo = genericUtility.getColumnValue("report_to", dom);
empCode = genericUtility.getColumnValue("emp_code", dom);
if(reportTo != null && reportTo.trim().length() > 0)
{
cnt = isValueExist("employee","emp_code",reportTo, conn);
if(cnt == 0)
{
errCode = "VMEMP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
status = getFieldValue("status", "employee", "emp_code", reportTo, conn);
if("S".equalsIgnoreCase(status))
{
errCode = "VMEMP2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if(empCode.equalsIgnoreCase(reportTo))
{
errCode = "VMEMP4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
if(childNodeName.equalsIgnoreCase("nationality"))
{
System.out.println(" Validaion for field "+childNodeName);
nationality = genericUtility.getColumnValue("nationality", dom);
// if(nationality != null || nationality.trim().length() > 0)
// {
cnt = isValueExist("country","count_code",nationality, conn);
if(cnt == 0)
{
errCode = "VMCONT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//}
}
if(childNodeName.equalsIgnoreCase("contact_state"))
{
System.out.println(" Validaion for field "+childNodeName);
contactState = genericUtility.getColumnValue("contact_state", dom);
if(contactState != null && contactState.trim().length() > 0)
{
cnt = isValueExist("state","state_code",contactState, conn);
if(cnt == 0)
{
errCode = "VESTATCD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("cur_state"))
{
System.out.println(" Validaion for field "+childNodeName);
curState = genericUtility.getColumnValue("cur_state", dom);
if(curState != null && curState.trim().length() > 0)
{
cnt = isValueExist("state","state_code",curState, conn);
if(cnt == 0)
{
errCode = "VESTATCD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("per_state"))
{
System.out.println(" Validaion for field "+childNodeName);
perState = genericUtility.getColumnValue("per_state", dom);
if(perState != null && perState.trim().length() > 0)
{
cnt = isValueExist("state","state_code",perState, conn);
if(cnt == 0)
{
errCode = "VESTATCD2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("date_join"))
{
System.out.println(" Validaion for field "+childNodeName);
dateJoinStr = genericUtility.getColumnValue("date_join", dom);
System.out.println(" dateJoinStr................ "+dateJoinStr);
if(dateJoinStr == null || dateJoinStr.trim().length() == 0)
{
errCode = "VMJOIN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("site_code__payment"))
{
System.out.println(" Validaion for field "+childNodeName);
siteCodePayment = genericUtility.getColumnValue("site_code__payment", dom);
empSite = genericUtility.getColumnValue("emp_site", dom);
if(siteCodePayment != null && siteCodePayment.trim().length() > 0)
{
cnt = isValueExist("site","site_code",siteCodePayment, conn);
if(cnt == 0)
{
errCode = "VMSITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select count(*) from site where site_code = '"+siteCodePayment+"' and "
+" fin_entity = (select fin_entity from site where site_code = '"+empSite+"' ) ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMSITE2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
if(childNodeName.equalsIgnoreCase("stan_code__hq"))
{
System.out.println(" Validaion for field "+childNodeName);
stanCodeHq = genericUtility.getColumnValue("stan_code__hq", dom);
if(stanCodeHq != null && stanCodeHq.trim().length() > 0)
{
cnt = isValueExist("station","stan_code",stanCodeHq, conn);
if(cnt == 0)
{
errCode = "VESTACD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("pay_mode"))
{
System.out.println(" Validaion for field "+childNodeName);
payMode = genericUtility.getColumnValue("pay_mode", dom);
if("T".equalsIgnoreCase(payMode))
{
bankCode = genericUtility.getColumnValue("bank_code", dom);
bankAcct = genericUtility.getColumnValue("bank_acct", dom);
if(bankCode == null || bankCode.trim().length() == 0 )
{
errCode = "VMBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(bankAcct == null || bankAcct.trim().length() == 0 )
{
errCode = "VTBANKACC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if("D".equalsIgnoreCase(payMode) )
{
bankCode = genericUtility.getColumnValue("bank_code", dom);
if(bankCode == null || bankCode.trim().length() == 0 )
{
errCode = "VMBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(childNodeName.equalsIgnoreCase("report_to__admin"))
{
System.out.println(" Validaion for field "+childNodeName);
reportToAdmin = genericUtility.getColumnValue("report_to__admin", dom);
empCode = genericUtility.getColumnValue("emp_code", dom);
if(reportToAdmin != null && reportToAdmin.trim().length() > 0)
{
cnt = isValueExist("employee","emp_code",reportToAdmin, conn);
if(cnt == 0)
{
errCode = "VMEMP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(empCode.equalsIgnoreCase(reportToAdmin))
{
errCode = "VMEMPACD";
}
else
{
relieveDateStr = getFieldValue("relieve_date", "employee", "emp_code", empCode, conn);
if(relieveDateStr != null && relieveDateStr.trim().length() > 0)
{
errCode = "VMEMPREL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
if(childNodeName.equalsIgnoreCase("pattern_code"))
{
System.out.println(" Validaion for field "+childNodeName);
patternCode = genericUtility.getColumnValue("pattern_code", dom);
if(patternCode != null && patternCode.trim().length() > 0)
{
empCode = genericUtility.getColumnValue("emp_code", dom);
workSite = genericUtility.getColumnValue("work_site", dom);
sql = " select start_date from shift_pattern where site_code = '"+workSite+"' and "
+" pattern_code = '"+patternCode+"' ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
today = new java.util.Date();
if(rs.next())
{
startDate = rs.getDate(1);
if( today.before(startDate))
{
errCode = "VTDTGTST";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
if(childNodeName.equalsIgnoreCase("work_shift"))
{
System.out.println(" Validaion for field "+childNodeName);
workShift = genericUtility.getColumnValue("work_shift", dom);
if(workShift != null && workShift.trim().length() > 0)
{
empCode = genericUtility.getColumnValue("emp_code", dom);
workSite = genericUtility.getColumnValue("work_site", dom);
sql = " select count(*) from workshft where site_code = '"+workSite+"' and "
+" shift = '"+workShift+"' ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VTWSNOT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select count(*) from workshft where site_code = '"+workSite+"' and "
+" shift = '"+workShift+"' and status = 'I' ";
System.out.println(" sql ..............."+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt > 0)
{
errCode = "VTSHINAC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
}
if(childNodeName.equalsIgnoreCase("gratuity_date"))
{
System.out.println(" Validaion for field "+childNodeName);
gratuityDate = getDateObject(genericUtility.getColumnValue("gratuity_date",dom));
dateJoin = getDateObject(genericUtility.getColumnValue("date_join",dom));
// dateJoin = new SimpleDateFormat(genericUtility.getApplDateFormat()).parse(dateJoinStr);
//gratuityDate = new SimpleDateFormat(genericUtility.getApplDateFormat()).parse(gratuityDateStr.toString());
if( gratuityDate == null )
{
errCode = "VTGRADATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if( gratuityDate.before(dateJoin))
{
errCode = "VTGRADATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
break;
case 4 :
System.out.println("Validation for Detail 4..........");
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("qlf_code"))
{
System.out.println(" Validaion for field "+childNodeName);
cnt = isValueExist("qualification", "qlf_code", childNodeValue, conn);
if(cnt == 0)
{
errCode = "VMQLF1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}//END FOR
break;
case 5 :
System.out.println("Validation for Detail 5 ..........");
parentNodeList = dom.getElementsByTagName("Detail5");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("train_code"))
{
System.out.println(" Validaion for field "+childNodeName);
cnt = isValueExist("training", "train_code", childNodeValue, conn);
if(cnt == 0)
{
errCode = "VMTRG1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}//END FOR
break;
case 7 :
System.out.println("Validation for Detail 7 ..........");
parentNodeList = dom.getElementsByTagName("Detail7");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("bank_code"))
{
System.out.println(" Validaion for field "+childNodeName);
bankCode = genericUtility.getColumnValue("bank_code", dom);
cnt = isValueExist("bank", "bank_code", bankCode, conn);
if(cnt == 0)
{
errCode = "VMBKCODE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}//END FOR
break;
}//END SWITCH
int errListSize = errList.size();
int count = 0;
String errorType = "";
String errFldName = null;
itmDBAccessEJB = new ITMDBAccessEJB();
if(errList != null && errListSize > 0)
{
for(count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println("errCode .........." + errCode);
// errString = getErrorString(errFldName, errCode, userId);
errString = itmDBAccessEJB.getErrorString(errFldName, errCode, userId);
System.out.println("errString........"+errString);
errString = itmDBAccessEJB.getErrorString("", errCode, userId);
System.out.println("errString........"+errString);
errorType = errorType(conn , errCode);
return errString;
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" EmpComplete Validation End and Connection is Closed");
}
errString = errStringXml.toString();
System.out.println("ErrString ::"+errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
valueXmlString = itemChanged(dom,dom1,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EmpComplete][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, 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;
int ctr=0,k=0,childNodeListLength=0;
String columnValue = null;
String childNodeName = null;
String errString = "";
String errCode = "";
String designCode="",descr="",reportToAdmin="";
String contactCode = "" , name = "" ;
String gradeCode ="",cadreCode="",designation="",joinedAs="",sex="";
String curAdd1="",perAdd1="",curAdd2="",perAdd2="",curAdd3="",perAdd3="";
String curPin="",perPin="",curState="",perState="",curCity="",perCity="",state="";
String empCode="",probationFlag="",confirmedFlag="",trainingPrdStr="",probationPrdStr="";
String dateJoin="",dateStr="";
String paySite="",workSite="",gratuityDateStr="";
String curTel1 ="",perTel1="",perTel="",contactCity="";
Timestamp dateJoinTs =null,date =null,probationDate =null;
int trainingPrd=0,probationPrd=0;
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String userId = "",loginSite="";
String mcode = "",empLname = "",empFname = "",query ="";
String dateJoinStr ="",probationDateStr="";
GenericUtility genericUtility = GenericUtility.getInstance();
UtilMethods utilMethods = UtilMethods.getInstance();
try
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
ConnDriver conndriver = new ConnDriver();
conn = conndriver.getConnectDB("DriverITM");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if(objContext != null && objContext.trim().length() > 0)
k = Integer.parseInt(objContext);
System.out.println("FORM NO:::" + k);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("****************ITEMCHANGE FOR CASE"+k+"*******************");
switch(k)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
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_defaultedit"))
{
reportToAdmin = genericUtility.getColumnValue("report_to__admin", dom);
empLname = getFieldValue("emp_lname", "employee", "emp_code", reportToAdmin, conn);
empFname = getFieldValue("emp_fname", "employee", "emp_code", reportToAdmin, conn);
valueXmlString.append("<admin_lname>").append("<![CDATA[" + empLname + "]]>").append("</admin_lname>");
valueXmlString.append("<admin_fname>").append("<![CDATA[" + empFname + "]]>").append("</admin_fname>");
}
if(currentColumn.trim().equalsIgnoreCase("design_code"))
{
designCode = genericUtility.getColumnValue("design_code", dom);
descr = getFieldValue("designation", "designation", "design_code", designCode, conn);
descr = descr == null ? "" : descr;
valueXmlString.append("<designation>").append("<![CDATA[" + descr + "]]>").append("</designation>");
}
if(currentColumn.trim().equalsIgnoreCase("report_to__admin"))
{
reportToAdmin = genericUtility.getColumnValue("report_to__admin", dom);
empLname = getFieldValue("emp_lname", "employee", "emp_code", reportToAdmin, conn);
empFname = getFieldValue("emp_fname", "employee", "emp_code", reportToAdmin, conn);
valueXmlString.append("<admin_lname>").append("<![CDATA[" + empLname + "]]>").append("</admin_lname>");
valueXmlString.append("<admin_fname>").append("<![CDATA[" + empFname + "]]>").append("</admin_fname>");
}
if(currentColumn.trim().equalsIgnoreCase("contact_code"))
{
String lname ="",mname="",fname="";
int index=0;
contactCode = genericUtility.getColumnValue("contact_code", dom);
query =" Select name from contact where contact_code = '"+contactCode+"' " ;
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
System.out.println("Query Executed " + query+ "\n\n******************");
if(rs.next())
{
name = rs.getString("name");
}
rs.close();
pstmt.close();
System.out.println("name............................"+name);
empCode = genericUtility.getColumnValue("emp_code", dom);
if(empCode == null)
{
valueXmlString.append("<emp_code>").append("<![CDATA[" + contactCode + "]]>").append("</emp_code>");
}
StringTokenizer st = new StringTokenizer(name);
while (st.hasMoreTokens())
{
index++;
if(index == 1)fname = st.nextToken();
if(index == 2)mname = st.nextToken();
if(index == 3)lname = st.nextToken();
}
valueXmlString.append("<emp_fname>").append("<![CDATA[" + fname + "]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA[" + mname + "]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA[" + lname + "]]>").append("</emp_lname>");
}
if(currentColumn.trim().equalsIgnoreCase("grade_code"))
{
gradeCode = genericUtility.getColumnValue("grade_code", dom);
cadreCode = genericUtility.getColumnValue("cadre_code", dom);
if(cadreCode == null)
{
cadreCode = getFieldValue("cadre_code", "grade", "grade_code", gradeCode, conn);
cadreCode = cadreCode == null ? "" : cadreCode;
valueXmlString.append("<cadre_code>").append("<![CDATA[" + cadreCode + "]]>").append("</cadre_code>");
}
}
if(currentColumn.trim().equalsIgnoreCase("designation"))
{
designation = genericUtility.getColumnValue("designation", dom);
joinedAs = genericUtility.getColumnValue("joined_as", dom);
if(joinedAs == null)
{
joinedAs = designation ;
valueXmlString.append("<joined_as>").append("<![CDATA[" + joinedAs + "]]>").append("</joined_as>");
}
}
if(currentColumn.trim().equalsIgnoreCase("sex"))
{
sex = genericUtility.getColumnValue("sex", dom);
if("M".equalsIgnoreCase(sex))
{
valueXmlString.append("<name_prefix>").append("<![CDATA[" + "Mr" + "]]>").append("</name_prefix>");
}
else
{
valueXmlString.append("<name_prefix>").append("<![CDATA[" + "Ms" + "]]>").append("</name_prefix>");
}
}
if(currentColumn.trim().equalsIgnoreCase("cur_add1"))
{
curAdd1 = genericUtility.getColumnValue("cur_add1", dom);
perAdd1 = genericUtility.getColumnValue("per_add1", dom);
if(perAdd1 == null || perAdd1.trim().length() ==0)
{
perAdd1 = curAdd1;
}
valueXmlString.append("<per_add1>").append("<![CDATA[" + perAdd1 + "]]>").append("</per_add1>");
}
if(currentColumn.trim().equalsIgnoreCase("cur_add2"))
{
curAdd2 = genericUtility.getColumnValue("cur_add2", dom);
perAdd2 = genericUtility.getColumnValue("per_add2", dom);
if(perAdd2 == null || perAdd2.trim().length() ==0)
{
perAdd2 = curAdd2;
}
valueXmlString.append("<per_add2>").append("<![CDATA[" + perAdd2 + "]]>").append("</per_add2>");
}
if(currentColumn.trim().equalsIgnoreCase("cur_add3"))
{
curAdd3 = genericUtility.getColumnValue("cur_add3", dom);
perAdd3 = genericUtility.getColumnValue("per_add3", dom);
if(perAdd3 == null || perAdd3.trim().length() ==0)
{
perAdd3 = curAdd3;
}
valueXmlString.append("<per_add3>").append("<![CDATA[" + perAdd3 + "]]>").append("</per_add3>");
}
if(currentColumn.trim().equalsIgnoreCase("cur_city"))
{
curCity = genericUtility.getColumnValue("cur_city", dom);
perCity = genericUtility.getColumnValue("per_city", dom);
state = getFieldValue("state_code", "station", "descr", curCity, conn);
if(perCity == null || perCity.trim().length() ==0)
{
perCity = curCity;
}
valueXmlString.append("<per_city>").append("<![CDATA[" + perCity + "]]>").append("</per_city>");
valueXmlString.append("<per_state>").append("<![CDATA[" + state + "]]>").append("</per_state>");
valueXmlString.append("<cur_state>").append("<![CDATA[" + state + "]]>").append("</cur_state>");
if(state.trim().length() > 0)
{
valueXmlString.append("<cur_state protect = \"1\"></cur_state>");
}
else
{
valueXmlString.append("<cur_state protect = \"0\"></cur_state>");
}
}
if(currentColumn.trim().equalsIgnoreCase("cur_state"))
{
curState = genericUtility.getColumnValue("cur_state", dom);
perState = genericUtility.getColumnValue("per_state", dom);
if(perState == null || perState.trim().length() ==0)
{
perState = curState;
}
valueXmlString.append("<per_state>").append("<![CDATA[" + perState + "]]>").append("</per_state>");
}
if(currentColumn.trim().equalsIgnoreCase("cur_pin"))
{
curPin = genericUtility.getColumnValue("cur_pin", dom);
perPin = genericUtility.getColumnValue("per_pin", dom);
if(perPin == null || perPin.trim().length() ==0)
{
perPin = curPin;
}
valueXmlString.append("<per_state>").append("<![CDATA[" + perPin + "]]>").append("</per_state>");
}
if(currentColumn.trim().equalsIgnoreCase("cur_tel1"))
{
curTel1 = genericUtility.getColumnValue("cur_tel1", dom);
perTel = genericUtility.getColumnValue("per_tel", dom);
if(perTel == null || perTel.trim().length() ==0)
{
perTel = curTel1;
}
valueXmlString.append("<per_tel>").append("<![CDATA[" + perTel + "]]>").append("</per_tel>");
}
if(currentColumn.trim().equalsIgnoreCase("contact_city"))
{
contactCity = genericUtility.getColumnValue("contact_city", dom);
state = getFieldValue("state_code", "station", "descr", contactCity, conn);
valueXmlString.append("<contact_state>").append("<![CDATA[" + state + "]]>").append("</contact_state>");
}
if(currentColumn.trim().equalsIgnoreCase("training_prd"))
{
empCode = genericUtility.getColumnValue("emp_code", dom);
probationFlag = genericUtility.getColumnValue("probation", dom);
confirmedFlag = genericUtility.getColumnValue("confirmed", dom);
trainingPrdStr = genericUtility.getColumnValue("training_prd", dom);
trainingPrdStr = trainingPrdStr == null ? "0" :trainingPrdStr;
probationPrdStr = genericUtility.getColumnValue("probation_prd", dom);
probationPrdStr = probationPrdStr == null ? "0" :probationPrdStr;
dateJoin = genericUtility.getColumnValue("date_join", dom);
dateJoin= genericUtility.getValidDateString(dateJoin,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) ;
dateJoinTs =java.sql.Timestamp.valueOf( dateJoin+ " 00:00:00.0");
trainingPrd =Integer.parseInt(trainingPrdStr);
probationPrd =Integer.parseInt(probationPrdStr);
if(trainingPrd == 0)
{
date = dateJoinTs ;
}
else
{//UtilMethods
date = utilMethods.AddMonths(dateJoinTs,trainingPrd);
}
dateStr = getAppDateFormat(date);
valueXmlString.append("<probation_date>").append("<![CDATA[" + dateStr + "]]>").append("</probation_date>");
if( probationPrdStr != null )
{
date = utilMethods.AddMonths(date,probationPrd);
}
dateStr = getAppDateFormat(date);
valueXmlString.append("<date_conf>").append("<![CDATA[" + dateStr + "]]>").append("</date_conf>");
if(trainingPrd ==0)
{
probationFlag = "Y" ;
}
else
{
probationFlag = "N" ;
}
valueXmlString.append("<probation>").append("<![CDATA[" + probationFlag + "]]>").append("</probation>");
if(probationPrd == 0 && ( trainingPrd == 0 || "Y".equalsIgnoreCase(probationFlag)))
{
confirmedFlag = "Y" ;
}
else
{
confirmedFlag = "N" ;
}
valueXmlString.append("<probation>").append("<![CDATA[" + probationFlag + "]]>").append("</probation>");
valueXmlString.append("<confirmed>").append("<![CDATA[" + confirmedFlag + "]]>").append("</confirmed>");
}
if(currentColumn.trim().equalsIgnoreCase("probation_prd"))
{
empCode = genericUtility.getColumnValue("emp_code", dom);
probationFlag = genericUtility.getColumnValue("probation", dom);
confirmedFlag = genericUtility.getColumnValue("confirmed", dom);
trainingPrdStr = genericUtility.getColumnValue("training_prd", dom);
probationPrdStr = genericUtility.getColumnValue("probation_prd", dom);
probationDateStr = genericUtility.getColumnValue("probation_date", dom);
trainingPrd = Integer.parseInt(trainingPrdStr);
probationPrd = Integer.parseInt(probationPrdStr);
if(probationDateStr != null )
{
probationDateStr= genericUtility.getValidDateString(probationDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) ;
probationDate =java.sql.Timestamp.valueOf( probationDateStr+ " 00:00:00.0");
}
if(probationPrd ==0)
{
date = probationDate;
}
else
{
date = utilMethods.AddMonths(probationDate,probationPrd);
}
dateStr = getAppDateFormat(date);
valueXmlString.append("<date_conf>").append("<![CDATA[" + dateStr + "]]>").append("</date_conf>");
if(probationPrd ==0 && (trainingPrd == 0 || "Y".equalsIgnoreCase(probationFlag)))
{
confirmedFlag ="Y";
}
else
{
confirmedFlag ="N";
}
valueXmlString.append("<confirmed>").append("<![CDATA[" + confirmedFlag + "]]>").append("</confirmed>");
}
if(currentColumn.trim().equalsIgnoreCase("date_join"))
{
dateJoinStr = genericUtility.getColumnValue("date_join", dom);
//gratuityDateStr = genericUtility.getColumnValue("gratuity_date", dom);
trainingPrdStr = genericUtility.getColumnValue("training_prd", dom);
valueXmlString.append("<gratuity_date>").append("<![CDATA[" + gratuityDateStr + "]]>").append("</gratuity_date>");
trainingPrdStr =trainingPrdStr == null ? "0" :trainingPrdStr;
trainingPrd = Integer.parseInt(trainingPrdStr);
dateJoinStr= genericUtility.getValidDateString(dateJoinStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) ;
dateJoinTs = java.sql.Timestamp.valueOf( dateJoinStr+ " 00:00:00.0");
if(trainingPrd == 0)
{
date = dateJoinTs;
}
else
{
date = utilMethods.AddMonths(dateJoinTs,trainingPrd);
}
dateStr = getAppDateFormat(date);
valueXmlString.append("<probation_date>").append("<![CDATA[" + dateStr + "]]>").append("</probation_date>");
probationPrdStr = genericUtility.getColumnValue("probation_prd", dom);
probationDateStr = genericUtility.getColumnValue("probation_date", dom);
probationPrdStr =probationPrdStr == null ? "0" :probationPrdStr;
probationPrd = Integer.parseInt(probationPrdStr);
if(probationDateStr != null)
{
probationDateStr= genericUtility.getValidDateString(probationDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) ;
probationDate = java.sql.Timestamp.valueOf( probationDateStr+ " 00:00:00.0");
}
if(probationPrd == 0)
{
date = probationDate;
}
else
{
date = utilMethods.AddMonths(probationDate,probationPrd);
}
dateStr = getAppDateFormat(date);
valueXmlString.append("<date_conf>").append("<![CDATA[" + dateStr + "]]>").append("</date_conf>");
if(trainingPrd == 0)
{
probationFlag = "Y";
}
else
{
probationFlag = "N";
}
if(probationPrd == 0 && trainingPrd == 0 )
{
confirmedFlag ="Y";
}
else
{
confirmedFlag ="N";
}
valueXmlString.append("<probation>").append("<![CDATA[" + probationFlag + "]]>").append("</probation>");
valueXmlString.append("<confirmed>").append("<![CDATA[" + confirmedFlag + "]]>").append("</confirmed>");
}
if(currentColumn.trim().equalsIgnoreCase("emp_site"))
{
mcode = genericUtility.getColumnValue("emp_site", dom);
paySite = genericUtility.getColumnValue("pay_site", dom);
if(paySite == null || paySite.length() ==0 )
{
paySite = mcode;
valueXmlString.append("<pay_site>").append("<![CDATA[" + paySite + "]]>").append("</pay_site>");
}
workSite = genericUtility.getColumnValue("work_site", dom);
if(workSite == null || workSite.length() ==0 )
{
workSite = mcode;
valueXmlString.append("<work_site>").append("<![CDATA[" + workSite + "]]>").append("</work_site>");
}
}
if(currentColumn.trim().equalsIgnoreCase("pay_mode"))
{
mcode = genericUtility.getColumnValue("pay_mode", dom);
mcode = mcode.trim();
if("C".equalsIgnoreCase(mcode))
{
valueXmlString.append("<bank_code>").append("<![CDATA[" + "" + "]]>").append("</bank_code>");
valueXmlString.append("<bank_acct>").append("<![CDATA[" + "" + "]]>").append("</bank_acct>");
}
else if(! ("D".equalsIgnoreCase(mcode) ) )
{
valueXmlString.append("<dd_payable_bank>").append("<![CDATA[" + "" + "]]>").append("</dd_payable_bank>");
}
}
if(currentColumn.trim().equalsIgnoreCase("emp_class"))
{
mcode = genericUtility.getColumnValue("emp_class", dom);
query =" Select descr from gencodes where fld_name = 'EMP_CLASS' "
+" and fld_value = '"+mcode+"' " ;
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + query+ "\n\n******************");
if(rs.next())
{
descr = rs.getString("descr");
}
rs.close();
pstmt.close();
System.out.println("descr--------------"+descr);
valueXmlString.append("<class_descr>").append("<![CDATA[" + descr + "]]>").append("</class_descr>");
}
if(currentColumn.trim().equalsIgnoreCase("occupation_code"))
{
mcode = genericUtility.getColumnValue("design_code", dom);
query =" Select descr from gencodes where fld_name = 'OCCUPATION_CODE' "
+" and fld_value = '"+mcode+"' " ;
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + query+ "\n\n******************");
if(rs.next())
{
descr = rs.getString("descr");
}
rs.close();
pstmt.close();
System.out.println("descr--------------"+descr);
valueXmlString.append("<occ_descr>").append("<![CDATA[" + descr + "]]>").append("</occ_descr>");
}
valueXmlString.append("</Detail1 >");
System.out.println("itemchange string :::" +valueXmlString);
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
int childListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn.trim()))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
}
while(ctr < childListLength && !childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
//valueXmlString.append("<operation protect=\"0\"></operation>");
//valueXmlString.append("<exp_lev protect=\"0\"></exp_lev>");
}
valueXmlString.append("</Detail2>");
break;
case 3 :
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail3>");
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"))
{
//exp_levdom = getColumnValue("exp_lev",dom,"2");
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
}
valueXmlString.append("</Detail3 >");
break;
case 4 :
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail4>");
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"))
{
//exp_levdom = getColumnValue("exp_lev",dom,"2");
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
}
valueXmlString.append("</Detail4 >");
break;
case 5 :
parentNodeList = dom.getElementsByTagName("Detail5");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail5>");
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"))
{
//exp_levdom = getColumnValue("exp_lev",dom,"2");
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
}
valueXmlString.append("</Detail5>");
break;
case 6 :
parentNodeList = dom.getElementsByTagName("Detail6");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail6>");
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"))
{
//exp_levdom = getColumnValue("exp_lev",dom,"2");
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
}
valueXmlString.append("</Detail6>");
System.out.println("itemchange string :::" +valueXmlString);
break;
case 7 :
parentNodeList = dom.getElementsByTagName("Detail7");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail7>");
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"))
{
//exp_levdom = getColumnValue("exp_lev",dom,"2");
empCode = genericUtility.getColumnValue("emp_code",dom1) == null ? "" : genericUtility.getColumnValue("emp_code",dom1);
System.out.println("empCode is :::::"+empCode );
valueXmlString.append("<emp_code>").append("<![CDATA[" + empCode + "]]>").append("</emp_code>");
}
if(currentColumn.trim().equalsIgnoreCase("bank_code"))
{
mcode = genericUtility.getColumnValue("bank_code", dom);
descr = getFieldValue("bank_name", "bank", "bank_code", mcode, conn);
descr = descr == null ? "" : descr;
valueXmlString.append("<bank_name>").append("<![CDATA[" + descr + "]]>").append("</bank_name>");
}
valueXmlString.append("</Detail7>");
System.out.println("itemchange string :::" +valueXmlString);
break;
}// switch end
valueXmlString.append("</Root>");
}// try end
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
conn.close();
conn = null;
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
System.out.println("[EmpComplete] Connection is Closed");
System.out.println("valueXmlString:::::" + valueXmlString.toString());
return valueXmlString.toString();
}
private String getAppDateFormat(Timestamp timestamp)
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in [EmpComplete] getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
private String getFieldValue(String column,String tableName, String columnName, String columnValue,Connection conn)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String value = null;
String sql = null;
sql = " select "+column+" from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + sql+ "\n\n******************");
if(rs.next())
{
value = rs.getString(1) != null ? rs.getString(1) : " ";
}
else
{
value = " ";
}
rs.close();
pstmt.close();
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return value;
}
private int isValueExist(String tableName, String columnName, String columnValue,Connection conn)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int cnt = 0 ;
sql = " select count(1) as count from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + sql+ "\n\n******************");
if(rs.next())
{
cnt = rs.getInt("count");
}
rs.close();
pstmt.close();
System.out.println("cnt--------------"+cnt);
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return cnt;
}
private java.util.Date getRelativeDate(java.util.Date date, int n )
{
try
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(cal.DATE, n);
date = cal.getTime();
System.out.println("********Relative Date " + date+"************************** ");
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return date ;
}
public String getEnv(String prdCode, String varName,Connection conn)
{
String retValue = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = "SELECT VAR_VALUE FROM PAYRPARM "
+ "WHERE PRD_CODE = '" + prdCode + "' AND VAR_NAME = '" + varName + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
retValue = rs.getString(1);
}
else
{
retValue = "NULLFOUND";
}
rs.close();
pstmt.close();
}
catch (SQLException se)
{
System.out.println("Exception : :getEnvFin:" + se.getMessage() + ":");
se.printStackTrace();
}
catch (Exception e)
{
System.out.println("Exception : :getEnvFin:" + e.getMessage() + ":");
e.printStackTrace();
}
return retValue;
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
return input;
}
}
/*
* Remote Interface for ReallocationEJB Added by Jaimin 13/09/2007
*/
package ibase.webitm.ejb.adm;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.Document;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface EmpCompleteLocal extends ValidatorLocal //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/*
* Remote Interface for ReallocationEJB Added by Jaimin 13/09/2007
*/
package ibase.webitm.ejb.adm;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.Document;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface EmpCompleteRemote extends ValidatorRemote //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ 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