Commit cbdf3b2c authored by sghate's avatar sghate

updated SiteHolTblIC component

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206466 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ecb6f2d7
...@@ -88,7 +88,7 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo ...@@ -88,7 +88,7 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
conn = getConnection(); conn = getConnection();
errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0) if (objContext != null && objContext.trim().length() > 0)
{ {
...@@ -144,197 +144,246 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo ...@@ -144,197 +144,246 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
} }
} }
else if("hol_tblno".equalsIgnoreCase(childNodeName)) else if (childNodeName.equalsIgnoreCase("hol_tblno"))
{ {
holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom)); holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
sql = "Select count(*) as cnt from gencodes where fld_name = 'HOL_TBLNO' and mod_name = 'X' and fld_value = ? ";
pstmt = conn.prepareStatement(sql); if(holTblNo == null || holTblNo.trim().length() == 0)
pstmt.setString(1, holTblNo);
rs = pstmt.executeQuery();
if(rs.next())
{ {
cnt = rs.getInt("cnt"); errList.add("VMHOLTBL");// Holiday Table cannot be Empty
errFields.add(childNodeName.toLowerCase());
} }
if(rs != null) else
{ {
rs.close(); holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
rs = null; sql = "select count(*) as cnt from gencodes where fld_name = 'HOL_TBLNO' and mod_name = 'X' and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0 && !"E".equalsIgnoreCase(editFlag))
{
errList.add("VMHOLTBL");//Data Already Existed for Entered SITE_HOLTBL_MAP Table
errFields.add(childNodeName.toLowerCase());
}
} }
if(pstmt != null)
}
}
System.out.println("errStringXml.toString()---1= "+errStringXml.toString());
if (errList != null && errList.size() > 0)
{
System.out.println("errList==[" + errList + "]");
int errListSize = errList.size();
System.out.println("errListSize:::::::[" + errListSize + "]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++)
{
System.out.println("in error For:::::::::::::::");
String errCode = (String) errList.get(i);
String errFldName = (String) errFields.get(i);
System.out.println("errCode .........." + errCode);
errString = itmDbAcess.getErrorString(errFldName, errCode, userId, "", conn);
System.out.println("errString is : ::::>>>> " + errString);
String msgType = errorType(conn, errCode);
if (errString.length() > 0)
{ {
pstmt.close(); String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,
pstmt = null; errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
} }
if(cnt == 0) if (msgType.equalsIgnoreCase("E"))
{ {
errList.add("VMHOLTBL"); break;
errFields.add(childNodeName.toLowerCase());
} }
} }
errList.clear();
errFields.clear();
} }
errStringXml.append("</Errors></Root>\r\n");
System.out.println("errStringXml.toString()---2= "+errStringXml.toString());
} }
System.out.println("errStringXml.toString()---1= "+errStringXml.toString()); }
if (errList != null && errList.size() > 0) catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{ {
System.out.println("errList==[" + errList + "]"); try
int errListSize = errList.size();
System.out.println("errListSize:::::::[" + errListSize + "]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++)
{ {
System.out.println("in error For:::::::::::::::");
String errCode = (String) errList.get(i); if(rs != null)
String errFldName = (String) errFields.get(i); {
System.out.println("errCode .........." + errCode); rs.close();
errString = itmDbAcess.getErrorString(errFldName, errCode, userId, "", conn); rs = null;
System.out.println("errString is : ::::>>>> " + errString); }
String msgType = errorType(conn, errCode); if(pstmt != null)
if (errString.length() > 0)
{ {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, pstmt.close();
errString.indexOf("<trace>")); pstmt = null;
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
} }
if (msgType.equalsIgnoreCase("E")) if(conn != null)
{ {
break; conn.close();
conn = null;
} }
} }
errList.clear(); catch(Exception e)
errFields.clear(); {
} e.printStackTrace();
errStringXml.append("</Errors></Root>\r\n"); throw new ITMException(e);
System.out.println("errStringXml.toString()---2= "+errStringXml.toString()); }
} }
catch(Exception e)
{ errString = errStringXml.toString();
e.printStackTrace(); System.out.println("testing : final errString : " + errString);
throw new ITMException(e); return errString;
} }
finally public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{ {
try Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
E12GenericUtility genericUtility = null;
try
{ {
if(conn != null) genericUtility = new E12GenericUtility();
if (xmlString != null && xmlString.trim().length() != 0)
{ {
conn.close(); dom = genericUtility.parseString(xmlString);
conn = null;
} }
if(rs != null) if (xmlString1 != null && xmlString1.trim().length() != 0)
{ {
rs.close(); dom1 = genericUtility.parseString(xmlString1);
rs = null;
} }
if(pstmt != null) if (xmlString2 != null && xmlString2.trim().length() != 0)
{ {
pstmt.close(); dom2 = genericUtility.parseString(xmlString2);
pstmt = null;
} }
} valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
catch(Exception e) }
catch (Exception e)
{ {
System.out.println("Exception :SiteHolTblIC :itemChanged(String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} return valueXmlString;
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
E12GenericUtility genericUtility = null;
try
{
genericUtility = new E12GenericUtility();
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);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :SiteHolTblIC :itemChanged(String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
} }
return valueXmlString; public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,String editFlag, String xtraParams)throws java.rmi.RemoteException, ITMException
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,String editFlag, String xtraParams)throws java.rmi.RemoteException, ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String colname = "";
colname = currentColumn;
int cnt = 0;
int currentFormNo = 0;
String siteCode = "";
String lsDescr = "";
String holTblNo = "";
String loginSiteCode = "";
StringBuffer valueXmlString = null;
E12GenericUtility genericUtility = null;
try
{ {
Connection conn = null;
genericUtility = new E12GenericUtility(); PreparedStatement pstmt = null;
conn = getConnection(); ResultSet rs = null;
if(objContext != null && objContext.trim().length() > 0) String sql = "";
String colname = "";
colname = currentColumn;
int cnt = 0;
int currentFormNo = 0;
String siteCode = "";
String lsDescr = "";
String holTblNo = "";
String loginSiteCode = "";
StringBuffer valueXmlString = null;
E12GenericUtility genericUtility = null;
try
{ {
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>"); genericUtility = new E12GenericUtility();
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n"); conn = getConnection();
loginSiteCode = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode")); if(objContext != null && objContext.trim().length() > 0)
System.out.println("loginSiteCode:::::"+loginSiteCode); {
System.out.println("current form no: " + currentFormNo); currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo) 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");
case 1: loginSiteCode = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
{ System.out.println("loginSiteCode:::::"+loginSiteCode);
valueXmlString.append("<Detail1>\r\n"); System.out.println("current form no: " + currentFormNo);
if("itm_default".equalsIgnoreCase(currentColumn)) switch(currentFormNo)
{
case 1:
{ {
System.out.println("inside itm_default"); valueXmlString.append("<Detail1>\r\n");
siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "site_code"));
System.out.println("siteCode:::::"+siteCode); if("itm_default".equalsIgnoreCase(currentColumn))
{
if(siteCode == null || siteCode.trim().length() == 0) System.out.println("inside itm_default");
siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "site_code"));
System.out.println("siteCode:::::"+siteCode);
if(siteCode == null || siteCode.trim().length() == 0)
{
siteCode = loginSiteCode;
}
if(siteCode != null && siteCode.trim().length() > 0)
{
sql = "Select descr as ls_descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsDescr = checkNull(rs.getString("ls_descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<site_descr>").append("<![CDATA[" + lsDescr + "]]>").append("</site_descr>");
}
valueXmlString.append("<site_code protect='1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
}
else if("itm_defaultedit".equalsIgnoreCase(currentColumn))
{ {
siteCode = loginSiteCode; siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
valueXmlString.append("<site_code protect=\"1\"><![CDATA[").append(siteCode).append("]]></site_code>\r\n");
holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
valueXmlString.append("<hol_tblno protect=\"1\"><![CDATA[").append(holTblNo).append("]]></hol_tblno>\r\n");
} }
if(siteCode != null && siteCode.trim().length() > 0)
else if("hol_tblno".equalsIgnoreCase(currentColumn))
{ {
sql = "Select descr as ls_descr from site where site_code = ?"; holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
sql = "Select fn_get_gen_descr( 'HOL_TBLNO' , 'X' , ? , 'D') as ls_descr from dual";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, holTblNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
...@@ -350,33 +399,26 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo ...@@ -350,33 +399,26 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
valueXmlString.append("<site_descr>").append("<![CDATA[" + lsDescr + "]]>").append("</site_descr>"); valueXmlString.append("<holtbl_descr>").append("<![CDATA[" + lsDescr + "]]>").append("</holtbl_descr>");
} }
valueXmlString.append("<site_code protect='1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n"); valueXmlString.append("</Detail1>");
} }
else if("itm_defaultedit".equalsIgnoreCase(currentColumn))
{
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
valueXmlString.append("<site_code protect=\"1\"><![CDATA[").append(siteCode).append("]]></site_code>\r\n");
holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
valueXmlString.append("<hol_tblno protect=\"1\"><![CDATA[").append(holTblNo).append("]]></hol_tblno>\r\n");
break;
} }
valueXmlString.append("</Root>");
else if("hol_tblno".equalsIgnoreCase(currentColumn)) }
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :SiteHolTblIC [itemChanged(String xmlString)] : ==>\n" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{ {
holTblNo = checkNull(genericUtility.getColumnValue("hol_tblno", dom));
sql = "Select fn_get_gen_descr( 'HOL_TBLNO' , 'X' , ? , 'D') as ls_descr from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo);
rs = pstmt.executeQuery();
if(rs.next())
{
lsDescr = checkNull(rs.getString("ls_descr"));
}
if(rs != null) if(rs != null)
{ {
rs.close(); rs.close();
...@@ -387,115 +429,86 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo ...@@ -387,115 +429,86 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
valueXmlString.append("<holtbl_descr>").append("<![CDATA[" + lsDescr + "]]>").append("</holtbl_descr>"); if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
} }
valueXmlString.append("</Detail1>");
}
break;
} }
valueXmlString.append("</Root>"); System.out.println("returning from SiteHolTblIC itemChanged ===" + valueXmlString.toString());
} return valueXmlString.toString();
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :SiteHolTblIC [itemChanged(String xmlString)] : ==>\n" + e.getMessage());
throw new ITMException(e);
} }
finally
{ private String errorType(Connection conn, String errorCode) throws ITMException {
try String msgType = "";
{ PreparedStatement pstmt = null;
if(conn != null) ResultSet rs = null;
try {
if (conn == null) {
System.out.println("Connection is null");
} else {
System.out.println("Connection is not null");
}
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{ {
conn.close(); msgType = rs.getString("MSG_TYPE");
conn = null;
} }
if(rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception ex)
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("returning from SiteHolTblIC itemChanged ===" + valueXmlString.toString());
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
if (conn == null) {
System.out.println("Connection is null");
} else {
System.out.println("Connection is not null");
}
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
if (rs != null)
{ {
rs.close(); ex.printStackTrace();
rs = null; throw new ITMException(ex);
} }
if (pstmt != null) finally
{ {
pstmt.close(); try
pstmt = null;
}
} catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{ {
rs.close(); if (rs != null)
rs = null; {
} rs.close();
if (pstmt != null) rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
} catch (Exception e)
{ {
pstmt.close(); e.printStackTrace();
pstmt = null; throw new ITMException(e);
} }
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
} }
return msgType;
} }
return msgType;
}
private String checkNull(String input) private String checkNull(String input)
{
if(input == null)
{ {
input = ""; if(input == null)
{
input = "";
}
return input.trim();
} }
return input.trim();
} }
}
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