Commit 9e807640 authored by sghate's avatar sghate

Shital: Updated component on 07-10-2019

SiteItDeclAprvr.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@209051 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a4dfbcad
package ibase.webitm.ejb.adm;
//modified by Shital on 02/08/2019 [Start]
//import ibase.system.config.ConnDriver;
//modified by Shital on 02/08/2019 [End]
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
//modified by Shital on 02/08/2019 [Start]
//import ibase.webitm.ejb.sys_UTL.CreateXmlObject;
//modified by Shital on 02/08/2019 [End]
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
//modified by Shital on 02/08/2019 [Start]
//import ibase.utility.*;
//modified by Shital on 02/08/2019 [End]
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
//modified by Shital on 02/08/2019 [Start]
//import javax.ejb.Stateless;
//import java.util.*;
//modified by Shital on 02/08/2019 [End]
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.text.SimpleDateFormat;
//modified by Shital on 02/08/2019 [Start]
//@Stateless
//modified by Shital on 02/08/2019 [Start]
public class SiteItDeclAprvr extends ValidatorEJB implements SiteItDeclAprvrRemote, SiteItDeclAprvrLocal
{
//modified by Shital on 02/08/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//modified by Shital on 02/08/2019 [Start]
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
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString="";
//modified by Shital on 02/08/2019 [Start]
//GenericUtility genericUtility =GenericUtility.getInstance();
//modified by Shital on 02/08/2019 [End]
try
{
System.out.println("apr: wfdatavalue of string["+xmlString+"]");
System.out.println("apr: wfdatavalue of string["+xmlString1+"]");
System.out.println("apr: wfdatavalue of string["+xmlString2+"]");
if(xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValdata(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println ("error string:" + errString);
}
catch (Exception e)
{
System.out.println ("Exception: apr: wfValData(String xmlString): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
//modified by Shital on 02/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 02/08/2019 [End]
}
System.out.println ("Returning from apr wfValData" +errString);
return (errString);
}
public String wfValdata(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
// String fname="";
// String mname="";
// String lname="";
//String sitedesc="";
//String empcodeaprvdesc="";
String sitecode = "";
//String emp_aprv="";
String empAprv = "";
String emailid = "";
// String chgDate="";
// String chgUser="";
// String chgTerm="";
String msgType = "";
String errCode = "";
String errFldName = "";
String sql = "";
// String descrip="";
String UserId = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int cnt = 0;
Connection connection = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int errListSize;
// int parentNodeListLength=0;
int childNodeListLength = 0;
int count = 0;
int ctr = 0;
//int noOfChilds = 0;
int currentFormNo = 0;
// String status="";
// String ecStatus="";
String errString = "";
//Modified by Ahmed on 08/NOV/2016[A16FSUN003][START]
String empAprvAlt1 = "";
String empAprvAlt2 = "";
int rowCnt = 0;
int siteCnt = 0 ;
int mstrCtr = 0;
Timestamp relieveDate = null;
//Modified by Ahmed on 08/NOV/2016[A16FSUN003][END]
System.out.println("editFlag..wfVal data.["+editFlag+"]");
//modified by Shital on 02/08/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital on 02/08/2019 [End]
try
{
//modified by Shital on 02/08/2019 [Start]
//ConnDriver connDriver = null;
//connDriver = new ConnDriver();
//connection = connDriver.getConnectDB("Driver");
connection = getConnection();
//modified by Shital on 02/08/2019 [End]
connection.setAutoCommit(false);
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch ( currentFormNo )
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail"+currentFormNo);
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
System.out.println("childNode"+childNode);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("site_code"))
{
count = 0;
sitecode = checkNull(genericUtility.getColumnValue("site_code",dom,objContext));
System.out.println("sitecode got in the validation ..::["+sitecode+"]");
if(sitecode == null || sitecode.trim().length() == 0)
{
System.out.println("Invalid sitecode ::::");
errList.add( "VMINVSITE1" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINVSITE1" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
//10/02/2015 Start
//modified by Shital on 02/08/2019 [Start]
//int siteCnt = 0 ;
//modified by Shital on 02/08/2019 [End]
sql = " SELECT COUNT(*) AS SITE_CNT FROM SITE WHERE SITE_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,sitecode);
rs = pstmt.executeQuery();
if( rs.next())
{
siteCnt = rs.getInt("SITE_CNT");
}
System.out.println("siteCnt:::: "+siteCnt);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(siteCnt == 0)
{
System.out.println("Invalid sitecode , Can not enter duplicate site code::::");
errList.add( "VMINVSITE3" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINVSITE3" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
// 10/02/2015 End
sql = " SELECT COUNT(*) AS SITE_CODE_CNT FROM SITE_ITDECL_APRVR WHERE SITE_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,sitecode);
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getInt("SITE_CODE_CNT");
}
System.out.println("count:::: "+count);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (editFlag.equalsIgnoreCase("A"))
{
if(count > 0)
{
System.out.println("Invalid sitecode , Can not enter duplicate site code::::");
errList.add( "VMINVSITE2" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINVSITE2" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
else
{
if(count > 1)
{
System.out.println("Invalid sitecode , Can not enter duplicate site code::::");
errList.add( "VMINVSITE2" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINVSITE2" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
//modified by Shital on 07/10/2019 [Start]
//if(childNodeName.equalsIgnoreCase("emp_code_aprv"))
if(childNodeName.equalsIgnoreCase("emp_code__aprv"))
{
count = 0;
//modified by Shital on 02/08/2019 [Start]
//int mstrCtr = 0;
//modified by Shital on 02/08/2019 [End]
//empAprv = checkNull(genericUtility.getColumnValue("emp_code_aprv",dom,objContext));
empAprv = checkNull(genericUtility.getColumnValue("emp_code__aprv",dom,objContext));
//modified by Shital on 07/10/2019 [End]
System.out.println("employee Code got in the validation ..::["+empAprv+"]");
if(empAprv == null || empAprv.trim().length() == 0)
{
System.out.println("Invalid adCode ::::");
errList.add( "VMINECODE1" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINECODE1" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = "SELECT COUNT(*) AS EMP_CNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,empAprv);
rs = pstmt.executeQuery();
if( rs.next())
{
mstrCtr = rs.getInt("EMP_CNT");
}
System.out.println("ctr:::: "+mstrCtr);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(mstrCtr == 0)
{
System.out.println("Invalid employee Code , employee Code not defined in table::::");
errList.add( "VMINECODE3" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINECODE3" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
//Modified by Ahmed on 08/NOV/2016[A16FSUN003][START]
else
{
empAprvAlt1 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt1", dom, objContext));
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom, objContext));
if(empAprv.equalsIgnoreCase(empAprvAlt1))
{
errList.add( "VMITSITE06" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE06" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else if(empAprv.equalsIgnoreCase(empAprvAlt2))
{
errList.add( "VMITSITE08" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE08" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
//Modified by Ahmed on 08/NOV/2016[A16FSUN003][END]
}
}
else if(childNodeName.equalsIgnoreCase("email_id"))
{
emailid = checkNull(genericUtility.getColumnValue("email_id",dom,objContext));
System.out.println("emailid got in the validation ..::["+emailid+"]");
if(emailid == null || emailid.trim().length() == 0)
{
System.out.println("Invalid emailid ::::");
errList.add( "VMINEMLID1" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMINEMLID1" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
//Modified by Ahmed on 07/NOV/2016[START]
if(childNodeName.equalsIgnoreCase("emp_code__aprv_alt1"))
{
empAprvAlt1 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt1", dom, objContext));
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom, objContext));
System.out.println("empAprvAlt1 got in the validation ..::["+empAprvAlt1+"]");
if(empAprvAlt1 != null && empAprvAlt1.trim().length() > 0)
{
sql = "";
sql = "SELECT COUNT(*) AS EMP_ALT1_CNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, empAprvAlt1);
rs = pstmt.executeQuery();
rowCnt = 0;
if( rs.next())
{
rowCnt = rs.getInt("EMP_ALT1_CNT");
}
System.out.println("rowCnt:::: "+rowCnt);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(rowCnt == 0)
{
System.out.println("Invalid employee Code , employee Code not defined in table::::");
errList.add( "VMITSITE01" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE01" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom, objContext));
if(empAprvAlt1.equalsIgnoreCase(empAprvAlt2))
{
errList.add( "VMITSITE07" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE07" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = "";
relieveDate = null;
sql = "SELECT RELIEVE_DATE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, empAprvAlt1);
rs = pstmt.executeQuery();
if( rs.next())
{
relieveDate = rs.getTimestamp("RELIEVE_DATE");
}
System.out.println("relieveDate:::: "+relieveDate);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(relieveDate != null)
{
System.out.println("employee Code with relieveDate::::");
errList.add( "VMITSITE02" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE02" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
else
{
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom, objContext));
if(empAprvAlt2 != null && empAprvAlt2.trim().length() > 0)
{
errList.add( "VMITSITE03" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE03");
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
if(childNodeName.equalsIgnoreCase("emp_code__aprv_alt2"))
{
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom, objContext));
System.out.println("empAprvAlt2 got in the validation ..::["+empAprvAlt2+"]");
if(empAprvAlt2 != null && empAprvAlt2.trim().length() > 0)
{
sql = "";
sql = "SELECT COUNT(*) AS EMP_ALT2_CNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, empAprvAlt2);
rs = pstmt.executeQuery();
rowCnt = 0;
if( rs.next())
{
rowCnt = rs.getInt("EMP_ALT2_CNT");
}
System.out.println("rowCnt:::: "+rowCnt);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(rowCnt == 0)
{
System.out.println("Invalid employee Code , employee Code not defined in table::::");
errList.add( "VMITSITE04" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE04" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = "";
relieveDate = null;
sql = "SELECT RELIEVE_DATE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, empAprvAlt2);
rs = pstmt.executeQuery();
if( rs.next())
{
relieveDate = rs.getTimestamp("RELIEVE_DATE");
}
System.out.println("relieveDate:::: "+relieveDate);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(relieveDate != null)
{
System.out.println("employee Code with relieveDate::::");
errList.add( "VMITSITE05" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( connection , "VMITSITE05" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
//Modified by Ahmed on 07/NOV/2016[END]
}
}//End of case
break;
}
//End of Switch
errListSize = errList.size();
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = (String)errList.get(cnt);
errFldName = (String)errFields.get(cnt);
System.out.println("errCode .........."+errCode);
//modified by Shital on 02/08/2019 [Start]
//errString = getErrorString( errFldName, errCode, UserId );
errString = itmDBAccessEJB.getErrorString(errFldName, errCode, UserId, "", connection);
//modified by Shital on 02/08/2019 [End]
System.out.println("errString is : ::::>>>> " + errString);
msgType = errorType( connection , errCode );
if ( errString.length() > 0)
{
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}
catch(Exception e)
{
System.out.println( "Exception : [ItDeclarationFmt][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( connection != null )
{
connection.close();
connection = null;
}
}
catch(Exception e1)
{
e1.printStackTrace();
System.out.println( "Exception : [ItDeclarationFmt][wfValData] : ==>\n"+e1.getMessage());
throw new ITMException(e1);
}
}
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 errString="";
//modified by Shital on 02/08/2019 [Start]
//GenericUtility genericUtility =GenericUtility.getInstance();
//modified by Shital on 02/08/2019 [End]
try
{
System.out.println("apr: itemChanged of string["+xmlString+"]");
System.out.println("apr: itemChanged of string["+xmlString1+"]");
System.out.println("apr: itemChanged of string["+xmlString2+"]");
if(xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
//errString = wfValdata(dom,dom1,dom2,objContext,editFlag,xtraParams);
errString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);// throws RemoteException,ITMException;
System.out.println ("error string:" + errString);
}
catch (Exception e)
{
System.out.println ("Exception: apr: wfValData(String xmlString): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println ("Returning from apr wfValData" +errString);
return (errString);
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
//String objName="";
String errString = "";
//String site_itdecl_aprvr="";
String sql = "";
//String fname="";
//String mname="";
//String lname="";
String sitedesc = "";
String empcodeaprvdesc = "";
String sitecode = "";
String empAprv = "";
//String emailid="";
//String msgType="";
//String errCode="";
String chgDate = "";
String chgUser = "";
String chgTerm = "";
//String errFldName="";
//modified by Shital on 02/08/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital on 02/08/2019 [End]
// ArrayList<String> errList = new ArrayList<String>();
// ArrayList<String> errFields = new ArrayList<String>();
Connection connection = null;
ResultSet rs = null;
PreparedStatement pstm = null;
//NodeList parentList = null;
//NodeList childList = null;
// Node parent = null;
// Node child = null;
// int count = 0;
// int noofChild = 0;
int currentFormno = 0;
StringBuffer valueXmlString = null;
String empNameAprv2 = "";
String empNameAprv1 = "";
String empAprvAlt1 = "";
String empAprvAlt2 = "";
//modified by Shital on 02/08/2019 [Start]
//ConnDriver connDriver = null;
//connDriver = new ConnDriver();
//modified by Shital on 02/08/2019 [Start]
System.out.println("objContext ..:: ["+objContext+"]");
System.out.println("currentColumn ..:: ["+currentColumn+"]");
System.out.println("editFlag ..:: ["+editFlag+"]");
System.out.println("xtraParams ..:: ["+xtraParams+"]");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormno = Integer.parseInt(objContext);
}
try
{
// 10/02/2015 Start
String loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
System.out.println("Login Employee got..:: ["+loginEmpCode+"]");
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
chgTerm = getValueFromXTRA_PARAMS(xtraParams,"termId");
java.util.Date currDate = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
chgDate = sdf.format(currDate);
// 10/02/2015 End
//modified by Shital on 02/08/2019 [Start]
//connection = connDriver.getConnectDB("Driver");
connection = getConnection();
//modified by Shital on 02/08/2019 [End]
connection.setAutoCommit(false);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n");
//errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println ("error string:" + errString);
String objNameDefault = checkNull(getObjName(dom ,"1"));
System.out.println("objNameDefault ..:: ["+objNameDefault+"]");
switch (currentFormno)
{
case 1:
{
valueXmlString.append("<Detail1 domID='1' dbID='' objContext='1' objName='"+objNameDefault+"' selected='Y'>\r\n");
if (currentColumn.equalsIgnoreCase("itm_default"))
{
System.out.println("value of chgDate"+chgDate);
System.out.println("value of chgUser"+chgUser);
System.out.println("value of chgterm"+chgTerm);
valueXmlString.append("<chg_date><![CDATA[").append(checkNull(chgDate)).append("]]></chg_date>\r\n");
valueXmlString.append("<chg_user><![CDATA[").append(checkNull(chgUser)).append("]]></chg_user>\r\n");
valueXmlString.append("<chg_term><![CDATA[").append(checkNull(chgTerm)).append("]]></chg_term>\r\n");
}
else if (currentColumn.equalsIgnoreCase("site_code"))
{
sitecode = checkNull(genericUtility.getColumnValue("site_code",dom2));
System.out.println("sitecode ..:: ["+sitecode+"]");
if (sitecode.trim().length() > 0)
{
sql="select descr from site where site_code = ?";
pstm = connection.prepareStatement(sql);
pstm.setString( 1, sitecode );
rs = pstm.executeQuery();
if(rs.next())
{
sitedesc = checkNull(rs.getString("descr"));
}
System.out.println("sitedesc ..:: ["+sitedesc+"]");
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstm!=null)
{
pstm.close();
pstm=null;
}
if (sitedesc.trim().length() > 0 )
{
valueXmlString.append("<site_descr><![CDATA[").append(checkNull(sitedesc)).append("]]></site_descr>\r\n");
}
else
{
valueXmlString.append("<site_descr><![CDATA[]]></site_descr>\r\n");
}
}
else
{
valueXmlString.append("<site_descr><![CDATA[").append("]]></site_descr>\r\n");
}
}
//modified by Shital on 07/10/2019 [Start]
//else if(currentColumn.equalsIgnoreCase("emp_code_aprv"))
else if(currentColumn.equalsIgnoreCase("emp_code__aprv"))
{
//empAprv = checkNull(genericUtility.getColumnValue("emp_code_aprv", dom2));
empAprv = checkNull(genericUtility.getColumnValue("emp_code__aprv", dom2));
System.out.println("employee code ["+empAprv+"]");
//modified by Shital on 07/10/2019 [End]
if (empAprv.trim().length() > 0)
{
sql = "select (emp_fname ||' ' || emp_mname ||' ' || emp_lname) as emp_name from employee where emp_code= ? ";
pstm = connection.prepareStatement(sql);
pstm.setString( 1, empAprv );
rs = pstm.executeQuery();
if (rs.next())
{
empcodeaprvdesc = checkNull(rs.getString("emp_name"));
}
System.out.println("employe description ["+empcodeaprvdesc+"]");
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstm!=null)
{
pstm.close();
pstm=null;
}
}
valueXmlString.append("<emp_descr><![CDATA[").append(checkNull(empcodeaprvdesc)).append("]]></emp_descr>\r\n");
}
//Modified by Ahmed on 07/NOV/2016[A16FSUN003][START]
else if(currentColumn.equalsIgnoreCase("emp_code__aprv_alt1"))
{
System.out.println(":::::::::inside emp_code__aprv_alt1::::::::::");
empAprvAlt1 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt1", dom2));
System.out.println("employee code alt 1 ["+empAprvAlt1+"]");
//modified by Shital on 02/08/2019 [Start]
//String empNameAprv1 = "";
//modified by Shital on 02/08/2019 [Start]
sql = "";
if (empAprvAlt1.trim().length() > 0)
{
sql = "select ddf_get_masters_name('EMPLOYEE', ?, 'FML') as emp_name__aprv_alt1 from dual";
pstm = connection.prepareStatement(sql);
pstm.setString( 1, empAprvAlt1 );
rs = pstm.executeQuery();
if (rs.next())
{
empNameAprv1 = checkNull(rs.getString("emp_name__aprv_alt1"));
}
System.out.println("employee alt 1 description ["+empNameAprv1+"]");
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstm!=null)
{
pstm.close();
pstm=null;
}
}
valueXmlString.append("<emp_name__aprv_alt1><![CDATA[").append(checkNull(empNameAprv1)).append("]]></emp_name__aprv_alt1>\r\n");
}
else if(currentColumn.equalsIgnoreCase("emp_code__aprv_alt2"))
{
System.out.println(":::::::::inside emp_code__aprv_alt2::::::::::");
empAprvAlt2 = checkNull(genericUtility.getColumnValue("emp_code__aprv_alt2", dom2));
System.out.println("employee code alt 2["+empAprvAlt2+"]");
//modified by Shital on 02/08/2019 [Start]
//String empNameAprv2 = "";
//modified by Shital on 02/08/2019 [Start]
sql = "";
if (empAprvAlt2.trim().length() > 0)
{
sql = "select ddf_get_masters_name('EMPLOYEE', ?, 'FML') as emp_name__aprv_alt2 from dual";
pstm = connection.prepareStatement(sql);
pstm.setString( 1, empAprvAlt2 );
rs = pstm.executeQuery();
if (rs.next())
{
empNameAprv2 = checkNull(rs.getString("emp_name__aprv_alt2"));
}
System.out.println("employee alt 1 description ["+empNameAprv2+"]");
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstm!=null)
{
pstm.close();
pstm=null;
}
}
valueXmlString.append("<emp_name__aprv_alt2><![CDATA[").append(checkNull(empNameAprv2)).append("]]></emp_name__aprv_alt2>\r\n");
}
//Modified by Ahmed on 07/NOV/2016[A16FSUN003][END]
//valueXmlString.append</group0></DocumentRoot>");
//System.out.println("value of xmlString::::"+valueXmlString);
//valueXmlString.append("</Root>\r\n");
}
valueXmlString.append("</Detail1>\r\n");
break;
}
valueXmlString.append("</Root>\r\n");
}
catch ( Exception exp )
{
System.out.println("Inside Exception site IT declarartion approval::"+exp.getMessage());
exp.printStackTrace();
//modified by Shital on 02/08/2019 [Start]
throw new ITMException(exp);
//modified by Shital on 02/08/2019 [End]
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstm != null )
{
pstm.close();
pstm = null;
}
if ( connection != null )
{
connection.close();
connection = null;
}
}
catch(Exception e)
{
System.out.println("[CategoryMasterEJB][itemChanged]Exception ::"+e);
e.printStackTrace();
//modified by Shital on 02/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 02/08/2019 [End]
}
}
//valueXmlString.append("</group0></DocumentRoot>");
System.out.println("value of xmlString::::"+valueXmlString);
System.out.println("valueXmlString....["+valueXmlString.toString());
return valueXmlString.toString();
}
private String getValueFromRefTable(String tableName,String fieldName,String fieldValue,String reqdField,Connection conn) throws ITMException
{
Statement stmt = null;
ResultSet rs = null;
String returnValue ="";
try
{
if (fieldValue ==null )
fieldValue ="";
stmt = conn.createStatement();
String sql = "SELECT "+reqdField+" FROM "+tableName+" WHERE "+fieldName+" = '"+fieldValue+"'" ;
System.out.println("*****getValueFromRefTable******* DESCR QUERY IS "+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
returnValue = rs.getString(1);
System.out.println("************* VALUE IN "+tableName+" *IS*******"+returnValue );
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( stmt != null )
{
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.out.println("Inside getValueFromRefTable Exception *******"+e.getMessage());
//modified by Shital on 02/08/2019 [Start]
e.printStackTrace();
throw new ITMException(e);
//modified by Shital on 02/08/2019 [End]
}
finally
{
try
{
if (rs!=null)
{
rs.close();
rs = null;
}
if (stmt!=null)
{
stmt.close();
stmt = null;
}
}
catch (Exception e)
{
System.out.println("Inside Exception finally [PostMarketingStudyEJB]"+e.getMessage());
e.printStackTrace();
}
}
if (returnValue == null)
returnValue="";
return returnValue;
}
private String errorType( Connection conn , String errorCode ) throws ITMException
{
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();
throw new ITMException(ex);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private int getCountFromRefTable(String tableName,String fieldName,String fieldValue,Connection conn) throws ITMException
{
Statement stmt = null;
ResultSet rs = null;
int count =0;
try
{
stmt = conn.createStatement();
String sql = "SELECT COUNT(*) AS COUNT FROM "+tableName+" WHERE "+fieldName+" = '"+fieldValue+"'";
System.out.println("sql==>"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
System.out.println("inside rs.statement");
count = rs.getInt("COUNT");
System.out.println("************* COUNT IN "+tableName+" ********"+count );
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( stmt != null )
{
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Inside getCountFromRefTable Exception *******"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (rs!=null)
{
rs.close();
rs = null;
}
if (stmt!=null)
{
stmt.close();
stmt = null;
}
}
catch (Exception e)
{
System.out.println("Inside Exception finally "+e.getMessage());
e.printStackTrace();
//modified by Shital on 02/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 02/08/2019 [End]
}
}
return count;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input =input.trim();
}
return input;
}
private String getObjName(Document dom,String objContext)
{
Node elementName = null;
NodeList elementList = null;
String objName = "";
elementList = dom.getElementsByTagName("Detail"+objContext);
elementName = elementList.item(0);
if (elementName!=null && ("Detail"+objContext).equalsIgnoreCase(elementName.getNodeName()))
{
NamedNodeMap etlAttributes = elementName.getAttributes();
if (etlAttributes!=null)
{
if (etlAttributes.getNamedItem("objName")!=null)
{
objName = etlAttributes.getNamedItem("objName").getNodeValue();
}
}
}
return objName;
}
}
\ 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