package ibase.webitm.ejb.adm;

import java.rmi.RemoteException;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;

import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3

@Stateless // added for ejb3
public class AttendancePrc extends ValidatorEJB implements  AttendancePrcLocal,AttendancePrcRemote //SessionBean
{
	GenericUtility genericUtility = GenericUtility.getInstance();
	ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
	
	/*public void ejbCreate() throws RemoteException, CreateException
	{
		System.out.println("Entering into AttendancesEJB.............");
	}
	public void ejbRemove()
	{
	}
	public void ejbActivate()
	{
	}
	public void ejbPassivate()
	{
	}*/
	public String wfValData() throws RemoteException,ITMException
	{
		System.out.println(">>>>>>>>>  IN wfValData 1");
		return "";
	}

	public String itemChanged() throws RemoteException,ITMException
	{
			System.out.println(">>>>>>  default itemChanged called");
		return "";
	}
	

	public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
	{
			System.out.println(">>>>>>  1 itemChanged called");
		Document dom = null;
		Document dom1 = null;
		Document dom2 = null;
		String valueXmlString = "";
		try
		{
		    System.out.println("xmlString :" + xmlString);
		    dom = parseString(xmlString); //returns the DOM Object for the passed XML Stirng
		    System.out.println("xmlString1 :" + xmlString1);
			dom1 = parseString(xmlString1); //returns the DOM Object for the passed XML Stirng
			System.out.println("xmlString2 :" + xmlString2);
			System.out.println("xtraParams :" + xtraParams);
			
			if (xmlString2.trim().length() > 0 )
			{
			//	dom2 = parseString("<Root>" + xmlString2+ "</Root>");
				dom2 = parseString(xmlString2);
			}
			valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
		}
		catch(Exception e)
		{
			System.out.println("Exception : [AttendancesEJB][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
	{
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		
		String sql = "";
		String  empfname="";
		String  empmname="";
		String  emplname="";		
		int childListLength=0;
		NodeList parentNodeList = null;
		NodeList childNodeList = null;
		Node parentNode = null;
		Node childNode = null;
		System.out.println("itemChanged  called");
		String loginSite = "";
		String empCode = null;
		String siteCode = null;
		String procGroup = null;
		String frProcGr = null;
		String prdCode = null;
		String pdCode = null;
		String prdCodeDescr = null;
		String todate = null;
		String dateTo = null;
		String toSiteCodeDescr = null;
		String frSiteCodeDescr = null;
		String pdDescr = null;
		StringBuffer valueXmlString = null; 
		int currentFormNo = 0;

		String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
		System.out.println("userId ::-"+userId);
		loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
		System.out.println("loginSiteCode ::-"+loginSite+":");
		try
		{
			conn = getConnection();
					
			if(objContext != null && objContext.trim().length()>0)
			{
				currentFormNo = Integer.parseInt(objContext);
			}
			valueXmlString = new StringBuffer("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?><Root><header><editFlag>");
			valueXmlString.append(editFlag).append("</editFlag></header>");
			System.out.println(">>>>>>>>>>>.. currentFormNo "+currentFormNo);
			System.out.println(">>>>>>>>>>>.. currentColumn "+currentColumn);
			switch (currentFormNo)
			{
					case 1:
						parentNodeList = dom1.getElementsByTagName("Detail1");
						parentNode = parentNodeList.item(0);
						childNodeList = parentNode.getChildNodes();
						valueXmlString.append("<Detail1>");			
						if(currentColumn.trim().equals("itm_default"))
						{
							sql = "SELECT SH_DESCR FROM SITE WHERE SITE_CODE = '"+loginSite+"'";
							System.out.println("SQL :: "+sql);
														
							stmt = conn.createStatement();
							rs = stmt.executeQuery(sql);
													
							if(rs.next())
							{
								toSiteCodeDescr=rs.getString("SH_DESCR");
							}
							
							Calendar cal=Calendar.getInstance();
							Date date=cal.getTime();
							SimpleDateFormat dateFormat=new SimpleDateFormat(genericUtility.getApplDateFormat());
							SimpleDateFormat yearFormat=new SimpleDateFormat("yyyy");
							SimpleDateFormat monthFormat=new SimpleDateFormat("MM");
							SimpleDateFormat monthFormatstr=new SimpleDateFormat("MMM");
							String yearStr=yearFormat.format(date);
							String dateStr=dateFormat.format(date);
							String monthNum=monthFormat.format(date);
							String monthStr=monthFormatstr.format(date);
							System.out.println(" yearStr "+yearStr);
							System.out.println("  monthStr "+monthNum);
							System.out.println("  monthStr "+monthStr);
							valueXmlString.append("<payroll_date><![CDATA[").append(dateStr).append("]]></payroll_date>\r\n");
						//	valueXmlString.append("<cutoff_date>").append(dateStr).append("</cutoff_date>\r\n");
							//valueXmlString.append("<emp_code__fr>").append("A").append("</emp_code__fr>\r\n");
							//valueXmlString.append("<emp_code__to>").append("ZZ").append("</emp_code__to>\r\n");
						//	valueXmlString.append("<proc_group__from>").append("A").append("</proc_group__from>\r\n");
						//	valueXmlString.append("<proc_group__to>").append("ZZ").append("</proc_group__to>\r\n");
							valueXmlString.append("<no_days><![CDATA[").append("0").append("]]></no_days>\r\n");
							valueXmlString.append("<site_code__fr><![CDATA[").append(loginSite).append("]]></site_code__fr>\r\n");
							valueXmlString.append("<site_code__to><![CDATA[").append(loginSite).append("]]></site_code__to>\r\n");
						//	valueXmlString.append("<prd_code__fr>").append(yearStr).append(monthNum).append("</prd_code__fr>\r\n");
						//	valueXmlString.append("<fr_prd_descr>").append(monthStr).append(yearStr).append("</fr_prd_descr>\r\n");
						
							
						
							//stmt.close();
						
							//rs.close();
						
							valueXmlString.append("<to_site_descr><![CDATA[").append(toSiteCodeDescr).append("]]></to_site_descr>\r\n");
							valueXmlString.append("<fr_site_descr><![CDATA[").append(toSiteCodeDescr).append("]]></fr_site_descr>\r\n");
							toSiteCodeDescr=null;
							sql="SELECT PRD_CODE FROM PARAMETER";
							System.out.println("SQL :: "+sql);
							
							stmt = conn.createStatement();
							rs = stmt.executeQuery(sql);
						
							if(rs.next())
							{
								prdCode=rs.getString("PRD_CODE");
							}
							 stmt.close();
							rs.close();
							valueXmlString.append("<prd_code__fr><![CDATA[").append(prdCode).append("]]></prd_code__fr>\r\n");
							sql="SELECT DESCR,TO_DATE FROM PERIOD WHERE CODE = '"+prdCode+"'";
							stmt = conn.createStatement();
							rs = stmt.executeQuery(sql);
							if(rs.next())
							{
								prdCodeDescr=rs.getString("DESCR");
								todate=rs.getString("TO_DATE");
							}
							stmt.close();
							rs.close();
							valueXmlString.append("<fr_prd_descr><![CDATA[").append(prdCodeDescr).append("]]></fr_prd_descr>\r\n");
							valueXmlString.append("<cutoff_date><![CDATA[").append(todate).append("]]></cutoff_date>\r\n");
							valueXmlString.append("<no_days protect=\"1\"></no_days>\r\n");
						}
						else if(currentColumn.trim().equals("emp_code__fr"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  empCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("emp_code__fr".equals(empCodeNode))
								{
									empCode=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  empCode : "+empCode);
									 break;
								}
								ctr++;
							}
							if(empCode!= null)
							{
								sql = "SELECT EMP_FNAME,EMP_LNAME  FROM EMPLOYEE  WHERE EMP_CODE = '"+empCode+"'" ;
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if(rs.next())
								{
									empfname=rs.getString("EMP_FNAME");
									emplname=rs.getString("EMP_LNAME");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<emp_name__fr><![CDATA[").append(empfname).append(emplname).append("]]></emp_name__fr>\r\n");
	
							}


						}
						else if(currentColumn.trim().equals("emp_code__to"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  empCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("emp_code__to".equals(empCodeNode))
								{
									empCode=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  empCode : "+empCode);
									 break;
								}
								ctr++;
							}
							if(empCode!= null)
							{
								sql = "SELECT EMP_FNAME,EMP_LNAME  FROM EMPLOYEE  WHERE EMP_CODE = '"+empCode+"'" ;
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									empfname=rs.getString("EMP_FNAME");
									emplname=rs.getString("EMP_LNAME");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<emp_name__to><![CDATA[").append(empfname).append(emplname).append("]]></emp_name__to>\r\n");
	
							}
						}
						else if(currentColumn.trim().equals("site_code__fr"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  siteCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("site_code__fr".equals(siteCodeNode))
								{
									siteCode=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  siteCode : "+siteCode);
									 break;
								}
								ctr++;
							}
							if(siteCode!= null)
							{
								sql = "SELECT SH_DESCR  FROM SITE  WHERE SITE_CODE = '"+siteCode+"'" ;
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									frSiteCodeDescr=rs.getString("sh_descr");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<fr_site_descr><![CDATA[").append(frSiteCodeDescr).append("]]></fr_site_descr>\r\n");
	
							}
						}
						else if(currentColumn.trim().equals("site_code__to"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  siteCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("site_code__to".equals(siteCodeNode))
								{
									siteCode=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  siteCode : "+siteCode);
									 break;
								}
								ctr++;
							}
							if(siteCode!= null)
							{
								sql = "SELECT sh_descr  FROM site  WHERE site_code = '"+siteCode+"'" ;
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									toSiteCodeDescr=rs.getString("sh_descr");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<to_site_descr><![CDATA[").append(toSiteCodeDescr).append("]]></to_site_descr>\r\n");
								toSiteCodeDescr=null;
							}
						}
						else if(currentColumn.trim().equals("proc_group__from"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  siteCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("proc_group__from".equals(siteCodeNode))
								{
									procGroup=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  procGroup : "+procGroup);
									 break;
								}
								ctr++;
							}
							if(procGroup!= null)
							{
								sql = "SELECT descr  FROM gencodes  WHERE fld_value = '"+procGroup+"'" ;
								System.out.println(">>>>>>> sql "+sql);
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									frProcGr=rs.getString("descr");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<from_p_group_descr><![CDATA[").append(frProcGr).append("]]></from_p_group_descr>\r\n");
	
							}
						}
						else if(currentColumn.trim().equals("proc_group__to"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  siteCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("proc_group__to".equals(siteCodeNode))
								{
									procGroup=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  procGroup : "+procGroup);
									 break;
								}
								ctr++;
							}
							if(procGroup!= null)
							{
								sql = "SELECT descr  FROM gencodes  WHERE fld_value = '"+procGroup+"'" ;
								System.out.println(">>>>>>> sql "+sql);
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									frProcGr=rs.getString("descr");
								}
								stmt.close();
								rs.close();
								valueXmlString.append("<to_p_group_descr><![CDATA[").append(frProcGr).append("]]></to_p_group_descr>\r\n");
	
							}
						}
						else if(currentColumn.trim().equals("prd_code__fr"))
						{
							int ctr = 0;
							childListLength = childNodeList.getLength();
							while(ctr<childListLength)
							{
								String  prdCodeNode=childNodeList.item(ctr).getNodeName();
	
								if("prd_code__fr".equals(prdCodeNode))
								{
									 pdCode=childNodeList.item(ctr).getFirstChild().getNodeValue();
									 System.out.println("  pdCode : "+pdCode);
									 break;
								}
								ctr++;
							}
							if(pdCode!= null)
							{
								sql="SELECT descr,to_date FROM period WHERE code = '"+pdCode+"'";
								System.out.println(">>>>>>> sql "+sql);
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								while(rs.next())
								{
									pdDescr=rs.getString("descr");
									dateTo=rs.getString("to_date");
									if(dateTo.indexOf(' ')!=-1)
									{
										dateTo=dateTo.substring(0,dateTo.indexOf(' '));
									}
								}
						/*		if(dateTo != null)
								{
									dateTo=dateTo.replace('-','/');
									SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd"); 
									Date startDate = simpleDateFormat.parse(dateTo);
									dateTo=startDate.toString();
								}  */
	
								stmt.close();
								rs.close();
								valueXmlString.append("<fr_prd_descr><![CDATA[").append(pdDescr).append("]]></fr_prd_descr>\r\n").append("<cutoff_date>").append(dateTo).append("</cutoff_date>\r\n");
						//		valueXmlString.append("<cutoff_date>").append(dateTo).append("</cutoff_date>\r\n");
	
							}
						}	
					valueXmlString.append("</Detail1>\r\n");
					break;
			}
			valueXmlString.append("</Root>");
		}
		catch(Exception e)
		{
			System.out.println("Exception :[][itemChanged::case 1:] :==>\n"+e.getMessage());
			e.printStackTrace();
			throw new ITMException(e);
		}
		finally
		{
			try
			{
				if(conn != null)
				{
					conn.close();
				}
			}
			catch(Exception ex)
			{
				System.out.println("Exception ::"+ex.getMessage());
				ex.printStackTrace();
			}


		}
		System.out.println(" valueXmlString.toString() "+valueXmlString.toString());
		return valueXmlString.toString();
	}
	
	public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
	{
		System.out.println(" IN wfValData 2");
		Document dom = null;  
		Document dom1 = null;
		Document dom2 = null;
		String  errString = null;
		System.out.println(" xmlString  "+xmlString);
		System.out.println(" xmlString1  "+xmlString1);
		System.out.println(" xmlString2  "+xmlString2);
		System.out.println("Entering into  validations ...................");
		try
		{
			dom = parseString(xmlString);
			dom1 = parseString(xmlString1);
			if (xmlString2.trim().length() > 0 )
			{
				//dom2 = parseString("<Root>" + xmlString2+ "</Root>"); manoj 24/07/06
				dom2 = parseString(xmlString2);
			}
			errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
		}
		catch(Exception e)
		{
			System.out.println("Exception : PayableOpeningsEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
		}
		return (errString);
	}
	public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
	{
		String errCode = "";
		Connection conn = null;
		Statement stmt = null;
		NodeList parentNodeList = null;
		NodeList childNodeList = null;
		Node parentNode = null;
		Node childNode = null;
		String childNodeName = "";
		String childNodeValue;
		String  errString = "";
		int currentFormNo = 0;
		int childNodeListLength;
		ResultSet rs = null;
		String sql = "";
		String userId = "";
		int cnt;
		ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
		userId = getValueFromXTRA_PARAMS(xtraParams,"userId");
		try
		{
			conn = getConnection();
			if(objContext != null && objContext.trim().length()>0)
			{
				currentFormNo = Integer.parseInt(objContext);
			}
			System.out.println("  currentFormNo "+currentFormNo);
			switch(currentFormNo)
			{
				case 1:
				{
					parentNodeList = dom1.getElementsByTagName("Detail2");
					parentNode = parentNodeList.item(0);
					childNodeList = parentNode.getChildNodes();
					childNodeListLength = childNodeList.getLength();
					for(int ctr = 0; ctr < childNodeListLength; ctr++)
					{
						childNode = childNodeList.item(ctr);
						childNodeName = childNode.getNodeName();
						childNodeValue=null;
						if(childNode.getFirstChild()!=null)
						{
							childNodeValue = childNode.getFirstChild().getNodeValue();
						}
						System.out.println(" childNodeName "+childNodeName);
						System.out.println("childNodeValue "+childNodeValue);
						if ("prd_code__fr".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VPDNULL";
								errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT FROM period WHERE code = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(" cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VPRDCODE";
										errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}
			/*			else
						if ("emp_code__fr".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VECFRNULL";
								errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT FROM Employee WHERE emp_code = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println("  cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VEMPCODEFR";
										errString = itmDBAccessEJB.getErrorString("emp_code__fr",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();

							}

						}
						else
						if ("emp_code__to".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VECTONULL";
								errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT FROM Employee WHERE emp_code = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(" cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VEMPCODETO";
										errString = itmDBAccessEJB.getErrorString("emp_code__to",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}
						else
						if ("site_code__fr".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VSCFRNUL";
								errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT FROM Site WHERE site_code = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(">>>>>>>>>  cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VSITCDFR";
										errString = itmDBAccessEJB.getErrorString("site_code__fr",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}
						else
						if ("site_code__to".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VSCTONUL";
								errString = itmDBAccessEJB.getErrorString("prd_code__fr",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT FROM Site WHERE site_code = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(">>>>>>>>>  cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VSITCDTO";
										errString = itmDBAccessEJB.getErrorString("site_code__to",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}
						else
						if ("proc_group__from".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VPRGFNUL";
								errString = itmDBAccessEJB.getErrorString("proc_group__from",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT from gencodes where fld_value = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(">>>>>>>>>  cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VPRGRFR";
										errString = itmDBAccessEJB.getErrorString("proc_group__from",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}
						else
						if ("proc_group__to".equals(childNodeName))
						{
							if(childNodeValue==null)
							{
								errCode = "VPRGTONUL";
								errString = itmDBAccessEJB.getErrorString("proc_group__to",errCode,userId);
								break;
							}
							else
							{
								sql = "SELECT COUNT(*) AS COUNT from gencodes where fld_value = '"+childNodeValue+"'";
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);
								if (rs.next())
								{
									 cnt = rs.getInt("COUNT");
									System.out.println(">>>>>>>>>  cnt  "+cnt);
									if (cnt == 0)
									{
										errCode = "VPRGRTO";
										errString = itmDBAccessEJB.getErrorString("proc_group__to",errCode,userId);
										break;
									}
								}
								stmt.close();
								rs.close();
							}

						}   */
					}
				}
			}
		}
		catch(Exception e)
		{
			System.out.println("Exception ::"+e);
			e.printStackTrace();
			errString = e.getMessage();
			throw new ITMException(e);
		}					
		finally
		{
			try
			{
				if(conn != null)
				{
					conn.close();
				}
			}
			catch(Exception ex)
			{
				System.out.println("Exception ::"+ex.getMessage());
				ex.printStackTrace();
			}


		}
		System.out.println(">>>>>>>>>  IN wfValData 3");
		return errString;		
	}
}