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
conn = getConnection();
errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
......@@ -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));
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())
if(holTblNo == null || holTblNo.trim().length() == 0)
{
cnt = rs.getInt("cnt");
errList.add("VMHOLTBL");// Holiday Table cannot be Empty
errFields.add(childNodeName.toLowerCase());
}
if(rs != null)
else
{
rs.close();
rs = null;
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);
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();
pstmt = null;
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(cnt == 0)
if (msgType.equalsIgnoreCase("E"))
{
errList.add("VMHOLTBL");
errFields.add(childNodeName.toLowerCase());
break;
}
}
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 + "]");
int errListSize = errList.size();
System.out.println("errListSize:::::::[" + errListSize + "]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++)
try
{
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)
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
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 = "";
pstmt.close();
pstmt = null;
}
if (msgType.equalsIgnoreCase("E"))
if(conn != null)
{
break;
conn.close();
conn = null;
}
}
errList.clear();
errFields.clear();
}
errStringXml.append("</Errors></Root>\r\n");
System.out.println("errStringXml.toString()---2= "+errStringXml.toString());
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
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();
conn = null;
dom = genericUtility.parseString(xmlString);
}
if(rs != null)
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
rs.close();
rs = null;
dom1 = genericUtility.parseString(xmlString1);
}
if(pstmt != null)
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
pstmt.close();
pstmt = null;
dom2 = genericUtility.parseString(xmlString2);
}
}
catch(Exception e)
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);
}
}
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;
}
return valueXmlString;
}
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
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,String editFlag, String xtraParams)throws java.rmi.RemoteException, ITMException
{
genericUtility = new E12GenericUtility();
conn = getConnection();
if(objContext != null && objContext.trim().length() > 0)
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
{
currentFormNo = Integer.parseInt(objContext);
}
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");
loginSiteCode = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
System.out.println("loginSiteCode:::::"+loginSiteCode);
System.out.println("current form no: " + currentFormNo);
genericUtility = new E12GenericUtility();
conn = getConnection();
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
{
valueXmlString.append("<Detail1>\r\n");
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");
loginSiteCode = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
System.out.println("loginSiteCode:::::"+loginSiteCode);
System.out.println("current form no: " + currentFormNo);
if("itm_default".equalsIgnoreCase(currentColumn))
switch(currentFormNo)
{
case 1:
{
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)
valueXmlString.append("<Detail1>\r\n");
if("itm_default".equalsIgnoreCase(currentColumn))
{
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.setString(1, siteCode);
pstmt.setString(1, holTblNo);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -350,33 +399,26 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
pstmt.close();
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;
}
else if("hol_tblno".equalsIgnoreCase(currentColumn))
valueXmlString.append("</Root>");
}
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)
{
rs.close();
......@@ -387,115 +429,86 @@ public class SiteHolTblIC extends ValidatorEJB implements SiteHolTblLocal,SiteHo
pstmt.close();
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>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :SiteHolTblIC [itemChanged(String xmlString)] : ==>\n" + e.getMessage());
throw new ITMException(e);
System.out.println("returning from SiteHolTblIC itemChanged ===" + valueXmlString.toString());
return valueXmlString.toString();
}
finally
{
try
{
if(conn != null)
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())
{
conn.close();
conn = null;
msgType = rs.getString("MSG_TYPE");
}
if(rs != null)
if (rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
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)
} catch (Exception ex)
{
rs.close();
rs = null;
}
if (pstmt != null)
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
pstmt.close();
pstmt = null;
}
} catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
try
{
rs.close();
rs = null;
}
if (pstmt != null)
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
} catch (Exception e)
{
pstmt.close();
pstmt = null;
e.printStackTrace();
throw new ITMException(e);
}
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return msgType;
}
return msgType;
}
private String checkNull(String input)
{
if(input == null)
private String checkNull(String input)
{
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