Added CustomerMasterIC file

parent 14dc5d83
package ibase.webitm.ejb.vhb.msq1;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class CustomerMasterIC extends ValidatorEJB {
E12GenericUtility genericUtility = new E12GenericUtility();
String winName = null;
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 = null;
BaseLogger.log("3", getUserInfo(), null,"currFrmXmlStr::"+xmlString);
BaseLogger.log("3", getUserInfo(), null,"hdrFrmXmlStr::"+xmlString1);
BaseLogger.log("3", getUserInfo(), null,"allFrmXmlStr::"+xmlString2);
try
{
if (xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ItemChangeErrString :" + errString);
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null,"Exception : [CRMCONTACTS][itemChanged(String,String)] :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String city ="";
String countCode = "";
String currCode = "";
int currentFormNo = 0;
String sql="";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
conn = getConnection();
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
BaseLogger.log("3", getUserInfo(), null,"FORM NO:::"+currentFormNo);
valueXmlString.append( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch(currentFormNo)
{
case 1 :
BaseLogger.log("3", getUserInfo(), null, "Inside Case1 Itemchanged CustomerMasterIC " );
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
if ("pin".equalsIgnoreCase(currentColumn.trim()))
{
System.out.println("inside pin itemchange");
int pinCnt=0;
String columnValue = genericUtility.getColumnValue("pin",dom);
System.out.println("pincode " +columnValue);
String pinSql ="SELECT COUNT(*) AS COUNT FROM STATION WHERE PIN=?";
pstmt = conn.prepareStatement(pinSql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next())
{
pinCnt=rs.getInt("COUNT");
}
System.out.println("Count ++ " + pinCnt);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(pinCnt==1)
{
System.out.println("Inside pinCnt==1 ");
String pinSql2 ="select st.CITY , st.COUNT_CODE , co.CURR_CODE from station st left join country co on st.count_code = co.count_code WHERE PIN = ? ";
pstmt = conn.prepareStatement(pinSql2);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next())
{
city = rs.getString("CITY");
countCode =rs.getString("COUNT_CODE");
currCode = rs.getString("CURR_CODE");
}
System.out.println("CITY +++ " + city );
System.out.println("COUNTRY +++ " + countCode );
System.out.println("CURRENCY +++ " + currCode );
valueXmlString.append("<city><![CDATA[").append(city).append("]]></city>\r\n");
valueXmlString.append("<count_code><![CDATA[").append(countCode).append("]]></count_code>\r\n");
valueXmlString.append("<curr_code><![CDATA[").append(currCode).append("]]></currCode>\r\n");
}
if(pinCnt==0)
{
System.out.println("Inside pinCnt==0 ");
valueXmlString.append("<city><![CDATA[").append("").append("]]></city>\r\n");
valueXmlString.append("<count_code><![CDATA[").append("").append("]]></count_code>\r\n");
valueXmlString.append("<curr_code><![CDATA[").append("").append("]]></curr_code>\r\n");
}
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}
}
catch(Exception e)
{
e.printStackTrace();
BaseLogger.log("3", getUserInfo(), null,"Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
if( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
BaseLogger.log("3", getUserInfo(), null,"valueXmlString:::::" + valueXmlString.toString());
return valueXmlString.toString();
}
}
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