Commit 7d2ed022 authored by manohar's avatar manohar

Multiplre error returned instead of breaking after each error


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96660 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6af8763b
......@@ -431,6 +431,9 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
int childNodeListLength;
String itemCode = "", unit = "", listType = "", effFromStr = "", validUptoStr = "", lotNoFrom = "", lotNoTo = "", slabno = "";
Timestamp effFrom =null, validUpto = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
......@@ -445,229 +448,290 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
currentFormNo = Integer.parseInt(objContext);
}
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);
childNodeName = childNode.getNodeName();
//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);
//childNodeName = childNode.getNodeName();
//System.out.println("Validation for [" + childNodeName + "]");
switch (currentFormNo)
{
case 1:
{
if (childNodeName.equals("slab_no"))
{
}
else if(childNodeName.equals("tax_base"))
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}
// ADDED BY RITESH ON 23/SEP/13 START
else if(childNodeName.equals("price_list"))
{
NamedNodeMap attrMap = parentNode.getAttributes();
String objName = attrMap.getNamedItem( "objName" ).getNodeValue();
String winName = "w_"+ objName;
priceList = genericUtility.getColumnValue("price_list",dom);
// 14/11/13 manoharan duplicate checking to consider all parameter
itemCode = genericUtility.getColumnValue("item_code",dom);
unit = genericUtility.getColumnValue("unit",dom);
listType = genericUtility.getColumnValue("list_type",dom);
effFromStr = genericUtility.getColumnValue("eff_from",dom);
validUptoStr = genericUtility.getColumnValue("valid_upto",dom);
lotNoFrom = genericUtility.getColumnValue("lot_no__from",dom);
lotNoTo = genericUtility.getColumnValue("lot_no__to",dom);
slabno = genericUtility.getColumnValue("slab_no",dom) ;
// end 14/11/13 manoharan duplicate checking to consider all parameter
System.out.println("price_list wfvalData :::: " + priceList);
// 14/11/13 manoharan commented as always it will be manual
//sql = "select key_flag from transetup where tran_window = '"+ winName +"'";
//pstmt = conn.prepareStatement(sql);
//rs = pstmt.executeQuery();
//if(rs.next())
//{
// lskeyflag = rs.getString("key_flag")== null ?"M":rs.getString("key_flag");
//
//}
//rs.close();rs = null;
//pstmt.close();pstmt = null;
// if("M".equals(lskeyflag) && (priceList == null || priceList.trim().length() == 0))
if(priceList == null || priceList.trim().length() == 0 || itemCode == null || itemCode.trim().length() == 0 || unit == null || unit.trim().length() == 0 || listType == null || listType.trim().length() == 0 || effFromStr == null || effFromStr.trim().length() == 0 || validUptoStr == null || validUptoStr.trim().length() == 0 || lotNoFrom == null || lotNoFrom.trim().length() == 0 || lotNoTo == null || lotNoTo.trim().length() == 0)
{
errCode = "VMCODNULL";
errString = getErrorString("price_list",errCode,userId);
}
else // if ("A".equals(editFlag))
{
System.out.println("before effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");
sql = "select count(*) from pricelist where price_list = ? "
+ " and item_code = ? and unit = ? and list_type = ? "
+ " and eff_from = ? and valid_upto = ? "
+ " and lot_no__from = ? and lot_no__to = ? ";
if ("E".equals(editFlag))
{
sql = sql + " and slab_no <> " + slabno ;
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList);
pstmt.setString(2,itemCode);
pstmt.setString(3,unit);
pstmt.setString(4,listType);
pstmt.setTimestamp(5,effFrom);
pstmt.setTimestamp(6,validUpto);
pstmt.setString(7,lotNoFrom);
pstmt.setString(8,lotNoTo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt1 = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(cnt1 > 0)
{
errCode = "VMDUPL1";
errString = getErrorString("price_list",errCode,userId);
}
}
} // ADDED BY RITESH ON 23/SEP/13 END
else if(childNodeName.equals("item_code"))
{
System.out.println("childNodeName 1. : " + childNodeName);
String mitem_code = genericUtility.getColumnValue("item_code",dom);
sql="select count(*) as count from item where item_code = '"+mitem_code+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
int cnt=0;
if(rs.next())
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("slab_no"))
{
cnt=rs.getInt("count");
}
rs.close();
rs = null;
if(cnt==0)
else if(childNodeName.equals("tax_base"))
{
errCode = "VMITEM_CD";
errString = getErrorString("min_qty",errCode,userId);
}
sql="select active from item where item_code='"+mitem_code+"'";
String mactive=null;
rs=stmt.executeQuery(sql);
if(rs.next())
// ADDED BY RITESH ON 23/SEP/13 START
else if(childNodeName.equals("price_list"))
{
NamedNodeMap attrMap = parentNode.getAttributes();
String objName = attrMap.getNamedItem( "objName" ).getNodeValue();
String winName = "w_"+ objName;
priceList = genericUtility.getColumnValue("price_list",dom);
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] priceList [ " + priceList + "]");
// 14/11/13 manoharan duplicate checking to consider all parameter
itemCode = genericUtility.getColumnValue("item_code",dom);
unit = genericUtility.getColumnValue("unit",dom);
listType = genericUtility.getColumnValue("list_type",dom);
effFromStr = genericUtility.getColumnValue("eff_from",dom);
validUptoStr = genericUtility.getColumnValue("valid_upto",dom);
lotNoFrom = genericUtility.getColumnValue("lot_no__from",dom);
lotNoTo = genericUtility.getColumnValue("lot_no__to",dom);
slabno = genericUtility.getColumnValue("slab_no",dom) ;
// end 14/11/13 manoharan duplicate checking to consider all parameter
System.out.println("price_list wfvalData :::: " + priceList);
// 14/11/13 manoharan commented as always it will be manual
//sql = "select key_flag from transetup where tran_window = '"+ winName +"'";
//pstmt = conn.prepareStatement(sql);
//rs = pstmt.executeQuery();
//if(rs.next())
//{
// lskeyflag = rs.getString("key_flag")== null ?"M":rs.getString("key_flag");
//
//}
//rs.close();rs = null;
//pstmt.close();pstmt = null;
// if("M".equals(lskeyflag) && (priceList == null || priceList.trim().length() == 0))
if(priceList == null || priceList.trim().length() == 0 || itemCode == null || itemCode.trim().length() == 0 || unit == null || unit.trim().length() == 0 || listType == null || listType.trim().length() == 0 || effFromStr == null || effFromStr.trim().length() == 0 || validUptoStr == null || validUptoStr.trim().length() == 0 || lotNoFrom == null || lotNoFrom.trim().length() == 0 || lotNoTo == null || lotNoTo.trim().length() == 0)
{
errCode = "VMCODNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else // if ("A".equals(editFlag))
{
System.out.println("before effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");
sql = "select count(*) from pricelist where price_list = ? "
+ " and item_code = ? and unit = ? and list_type = ? "
+ " and eff_from = ? and valid_upto = ? "
+ " and lot_no__from = ? and lot_no__to = ? ";
if ("E".equals(editFlag))
{
sql = sql + " and slab_no <> " + slabno ;
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList);
pstmt.setString(2,itemCode);
pstmt.setString(3,unit);
pstmt.setString(4,listType);
pstmt.setTimestamp(5,effFrom);
pstmt.setTimestamp(6,validUpto);
pstmt.setString(7,lotNoFrom);
pstmt.setString(8,lotNoTo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt1 = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(cnt1 > 0)
{
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} // ADDED BY RITESH ON 23/SEP/13 END
else if(childNodeName.equals("item_code"))
{
mactive=rs.getString("active");
System.out.println("childNodeName 1. : " + childNodeName);
String mitem_code = genericUtility.getColumnValue("item_code",dom);
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mitem_code [ " + mitem_code + "]");
sql="select count(*) as count from item where item_code = '"+mitem_code+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
int cnt=0;
if(rs.next())
{
cnt=rs.getInt("count");
}
rs.close();
rs = null;
if(cnt==0)
{
errCode = "VMITEM_CD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql="select active from item where item_code='"+mitem_code+"'";
String mactive=null;
rs=stmt.executeQuery(sql);
if(rs.next())
{
mactive=rs.getString("active");
}
rs.close();
rs = null;
if(mactive.equals("N"))
{
errCode="VTITEM4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
if(mactive.equals("N"))
{
errCode="VTITEM4";
errString = getErrorString("min_qty",errCode,userId);
}
}
else if (childNodeName.equals("price_list__parent"))
{
String ls_plist_parent,Is_price_list;
System.out.println("childNodeName 1. : " + childNodeName);
ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom);
Is_price_list = genericUtility.getColumnValue("price_list",dom);
//System.out.println("childNode.getFirstChild() 1. : " + childNode.getFirstChild());
//if (ls_plist_parent == null || ls_plist_parent.trim().length() == 0) //
if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/
else if (childNodeName.equals("price_list__parent"))
{
if(ls_plist_parent.trim().equals(Is_price_list.trim()) )
String ls_plist_parent,Is_price_list;
System.out.println("childNodeName 1. : " + childNodeName);
ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom);
Is_price_list = genericUtility.getColumnValue("price_list",dom);
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] ls_plist_parent [ " + ls_plist_parent + "] Is_price_list [" + Is_price_list + "]");
//System.out.println("childNode.getFirstChild() 1. : " + childNode.getFirstChild());
//if (ls_plist_parent == null || ls_plist_parent.trim().length() == 0) //
if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/
{
if(ls_plist_parent.trim().equals(Is_price_list.trim()) )
errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId);
break;
errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId);
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equals("min_qty"))
{
int mmaxqty,mminqty;
mmaxqty=Integer.parseInt(genericUtility.getColumnValue("min_qty",dom));
mminqty=Integer.parseInt(genericUtility.getColumnValue("max_qty",dom));
else if (childNodeName.equals("min_qty"))
{
int mmaxqty,mminqty;
mmaxqty=Integer.parseInt(genericUtility.getColumnValue("min_qty",dom));
mminqty=Integer.parseInt(genericUtility.getColumnValue("max_qty",dom));
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
if (mmaxqty < mminqty )
{
errCode = "VMMINQTY";
errString = getErrorString("min_qty",errCode,userId);
break;
}
if (mmaxqty < mminqty )
{
errCode = "VMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equals("valid_upto"))
{
Timestamp mvalid_upto,meff_from;
String strvalid_upto,strmeff_from;
strvalid_upto=genericUtility.getColumnValue("valid_upto",dom) ;
strmeff_from=genericUtility.getColumnValue("meff_from",dom);
}
else if(childNodeName.equals("valid_upto"))
{
Timestamp mvalid_upto,meff_from;
String strvalid_upto,strmeff_from;
strvalid_upto=genericUtility.getColumnValue("valid_upto",dom) ;
strmeff_from=genericUtility.getColumnValue("eff_from",dom);
String valid_uptoDate=getValidDateTimeString(strvalid_upto,GenericUtility.getInstance().getApplDateFormat(),GenericUtility.getInstance().getDBDateFormat());
String eff_fromDate= getValidDateTimeString(strmeff_from,GenericUtility.getInstance().getApplDateFormat(),GenericUtility.getInstance().getDBDateFormat());
String valid_uptoDate=getValidDateTimeString(strvalid_upto,GenericUtility.getInstance().getApplDateFormat(),GenericUtility.getInstance().getDBDateFormat());
String eff_fromDate= getValidDateTimeString(strmeff_from,GenericUtility.getInstance().getApplDateFormat(),GenericUtility.getInstance().getDBDateFormat());
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
mvalid_upto = Timestamp.valueOf(valid_uptoDate+" 00:00:00");
meff_from = Timestamp.valueOf(eff_fromDate+" 00:00:00");
mvalid_upto = Timestamp.valueOf(valid_uptoDate+" 00:00:00");
meff_from = Timestamp.valueOf(eff_fromDate+" 00:00:00");
if( ( mvalid_upto.compareTo( meff_from) ) ==0 )
{
errCode="VMVAL_UPTO";
errString=getErrorString("valid_upto",errCode,userId);
break;
if( ( mvalid_upto.compareTo( meff_from) ) ==0 )
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equals("tax_code"))
{
String mValue=genericUtility.getColumnValue("tax_code",dom);
sql="Select Count(*) as count from tax where tax_code = '"+mValue+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
if(rs.next())
else if(childNodeName.equals("tax_code"))
{
int cnt=rs.getInt("count");
if(cnt==0)
errCode = "VTTAX1";
break;
String mValue=genericUtility.getColumnValue("tax_code",dom);
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mValue [ " + mValue + "]");
sql="Select Count(*) as count from tax where tax_code = '"+mValue+"'";
rs=stmt.executeQuery(sql);
System.out.println("SQL"+sql);
if(rs.next())
{
int cnt=rs.getInt("count");
if(cnt==0)
{
errCode = "VTTAX1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
}
rs.close();
rs = null;
}
else if(childNodeName.equals("rate") || childNodeName.equals("min_rate") || childNodeName.equals("max_rate") ) // 20/10/14 manoharan min_rate and max_rate included
{
double mrate; // 20/10/14 manoharan changes from integer to double
mrate= Double.parseDouble(genericUtility.getColumnValue("rate",dom) );
if(mrate<=0)
errCode="VTRATE2";
errString=getErrorString("rate",errCode,userId);
}
else if(childNodeName.equals("rate") || childNodeName.equals("min_rate") || childNodeName.equals("max_rate") ) // 20/10/14 manoharan min_rate and max_rate included
{
double mrate; // 20/10/14 manoharan changes from integer to double
mrate= Double.parseDouble(genericUtility.getColumnValue(childNodeName,dom) );
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if(mrate<=0)
{
errCode="VTRATE2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}//case1
}
break;
}
break;
}
}//switch
}//for
//}//for
int errListSize = errList.size();
int cnt = 0;
String errFldName = null, errorType = null;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , 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);
errString = "";
}
if(errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//try
catch(Exception e)
{
......@@ -696,7 +760,10 @@ public class PriceList extends ValidatorEJB implements PriceListLocal, PriceList
}
}catch(Exception se){}
}
errString = errStringXml.toString();
System.out.println("ErrString ::"+errString);
return errString;
}//wfValData
......@@ -740,6 +807,51 @@ public String getValidDateTimeString(String dateTimeStr, String sourceDateTimeFo
System.out.println("retDateStr :"+retDateStr);
return retDateStr;
}
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();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} 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;
}
......
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