Commit 01dc27d4 authored by tmahadi's avatar tmahadi

src updated by Sagar N for pricelist validation in head 300117


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104503 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e615d735
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.*; import java.util.*;
import java.util.Date; import java.util.Date;
import java.text.*; import java.text.*;
import java.sql.*; import java.sql.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import javax.ejb.*; import javax.ejb.*;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.system.config.*; import ibase.system.config.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
//public class PriceListEJB extends ValidatorEJB implements SessionBean //public class PriceListEJB extends ValidatorEJB implements SessionBean
@Stateless // added for ejb3 @Stateless // added for ejb3
public class PriceList extends ValidatorEJB implements PriceListLocal, PriceListRemote public class PriceList extends ValidatorEJB implements PriceListLocal, PriceListRemote
{ {
//GenericUtility genericUtility = GenericUtility.getInstance(); //GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility= new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
/*public void ejbCreate() throws RemoteException, CreateException /*public void ejbCreate() throws RemoteException, CreateException
{ {
System.out.println("sEntering into SQLChangeEJB............."); System.out.println("sEntering into SQLChangeEJB.............");
} }
public void ejbRemove() public void ejbRemove()
{ {
} }
public void ejbActivate() public void ejbActivate()
{ {
} }
public void ejbPassivate() public void ejbPassivate()
{ {
}*/ }*/
public String wfValData() throws RemoteException,ITMException public String wfValData() throws RemoteException,ITMException
{ {
return ""; return "";
} }
public String itemChanged() throws RemoteException,ITMException public String itemChanged() throws RemoteException,ITMException
{ {
return ""; return "";
} }
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{ {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String valueXmlString = ""; String valueXmlString = "";
try try
{ {
dom = parseString(xmlString); //returns the DOM Object for the passed XML Stirng dom = parseString(xmlString); //returns the DOM Object for the passed XML Stirng
System.out.println("xmlString :" + xmlString); System.out.println("xmlString :" + xmlString);
dom1 = parseString(xmlString1); //returns the DOM Object for the passed XML Stirng dom1 = parseString(xmlString1); //returns the DOM Object for the passed XML Stirng
System.out.println("xmlString1 :" + xmlString1); System.out.println("xmlString1 :" + xmlString1);
if (xmlString2.trim().length() > 0 ) if (xmlString2.trim().length() > 0 )
{ {
dom2 = parseString("<Root>" + xmlString2+ "</Root>"); dom2 = parseString("<Root>" + xmlString2+ "</Root>");
} }
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams); valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception : [PriceListEJB][itemChanged(String,String)] :==>\n"+e.getMessage()); System.out.println("Exception : [PriceListEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
} }
return valueXmlString; return valueXmlString;
} }
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{ {
Connection conn = null; Connection conn = null;
Statement stmt = null,stmt1 = null; Statement stmt = null,stmt1 = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ResultSet rs1 = null; ResultSet rs1 = null;
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
StringBuffer retString = new StringBuffer(); StringBuffer retString = new StringBuffer();
String errCode = ""; String errCode = "";
String sql = "",sql1 =""; String sql = "",sql1 ="";
String columnValue = ""; String columnValue = "";
String childNodeName = ""; String childNodeName = "";
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
int ctr = 0; int ctr = 0;
int n = 0; int n = 0;
int currentFormNo = 0; int currentFormNo = 0;
String priceList = null; String priceList = "";
String listType=""; String listType="";
String itemCode = null; String itemCode = "";
String unit = null; String unit = "";
String slabno = null; String slabno = "";
String col_name; String col_name = "";
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId"); String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("userId ::-"+userId); System.out.println("userId ::-"+userId);
try try
{ {
conn = getConnection(); conn = getConnection();
stmt = conn.createStatement(); stmt = conn.createStatement();
stmt1 = conn.createStatement(); stmt1 = conn.createStatement();
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
System.out.println("[PriceListEJB] [itemChanged] :currentFormNo ....." +currentFormNo); System.out.println("[PriceListEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>"); valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail>"); valueXmlString.append("<Detail>");
switch (currentFormNo) switch (currentFormNo)
{ {
case 1: case 1:
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
ctr = 0; ctr = 0;
int childNodeListLength = childNodeList.getLength(); int childNodeListLength = childNodeList.getLength();
do do
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn)) if(childNodeName.equals(currentColumn))
{ {
if (childNode.getFirstChild() != null) if (childNode.getFirstChild() != null)
{ {
columnValue=childNode.getFirstChild().getNodeValue().trim(); columnValue=childNode.getFirstChild().getNodeValue().trim();
} }
} }
ctr++; ctr++;
} }
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn)); while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
try try
{ {
if (currentColumn.trim().equals("itm_defaultedit")) if (currentColumn.trim().equals("itm_defaultedit"))
{ {
priceList = genericUtility.getColumnValue("price_list",dom) ; priceList = genericUtility.getColumnValue("price_list",dom) ;
itemCode = genericUtility.getColumnValue("item_code",dom) ; itemCode = genericUtility.getColumnValue("item_code",dom) ;
unit = genericUtility.getColumnValue("unit",dom) ; unit = genericUtility.getColumnValue("unit",dom) ;
listType = genericUtility.getColumnValue("list_type",dom) ; listType = genericUtility.getColumnValue("list_type",dom) ;
slabno = genericUtility.getColumnValue("slab_no",dom) ; slabno = genericUtility.getColumnValue("slab_no",dom) ;
valueXmlString.append("<price_list protect=\"1\">").append("<![CDATA["+priceList+"]]>").append("</price_list>"); valueXmlString.append("<price_list protect=\"1\">").append("<![CDATA["+priceList+"]]>").append("</price_list>");
valueXmlString.append("<item_code protect=\"1\">").append("<![CDATA["+itemCode+"]]>").append("</item_code>"); valueXmlString.append("<item_code protect=\"1\">").append("<![CDATA["+itemCode+"]]>").append("</item_code>");
valueXmlString.append("<unit protect=\"1\">").append("<![CDATA["+unit+"]]>").append("</unit>"); valueXmlString.append("<unit protect=\"1\">").append("<![CDATA["+unit+"]]>").append("</unit>");
valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>"); valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>");
valueXmlString.append("<slab_no protect=\"1\">").append("<![CDATA["+slabno+"]]>").append("</slab_no>"); valueXmlString.append("<slab_no protect=\"1\">").append("<![CDATA["+slabno+"]]>").append("</slab_no>");
/* sql = "SELECT DISTINCT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'"; /* sql = "SELECT DISTINCT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'";
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
System.out.println("SQL....."+sql); System.out.println("SQL....."+sql);
if (rs.next()) if (rs.next())
{ {
listType = rs.getString("list_type"); listType = rs.getString("list_type");
} }
rs.close(); rs.close();
rs = null; rs = null;
valueXmlString.append("<list_type protect='1\'>").append(listType).append("</list_type>"); valueXmlString.append("<list_type protect='1\'>").append(listType).append("</list_type>");
*/ */
} }
else // Commented By Sagar On 27-JAN-2017 Start
if (currentColumn.trim().equals("itm_default") ) /* else
{ if (currentColumn.trim().equals("itm_default") )
long mslab_no=0; {
priceList = genericUtility.getColumnValue("price_list",dom) ; long mslab_no=0;
String mprice_list,mitem_code,munit,mlist_type; priceList = genericUtility.getColumnValue("price_list",dom) ;
// 21/06813 manoharan check for value String mprice_list,mitem_code,munit,mlist_type;
valueXmlString.append("<item_code protect=\"0\">").append("<![CDATA[").append(" ").append("]]>").append("</item_code>"); // 21/06813 manoharan check for value
valueXmlString.append("<unit protect=\"0\">").append("<![CDATA[ ]]>").append("</unit>"); valueXmlString.append("<item_code protect=\"0\">").append("<![CDATA[").append(" ").append("]]>").append("</item_code>");
if (priceList != null && priceList.trim().length() > 0 ) valueXmlString.append("<unit protect=\"0\">").append("<![CDATA[ ]]>").append("</unit>");
{ if (priceList != null && priceList.trim().length() > 0 )
valueXmlString.append("<price_list protect=\"1\">").append("<![CDATA["+priceList+"]]>").append("</price_list>"); {
// 31/01/2008 manoharan distinct not required valueXmlString.append("<price_list protect=\"1\">").append("<![CDATA["+priceList+"]]>").append("</price_list>");
//sql = "SELECT DISTINCT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'"; // 31/01/2008 manoharan distinct not required
sql = "SELECT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'"; //sql = "SELECT DISTINCT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'";
sql = "SELECT list_type FROM PRICELIST WHERE price_list = '"+ priceList +"'";
rs = stmt.executeQuery(sql);
System.out.println("SQL....."+sql); rs = stmt.executeQuery(sql);
if (rs.next()) System.out.println("SQL....."+sql);
{ if (rs.next())
listType = rs.getString("list_type"); {
valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>"); listType = rs.getString("list_type");
} valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>");
else }
{ else
// 31/01/2008 manoharan {
rs.close(); // 31/01/2008 manoharan
rs = null; rs.close();
sql = "SELECT list_type FROM PRICELIST_MST WHERE price_list = '"+ priceList +"'"; rs = null;
sql = "SELECT list_type FROM PRICELIST_MST WHERE price_list = '"+ priceList +"'";
rs = stmt.executeQuery(sql);
System.out.println("SQL....."+sql); rs = stmt.executeQuery(sql);
if (rs.next()) System.out.println("SQL....."+sql);
{ if (rs.next())
listType = rs.getString("list_type"); {
valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>"); listType = rs.getString("list_type");
} valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+listType+"]]>").append("</list_type>");
else }
{ else
valueXmlString.append("<list_type protect=\"0\">").append("<![CDATA[ ]]>").append("</list_type>"); {
} valueXmlString.append("<list_type protect=\"0\">").append("<![CDATA[ ]]>").append("</list_type>");
// end 31/01/2008 manoharan }
} // end 31/01/2008 manoharan
rs.close(); }
rs = null; rs.close();
rs = null;
sql="SELECT MAX(SLAB_NO) FROM PRICELIST WHERE PRICE_LIST = '" + priceList + "'";
sql="SELECT MAX(SLAB_NO) FROM PRICELIST WHERE PRICE_LIST = '" + priceList + "'";
rs=stmt.executeQuery(sql);
System.out.println("SQL query....."+sql); rs=stmt.executeQuery(sql);
if(rs.next()) System.out.println("SQL query....."+sql);
{ if(rs.next())
mslab_no=rs.getLong(1); {
valueXmlString.append("<slab_no protect=\"1\">").append(mslab_no + 1).append("</slab_no>"); mslab_no=rs.getLong(1);
} valueXmlString.append("<slab_no protect=\"1\">").append(mslab_no + 1).append("</slab_no>");
else }
{ else
valueXmlString.append("<slab_no protect=\"1\">").append("1").append("</slab_no>"); {
} valueXmlString.append("<slab_no protect=\"1\">").append("1").append("</slab_no>");
rs.close(); }
rs = null; rs.close();
} rs = null;
}
Timestamp mfr_date=null,mto_date=null;
sql="SELECT FR_DATE,TO_DATE FROM PARAMETER"; Timestamp mfr_date=null,mto_date=null;
sql="SELECT FR_DATE,TO_DATE FROM PARAMETER";
rs=stmt.executeQuery(sql);
if(rs.next()) rs=stmt.executeQuery(sql);
{ if(rs.next())
mfr_date=rs.getTimestamp("fr_date") ; {
mto_date=rs.getTimestamp("to_date") ; mfr_date=rs.getTimestamp("fr_date") ;
} mto_date=rs.getTimestamp("to_date") ;
rs.close(); }
rs = null; rs.close();
//commented by rajendra on 11/10/07 for avoid null rs = null;
// mprice_list = genericUtility.getColumnValue("price_list",dom); //commented by rajendra on 11/10/07 for avoid null
// mitem_code = genericUtility.getColumnValue("item_code",dom); // mprice_list = genericUtility.getColumnValue("price_list",dom);
// munit = genericUtility.getColumnValue("unit",dom); // mitem_code = genericUtility.getColumnValue("item_code",dom);
// mlist_type = genericUtility.getColumnValue("list_type",dom); // munit = genericUtility.getColumnValue("unit",dom);
// // mlist_type = genericUtility.getColumnValue("list_type",dom);
// valueXmlString.append("<fr_date>").append(mfr_date).append("</fr_date>"); //
// valueXmlString.append("<to_date>").append(mto_date).append("</to_date>"); // valueXmlString.append("<fr_date>").append(mfr_date).append("</fr_date>");
// valueXmlString.append("<price_list>").append(mprice_list).append("</price_list>"); // valueXmlString.append("<to_date>").append(mto_date).append("</to_date>");
// valueXmlString.append("<item_code>").append(mitem_code).append("</item_code>"); // valueXmlString.append("<price_list>").append(mprice_list).append("</price_list>");
// valueXmlString.append("<unit>").append(munit).append("</unit>"); // valueXmlString.append("<item_code>").append(mitem_code).append("</item_code>");
// valueXmlString.append("<list_type>").append(mlist_type).append("</list_type>"); // valueXmlString.append("<unit>").append(munit).append("</unit>");
// valueXmlString.append("<list_type>").append(mlist_type).append("</list_type>");
}
else } */ //Commented By Sagar On 27-JAN-2017 End
if(currentColumn.trim().equals("price_list")) else
{ if(currentColumn.trim().equals("price_list"))
String mlist_type=""; {
String ls_price_list=genericUtility.getColumnValue("price_list",dom); String mlist_type="";
sql="select distinct list_type from pricelist_mst where price_list = '"+ls_price_list+"'"; String ls_price_list=genericUtility.getColumnValue("price_list",dom);
sql="select distinct list_type from pricelist_mst where price_list = '"+ls_price_list+"'";
rs=stmt.executeQuery(sql);
if(rs.next()) rs=stmt.executeQuery(sql);
{ if(rs.next())
mlist_type=rs.getString("list_type"); {
} mlist_type=rs.getString("list_type");
rs.close(); }
rs = null; rs.close();
rs = null;
valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+mlist_type+"]]>").append("</list_type>");
} valueXmlString.append("<list_type protect=\"1\">").append("<![CDATA["+mlist_type+"]]>").append("</list_type>");
else }
if(currentColumn.trim().equals("item_code")) else
{ if(currentColumn.trim().equals("item_code"))
String mcode="",mdescr="",munit="",msite_code=""; {
long mslabno = 0; String mcode="",mdescr="",munit="",msite_code="";
mcode=genericUtility.getColumnValue("item_code",dom); long mslabno = 0;
System.out.println("Item code>>>>>>>" + mcode); mcode=genericUtility.getColumnValue("item_code",dom);
priceList = genericUtility.getColumnValue("price_list",dom) ; System.out.println("Item code>>>>>>>" + mcode);
System.out.println("pRICELIST>>>>>>>>>" + priceList); priceList = genericUtility.getColumnValue("price_list",dom) ;
System.out.println("itemcode>>>>>" + mcode); System.out.println("pRICELIST>>>>>>>>>" + priceList);
sql="SELECT DESCR,UNIT ,SITE_CODE FROM ITEM WHERE ITEM_CODE='"+mcode+"'"; System.out.println("itemcode>>>>>" + mcode);
sql="SELECT DESCR,UNIT ,SITE_CODE FROM ITEM WHERE ITEM_CODE='"+mcode+"'";
rs = stmt.executeQuery(sql);
if(rs.next()) rs = stmt.executeQuery(sql);
{ if(rs.next())
mdescr=rs.getString("descr"); {
munit=rs.getString("unit"); mdescr=rs.getString("descr");
msite_code=rs.getString("site_code"); munit=rs.getString("unit");
} msite_code=rs.getString("site_code");
rs.close(); }
rs = null; rs.close();
rs = null;
valueXmlString.append("<item_descr>").append("<![CDATA["+mdescr+"]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA["+munit+"]]>").append("</unit>"); valueXmlString.append("<item_descr>").append("<![CDATA["+mdescr+"]]>").append("</item_descr>");
valueXmlString.append("<site_code>").append("<![CDATA["+msite_code+"]]>").append("</site_code>"); valueXmlString.append("<unit>").append("<![CDATA["+munit+"]]>").append("</unit>");
valueXmlString.append("<site_code>").append("<![CDATA["+msite_code+"]]>").append("</site_code>");
sql1="SELECT MAX(SLAB_NO) FROM PRICELIST WHERE PRICE_LIST = '" + priceList + "'" +"AND ITEM_CODE = '"+ mcode +"'";
rs1=stmt1.executeQuery(sql1); sql1="SELECT MAX(SLAB_NO) FROM PRICELIST WHERE PRICE_LIST = '" + priceList + "'" +"AND ITEM_CODE = '"+ mcode +"'";
System.out.println("SQL query....."+sql1); rs1=stmt1.executeQuery(sql1);
if(rs1.next()) System.out.println("SQL query....."+sql1);
{ if(rs1.next())
mslabno=rs1.getLong(1); {
valueXmlString.append("<slab_no protect=\"1\">").append(mslabno + 1).append("</slab_no>"); mslabno=rs1.getLong(1);
} valueXmlString.append("<slab_no protect=\"1\">").append(mslabno + 1).append("</slab_no>");
else }
{ else
valueXmlString.append("<slab_no protect=\"1\">").append("1").append("</slab_no>"); {
} valueXmlString.append("<slab_no protect=\"1\">").append("1").append("</slab_no>");
rs1.close(); }
rs1 = null; rs1.close();
rs1 = null;
}
else }
if(currentColumn.trim().equals("unit")) else
{ if(currentColumn.trim().equals("unit"))
String mdescr=""; {
String munit=genericUtility.getColumnValue("unit",dom) ; String mdescr="";
sql="SELECT DESCR FROM UOM WHERE UNIT='"+munit+"'"; String munit=genericUtility.getColumnValue("unit",dom) ;
sql="SELECT DESCR FROM UOM WHERE UNIT='"+munit+"'";
rs = stmt.executeQuery(sql);
if(rs.next()) rs = stmt.executeQuery(sql);
{ if(rs.next())
mdescr=rs.getString("descr"); {
} mdescr=rs.getString("descr");
rs.close(); }
rs = null; rs.close();
rs = null;
valueXmlString.append("<descr>").append("<![CDATA["+mdescr+"]]>").append("</descr>");
} valueXmlString.append("<descr>").append("<![CDATA["+mdescr+"]]>").append("</descr>");
else }
if(currentColumn.trim().equals("list_type") ) else
{ if(currentColumn.trim().equals("list_type") )
String mlist_type="",mrate_type="",mlot_no__from="",mlot_no__to="" ; {
mlist_type= genericUtility.getColumnValue("list_type",dom); String mlist_type="",mrate_type="",mlot_no__from="",mlot_no__to="" ;
mlist_type= genericUtility.getColumnValue("list_type",dom);
if( (mlist_type.equals("M") || mlist_type.equals("N")) )
{ if( (mlist_type.equals("M") || mlist_type.equals("N")) )
mrate_type = genericUtility.getColumnValue("rate_type",dom); {
mlot_no__from = genericUtility.getColumnValue("lot_no__from",dom); mrate_type = genericUtility.getColumnValue("rate_type",dom);
mlot_no__to = genericUtility.getColumnValue("mlot_no__to",dom); mlot_no__from = genericUtility.getColumnValue("lot_no__from",dom);
valueXmlString.append("<rate_type protect = \"1\">").append("<![CDATA["+mrate_type+"]]>").append("</rate_type>"); mlot_no__to = genericUtility.getColumnValue("mlot_no__to",dom);
valueXmlString.append("<lot_no__from protect = \"1\">").append("<![CDATA["+mlot_no__from+"]]>").append("</lot_no__from>"); valueXmlString.append("<rate_type protect = \"1\">").append("<![CDATA["+mrate_type+"]]>").append("</rate_type>");
valueXmlString.append("<lot_no__to protect= \"1\">").append("<![CDATA["+mlot_no__to+"]]>").append("</lot_no__to>"); valueXmlString.append("<lot_no__from protect = \"1\">").append("<![CDATA["+mlot_no__from+"]]>").append("</lot_no__from>");
} valueXmlString.append("<lot_no__to protect= \"1\">").append("<![CDATA["+mlot_no__to+"]]>").append("</lot_no__to>");
else }
{ else
valueXmlString.append("<rate_type protect = \"1\">").append("<![CDATA["+mrate_type+"]]>").append("</rate_type>"); {
valueXmlString.append("<lot_no__from protect = \"0\">").append("<![CDATA["+mlot_no__from+"]]>").append("</lot_no__from>"); valueXmlString.append("<rate_type protect = \"1\">").append("<![CDATA["+mrate_type+"]]>").append("</rate_type>");
valueXmlString.append("<lot_no__to protect = \"0\">").append("<![CDATA["+mlot_no__to+"]]>").append("</lot_no__to>"); valueXmlString.append("<lot_no__from protect = \"0\">").append("<![CDATA["+mlot_no__from+"]]>").append("</lot_no__from>");
valueXmlString.append("<lot_no__to protect = \"0\">").append("<![CDATA["+mlot_no__to+"]]>").append("</lot_no__to>");
}
}
}
}
}//try
catch(Exception e) }//try
{ catch(Exception e)
System.out.println("Exception :[PriceListEJB][itemChanged::case 1::order_type] :==>\n"+e.getMessage()); {
throw new ITMException(e); System.out.println("Exception :[PriceListEJB][itemChanged::case 1::order_type] :==>\n"+e.getMessage());
} throw new ITMException(e);
valueXmlString.append("</Detail>"); }
break; valueXmlString.append("</Detail>");
}//Switch break;
valueXmlString.append("</Root>"); }//Switch
}//try valueXmlString.append("</Root>");
}//try
catch(Exception e)
{ catch(Exception e)
System.out.println("Exception ::"+e.getMessage()); {
} System.out.println("Exception ::"+e.getMessage());
finally }
{ finally
try {
{ try
if (rs != null) {
{ if (rs != null)
rs.close(); {
rs = null; rs.close();
} rs = null;
if(stmt != null) }
{ if(stmt != null)
stmt.close(); {
stmt = null; stmt.close();
} stmt = null;
if (conn != null) }
{ if (conn != null)
conn.close(); {
conn = null; conn.close();
} conn = null;
} }
catch(Exception s){} }
} catch(Exception s){}
return valueXmlString.toString(); }
}//itemChanged() return valueXmlString.toString();
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException }//itemChanged()
{
Document dom = null; // Added By Sagar On 25-JAN-2017 Start
Document dom1 = null; private String checkNull(String input)
Document dom2 = null; {
String errString = null; return input == null ? "" : input.trim();
System.out.println("Entering into validations ..................."); }
try // Added By Sagar On 25-JAN-2017 End
{
dom = parseString(xmlString); public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
dom1 = parseString(xmlString1); {
if (xmlString2.trim().length() > 0 ) Document dom = null;
{ Document dom1 = null;
dom2 = parseString("<Root>" + xmlString2+ "</Root>"); Document dom2 = null;
} String errString = null;
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); System.out.println("Entering into validations ...................");
} try
catch(Exception e) {
{ dom = parseString(xmlString);
System.out.println("Exception : PayableOpeningsEJB : wfValData(String xmlString) : ==>\n"+e.getMessage()); dom1 = parseString(xmlString1);
} if (xmlString2.trim().length() > 0 )
return (errString); {
} dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
{ }
Connection conn = null; catch(Exception e)
Statement stmt = null; {
PreparedStatement pstmt = null; System.out.println("Exception : PayableOpeningsEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
ResultSet rs = null; }
String errString = ""; return (errString);
String errCode = ""; }
String sql = "";
String userId = ""; public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
String custCode = ""; {
String empCodeGiven = ""; Connection conn = null;
String empCodeMerge = ""; Statement stmt = null;
String childNodeName = ""; PreparedStatement pstmt = null;
String priceList = ""; ResultSet rs = null;
String lskeyflag = ""; String errString = "";
int cnt1 = 0; String errCode = "";
NodeList parentNodeList = null; String sql = "";
NodeList childNodeList = null; String userId = "";
Node parentNode = null; String custCode = "";
Node childNode = null; String empCodeGiven = "";
int ctr,currentFormNo=0; String empCodeMerge = "";
int childNodeListLength; String childNodeName = "";
String itemCode = "", unit = "", listType = "", effFromStr = "", validUptoStr = "", lotNoFrom = "", lotNoTo = "", slabno = "",minQty = "",maxQty = ""; String priceList = "";
Timestamp effFrom =null, validUpto = null; String lskeyflag = "";
ArrayList<String> errList = new ArrayList<String>(); int cnt1 = 0;
ArrayList<String> errFields = new ArrayList<String>(); NodeList parentNodeList = null;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); NodeList childNodeList = null;
Node parentNode = null;
try Node childNode = null;
{ int ctr,currentFormNo=0;
conn = getConnection(); int childNodeListLength;
stmt = conn.createStatement(); String itemCode = "", unit = "", listType = "", effFromStr = "", validUptoStr = "", lotNoFrom = "", lotNoTo = "", slabno = "",minQty = "",maxQty = "";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId"); Timestamp effFrom =null, validUpto = null;
System.out.println("userId = "+userId); ArrayList<String> errList = new ArrayList<String>();
System.out.println("xtraParams = "+xtraParams); ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
if(objContext != null && objContext.trim().length()>0) // Added By Sagar on [25-JAN-2017] [Start]
{ int mmaxqty=0 , mminqty = 0,cnt=0;
currentFormNo = Integer.parseInt(objContext); double mrate = 0.0;
} String mmaxqtyStr = "" , mminqtyStr = "" , strvalid_upto="" , strmeff_from = "" , valid_uptoDate = "" ,
eff_fromDate = "" , mitem_code ="" , mactive ="" , mrateStr= "" , mValue ="", ls_plist_parent = "" , Is_price_list = "" ;
//parentNodeList = dom.getElementsByTagName("Detail" + currentFormNo); //ConnDriver connDriver = new ConnDriver();
//parentNode = parentNodeList.item(0); // Added By Sagar on [25-JAN-2017] [End]
//childNodeList = parentNode.getChildNodes(); try
//childNodeListLength = childNodeList.getLength(); {
//for (ctr = 0; ctr < childNodeListLength; ctr++) conn = getConnection();
//{ //conn = connDriver.getConnectDB("DriverITM");
//childNode = childNodeList.item(ctr); stmt = conn.createStatement();
//childNodeName = childNode.getNodeName(); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
//System.out.println("Validation for [" + childNodeName + "]"); System.out.println("userId = "+userId);
switch (currentFormNo) System.out.println("xtraParams = "+xtraParams);
{
case 1: if(objContext != null && objContext.trim().length()>0)
{ {
parentNodeList = dom.getElementsByTagName("Detail1"); currentFormNo = Integer.parseInt(objContext);
parentNode = parentNodeList.item(0); }
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); //parentNodeList = dom.getElementsByTagName("Detail" + currentFormNo);
//parentNode = parentNodeList.item(0);
for(ctr = 0; ctr < childNodeListLength; ctr++) //childNodeList = parentNode.getChildNodes();
{ //childNodeListLength = childNodeList.getLength();
childNode = childNodeList.item(ctr); //for (ctr = 0; ctr < childNodeListLength; ctr++)
childNodeName = childNode.getNodeName(); //{
//childNode = childNodeList.item(ctr);
// ADDED BY RITESH ON 23/SEP/13 START //childNodeName = childNode.getNodeName();
if(childNodeName.equals("price_list")) //System.out.println("Validation for [" + childNodeName + "]");
{ switch (currentFormNo)
NamedNodeMap attrMap = parentNode.getAttributes(); {
String objName = attrMap.getNamedItem( "objName" ).getNodeValue(); case 1:
String winName = "w_"+ objName; {
priceList = genericUtility.getColumnValue("price_list",dom); parentNodeList = dom.getElementsByTagName("Detail1");
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] priceList [ " + priceList + "]"); parentNode = parentNodeList.item(0);
// 14/11/13 manoharan duplicate checking to consider all parameter childNodeList = parentNode.getChildNodes();
itemCode = genericUtility.getColumnValue("item_code",dom); childNodeListLength = childNodeList.getLength();
unit = genericUtility.getColumnValue("unit",dom);
listType = genericUtility.getColumnValue("list_type",dom); for(ctr = 0; ctr < childNodeListLength; ctr++)
effFromStr = genericUtility.getColumnValue("eff_from",dom); {
validUptoStr = genericUtility.getColumnValue("valid_upto",dom); childNode = childNodeList.item(ctr);
lotNoFrom = genericUtility.getColumnValue("lot_no__from",dom); childNodeName = childNode.getNodeName();
lotNoTo = genericUtility.getColumnValue("lot_no__to",dom); if (childNodeName.equals("slab_no"))
slabno = genericUtility.getColumnValue("slab_no",dom) ; {
minQty = genericUtility.getColumnValue("min_qty",dom); }
maxQty = genericUtility.getColumnValue("max_qty", dom); if(childNodeName.equals("tax_base"))
{
// end 14/11/13 manoharan duplicate checking to consider all parameter }
System.out.println("price_list wfvalData :::: " + priceList); // ADDED BY RITESH ON 23/SEP/13 START
// 14/11/13 manoharan commented as always it will be manual if(childNodeName.equals("price_list"))
//sql = "select key_flag from transetup where tran_window = '"+ winName +"'"; {
//pstmt = conn.prepareStatement(sql); NamedNodeMap attrMap = parentNode.getAttributes();
//rs = pstmt.executeQuery(); String objName = attrMap.getNamedItem( "objName" ).getNodeValue();
//if(rs.next()) String winName = "w_"+ objName;
//{ priceList = genericUtility.getColumnValue("price_list",dom);
// lskeyflag = rs.getString("key_flag")== null ?"M":rs.getString("key_flag"); 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);
//rs.close();rs = null; unit = genericUtility.getColumnValue("unit",dom);
//pstmt.close();pstmt = null; listType = genericUtility.getColumnValue("list_type",dom);
// if("M".equals(lskeyflag) && (priceList == null || priceList.trim().length() == 0)) effFromStr = genericUtility.getColumnValue("eff_from",dom);
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) validUptoStr = genericUtility.getColumnValue("valid_upto",dom);
{ lotNoFrom = genericUtility.getColumnValue("lot_no__from",dom);
errCode = "VMCODNULL"; lotNoTo = genericUtility.getColumnValue("lot_no__to",dom);
errList.add(errCode); // Modified By Sagar to check null for dom value on [25-JAN-2017] [Start]
errFields.add(childNodeName.toLowerCase()); slabno = checkNull(genericUtility.getColumnValue("slab_no",dom));
} minQty = checkNull(genericUtility.getColumnValue("min_qty",dom));
else // if ("A".equals(editFlag)) maxQty = checkNull(genericUtility.getColumnValue("max_qty", dom));
{ // Modified By Sagar to to check null for dom value on [25-JAN-2017] [End]
System.out.println("before effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]"); // end 14/11/13 manoharan duplicate checking to consider all parameter
effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); System.out.println("price_list wfvalData :::: " + priceList);
validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); // 14/11/13 manoharan commented as always it will be manual
System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]"); //sql = "select key_flag from transetup where tran_window = '"+ winName +"'";
effFrom = Timestamp.valueOf(effFromStr + " 00:00:00"); //pstmt = conn.prepareStatement(sql);
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00"); //rs = pstmt.executeQuery();
System.out.println("Quantity From [" + minQty + "] Quantity To [" + maxQty + "]"); //if(rs.next())
sql = "select count(*) from pricelist where price_list = ? " //{
+ " and item_code = ? and unit = ? and list_type = ? " // lskeyflag = rs.getString("key_flag")== null ?"M":rs.getString("key_flag");
+ " and eff_from = ? and valid_upto = ? " //
+ " and lot_no__from = ? and lot_no__to = ? " //}
+ " and min_qty = ? and max_qty = ?"; //rs.close();rs = null;
if ("E".equals(editFlag)) //pstmt.close();pstmt = null;
{ // if("M".equals(lskeyflag) && (priceList == null || priceList.trim().length() == 0))
sql = sql + " and slab_no <> " + slabno ; // Modified By Sagar to check null for dom value on [25-JAN-2017] [Start]
} //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)
if(priceList == null || priceList.trim().length() == 0 )
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1,priceList); errCode = "VTLPRCNUL";
pstmt.setString(2,itemCode); errList.add(errCode);
pstmt.setString(3,unit); errFields.add(childNodeName.toLowerCase());
pstmt.setString(4,listType); }
pstmt.setTimestamp(5,effFrom); else if(itemCode == null || itemCode.trim().length() == 0)
pstmt.setTimestamp(6,validUpto); {
pstmt.setString(7,lotNoFrom); errCode = "VTITMNULL";
pstmt.setString(8,lotNoTo); errList.add(errCode);
pstmt.setString(9,minQty); errFields.add(childNodeName.toLowerCase());
pstmt.setString(10,maxQty); }
else if(unit == null || unit.trim().length() == 0 )
rs = pstmt.executeQuery(); {
if(rs.next()) errCode = "VTINVUNIT";
{ errList.add(errCode);
cnt1 = rs.getInt(1); errFields.add(childNodeName.toLowerCase());
} }
rs.close();rs = null; else if(listType == null || listType.trim().length() == 0 )
pstmt.close();pstmt = null; {
if(cnt1 > 0) errCode = "VTLSTNULL";
{ errList.add(errCode);
errCode = "VMDUPL1"; errFields.add(childNodeName.toLowerCase());
errList.add(errCode); }
errFields.add(childNodeName.toLowerCase()); else if(effFromStr == null || effFromStr.trim().length() == 0 )
} {
} errCode = "VTEFFNULL";
errList.add(errCode);
} // ADDED BY RITESH ON 23/SEP/13 END errFields.add(childNodeName.toLowerCase());
else if(childNodeName.equals("item_code")) }
{ else if(validUptoStr == null || validUptoStr.trim().length() == 0 )
System.out.println("childNodeName 1. : " + childNodeName); {
String mitem_code = genericUtility.getColumnValue("item_code",dom); errCode = "VTVLDNULL";
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mitem_code [ " + mitem_code + "]"); errList.add(errCode);
sql="select count(*) as count from item where item_code = '"+mitem_code+"'"; errFields.add(childNodeName.toLowerCase());
rs=stmt.executeQuery(sql); }
System.out.println("SQL"+sql); else if(lotNoFrom == null || lotNoFrom.trim().length() == 0 )
int cnt=0; {
if(rs.next()) errCode = "VTLTFRNUL";
{ errList.add(errCode);
cnt=rs.getInt("count"); errFields.add(childNodeName.toLowerCase());
} }
rs.close(); else if(lotNoTo == null || lotNoTo.trim().length() == 0 )
rs = null; {
if(cnt==0) errCode = "VTLTTONUL";
{ errList.add(errCode);
errCode = "VMITEM_CD"; errFields.add(childNodeName.toLowerCase());
errList.add(errCode); }
errFields.add(childNodeName.toLowerCase()); else // if ("A".equals(editFlag))
} {
sql="select active from item where item_code='"+mitem_code+"'"; System.out.println("before effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
String mactive=null; /*effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
rs=stmt.executeQuery(sql); validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
if(rs.next()) System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
{ effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
mactive=rs.getString("active"); validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");*/
}
rs.close(); if(effFromStr.trim().length() > 0 )
rs = null; {
if(mactive.equals("N")) effFromStr = genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
{ effFrom = Timestamp.valueOf(effFromStr + " 00:00:00");
errCode="VTITEM4"; }
errList.add(errCode); if(validUptoStr.trim().length() > 0 )
errFields.add(childNodeName.toLowerCase()); {
} validUptoStr = genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
validUpto = Timestamp.valueOf(validUptoStr + " 00:00:00");
} }
else if (childNodeName.equals("price_list__parent")) // Modified By Sagar to check null for dom value on [25-JAN-2017] [End]
{ System.out.println("after effFromStr [" + effFromStr + "] validUptoStr [" + validUptoStr + "]");
String ls_plist_parent,Is_price_list; System.out.println("Quantity From [" + minQty + "] Quantity To [" + maxQty + "]");
System.out.println("childNodeName 1. : " + childNodeName);
ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom); sql = "select count(*) from pricelist where price_list = ? "
Is_price_list = genericUtility.getColumnValue("price_list",dom); + " and item_code = ? and unit = ? and list_type = ? "
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] ls_plist_parent [ " + ls_plist_parent + "] Is_price_list [" + Is_price_list + "]"); + " and eff_from = ? and valid_upto = ? "
//System.out.println("childNode.getFirstChild() 1. : " + childNode.getFirstChild()); + " and lot_no__from = ? and lot_no__to = ? "
//if (ls_plist_parent == null || ls_plist_parent.trim().length() == 0) // + " and min_qty = ? and max_qty = ?";
if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/ if ("E".equals(editFlag))
{ {
if(ls_plist_parent.trim().equals(Is_price_list.trim()) ) sql = sql + " and slab_no <> " + slabno ;
}
errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId); pstmt = conn.prepareStatement(sql);
errList.add(errCode); pstmt.setString(1,priceList);
errFields.add(childNodeName.toLowerCase()); pstmt.setString(2,itemCode);
} pstmt.setString(3,unit);
} pstmt.setString(4,listType);
else if (childNodeName.equals("min_qty")) pstmt.setTimestamp(5,effFrom);
{ pstmt.setTimestamp(6,validUpto);
int mmaxqty,mminqty; pstmt.setString(7,lotNoFrom);
mminqty =Integer.parseInt(genericUtility.getColumnValue("min_qty",dom)); pstmt.setString(8,lotNoTo);
mmaxqty=Integer.parseInt(genericUtility.getColumnValue("max_qty",dom)); pstmt.setString(9,minQty);
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]"); pstmt.setString(10,maxQty);
rs = pstmt.executeQuery();
if (mmaxqty < mminqty ) if(rs.next())
{ {
errCode = "VMMINQTY"; cnt1 = rs.getInt(1);
errList.add(errCode); }
errFields.add(childNodeName.toLowerCase()); if(rs != null){
} rs.close();
rs = null;
}
} if(pstmt != null){
else if(childNodeName.equals("valid_upto")) pstmt.close();
{ pstmt = null;
Timestamp mvalid_upto,meff_from; }
String strvalid_upto,strmeff_from;
strvalid_upto=genericUtility.getColumnValue("valid_upto",dom) ; if(cnt1 > 0)
strmeff_from=genericUtility.getColumnValue("eff_from",dom); {
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
String valid_uptoDate=getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); }
String eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); }
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
} // ADDED BY RITESH ON 23/SEP/13 END
mvalid_upto = Timestamp.valueOf(valid_uptoDate+" 00:00:00"); // Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
meff_from = Timestamp.valueOf(eff_fromDate+" 00:00:00"); /*else if(childNodeName.equals("item_code"))
{
if( ( mvalid_upto.compareTo( meff_from) ) ==0 ) System.out.println("childNodeName 1. : " + childNodeName);
{ String mitem_code = genericUtility.getColumnValue("item_code",dom);
errCode="VMVAL_UPTO"; System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mitem_code [ " + mitem_code + "]");
errList.add(errCode); sql="select count(*) as count from item where item_code = '"+mitem_code+"'";
errFields.add(childNodeName.toLowerCase()); rs=stmt.executeQuery(sql);
} System.out.println("SQL"+sql);
} int cnt=0;
if(rs.next())
else if(childNodeName.equals("tax_code")) {
{ cnt=rs.getInt("count");
String mValue=genericUtility.getColumnValue("tax_code",dom); }
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mValue [ " + mValue + "]"); rs.close();
sql="Select Count(*) as count from tax where tax_code = '"+mValue+"'"; rs = null;
rs=stmt.executeQuery(sql); if(cnt==0)
System.out.println("SQL"+sql); {
if(rs.next()) errCode = "VMITEM_CD";
{ errList.add(errCode);
int cnt=rs.getInt("count"); errFields.add(childNodeName.toLowerCase());
}
if(cnt==0) sql="select active from item where item_code='"+mitem_code+"'";
{ String mactive=null;
errCode = "VTTAX1"; rs=stmt.executeQuery(sql);
errList.add(errCode); if(rs.next())
errFields.add(childNodeName.toLowerCase()); {
} mactive=rs.getString("active");
} }
rs.close(); rs.close();
rs = null; rs = null;
} if(mactive.equals("N"))
{
else if(childNodeName.equals("rate") || childNodeName.equals("min_rate") || childNodeName.equals("max_rate") ) // 20/10/14 manoharan min_rate and max_rate included errCode="VTITEM4";
{ errList.add(errCode);
double mrate; // 20/10/14 manoharan changes from integer to double errFields.add(childNodeName.toLowerCase());
mrate= Double.parseDouble(genericUtility.getColumnValue(childNodeName,dom) ); }
System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if(mrate<=0) }*/
{ if("item_code".equalsIgnoreCase(childNodeName))
errCode="VTRATE2"; {
errList.add(errCode); System.out.println("childNodeName 1. : " + childNodeName);
errFields.add(childNodeName.toLowerCase()); mitem_code = checkNull(genericUtility.getColumnValue("item_code",dom));
} if(mitem_code == null || mitem_code.length() == 0)
{
} errCode = "VTITMNULL";
errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
}
} System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mitem_code [ " + mitem_code + "]");
}//switch sql="select count(*) as count from item where item_code = '"+mitem_code+"'";
//}//for rs=stmt.executeQuery(sql);
int errListSize = errList.size(); System.out.println("SQL"+sql);
int cnt = 0; //int cnt=0;
String errFldName = null, errorType = null; if(rs.next())
System.out.println("errListSize ..........[" + errListSize + "]"); {
if(errList != null && errListSize > 0) cnt=rs.getInt("count");
{ }
for(cnt = 0; cnt < errListSize; cnt ++) if(rs != null){
{ rs.close();
errCode = errList.get(cnt); rs = null;
errFldName = errFields.get(cnt); }
System.out.println("errCode ..........[" + errCode + "]");
errString = getErrorString(errFldName, errCode, userId); if(cnt==0)
errorType = errorType(conn , errCode); {
if(errString.length() > 0) errCode = "VMITEM_CD";
{ errList.add(errCode);
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); errFields.add(childNodeName.toLowerCase());
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); }
errStringXml.append(bifurErrString); else
errString = ""; {
} sql="select active from item where item_code='"+mitem_code+"'";
if(errorType.equalsIgnoreCase("E")) rs=stmt.executeQuery(sql);
{ if(rs.next())
break; {
} mactive=checkNull(rs.getString("active"));
} }
errList.clear();
errList = null; if(rs != null){
errFields.clear(); rs.close();
errFields = null; rs = null;
errStringXml.append("</Errors> </Root> \r\n"); }
} if("N".equalsIgnoreCase(mactive))
else {
{ errCode="VTITEM4";
errStringXml = new StringBuffer(""); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
}
}//try }
catch(Exception e) }
{ // Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
System.out.println("Exception ::"+e); // Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
e.printStackTrace(); /*else if (childNodeName.equals("price_list__parent"))
} {
finally String ls_plist_parent,Is_price_list;
{ System.out.println("childNodeName 1. : " + childNodeName);
try ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom);
{ Is_price_list = genericUtility.getColumnValue("price_list",dom);
System.out.println("Closing Connection....."); System.out.println("20/10/14 manohar validation for [" + childNodeName + "] ls_plist_parent [ " + ls_plist_parent + "] Is_price_list [" + Is_price_list + "]");
if (rs != null) //System.out.println("childNode.getFirstChild() 1. : " + childNode.getFirstChild());
{ //if (ls_plist_parent == null || ls_plist_parent.trim().length() == 0) //
rs.close(); if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/
rs = null; {
} if(ls_plist_parent.trim().equals(Is_price_list.trim()) )
if(stmt != null)
{ errCode = "VTPARENTPL";
stmt.close(); errString = getErrorString("price_list__parent",errCode,userId);
stmt = null; errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
if (conn != null) }
{ }*/
conn.close(); if ("price_list__parent".equalsIgnoreCase(childNodeName))
conn = null; {
} System.out.println("childNodeName 1. : " + childNodeName);
}catch(Exception se){} ls_plist_parent = genericUtility.getColumnValue("price_list__parent",dom);
} Is_price_list = genericUtility.getColumnValue("price_list",dom);
errString = errStringXml.toString(); System.out.println("25-JAN-2017 validation for [" + childNodeName + "] ls_plist_parent [ " + ls_plist_parent + "] Is_price_list [" + Is_price_list + "]");
System.out.println("ErrString ::"+errString); if (ls_plist_parent != null && ls_plist_parent.trim().length() > 0)// manoharan commented wrong condition/
{
if(ls_plist_parent.equalsIgnoreCase((Is_price_list)))
return errString;
}//wfValData errCode = "VTPARENTPL";
errString = getErrorString("price_list__parent",errCode,userId);
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
// Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
public String getValidDateTimeString(String dateTimeStr, String sourceDateTimeFormat, String targetDateTimeFormat) throws ITMException /*else if (childNodeName.equals("min_qty"))
{ {
System.out.println("Getting the valid datetime string for dateTimeStr :"+dateTimeStr+": which is in format :"+sourceDateTimeFormat); int mmaxqty,mminqty;
Object date = null; mminqty =Integer.parseInt(genericUtility.getColumnValue("min_qty",dom));
String retDateStr = ""; mmaxqty=Integer.parseInt(genericUtility.getColumnValue("max_qty",dom));
try System.out.println("20/10/14 manohar validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
{
if (!(sourceDateTimeFormat.equalsIgnoreCase(targetDateTimeFormat)))
{ if (mmaxqty < mminqty )
if (sourceDateTimeFormat.indexOf("/") != -1) {
{ errCode = "VMMINQTY";
dateTimeStr.replace('/', '-'); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
else if (sourceDateTimeFormat.indexOf(".") != -1) }
{ }*/
dateTimeStr.replace('.', '-'); if ("min_qty".equalsIgnoreCase(childNodeName))
} {
date = new SimpleDateFormat(sourceDateTimeFormat).parse(dateTimeStr); mminqtyStr = checkNull(genericUtility.getColumnValue("min_qty",dom));
SimpleDateFormat sdfOutput = new SimpleDateFormat(targetDateTimeFormat); mmaxqtyStr = checkNull(genericUtility.getColumnValue("max_qty",dom));
retDateStr = sdfOutput.format(date); if(mminqtyStr == null || mminqtyStr.length() == 0)
} {
else errCode = "VTMMINQTY";
{ errList.add(errCode);
retDateStr = dateTimeStr; errFields.add(childNodeName.toLowerCase());
} }
} if(mmaxqtyStr.length() > 0)
catch (Exception e) {
{ mmaxqty=Integer.parseInt(mmaxqtyStr);
System.out.println("Exception :GenericUtility :getValidDateString :==>"+e.getMessage()); }
throw new ITMException(e); else
} {
System.out.println("retDateStr :"+retDateStr); mmaxqty = 0;
return retDateStr; }
} if(mminqtyStr.length() > 0)
private String errorType(Connection conn, String errorCode) throws ITMException {
{ mminqty =Integer.parseInt(mminqtyStr);
String msgType = ""; }
PreparedStatement pstmt = null; else
ResultSet rs = null; {
try mminqty = 0;
{ }
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
pstmt = conn.prepareStatement(sql); if (mmaxqty < mminqty )
pstmt.setString(1, errorCode); {
rs = pstmt.executeQuery(); errCode = "VMMINQTY";
if (rs.next()) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
msgType = rs.getString("MSG_TYPE"); }
} }
rs.close(); if("max_qty".equalsIgnoreCase(childNodeName))
rs = null; {
pstmt.close(); mmaxqtyStr = checkNull(genericUtility.getColumnValue("max_qty",dom));
pstmt = null; mminqtyStr = checkNull(genericUtility.getColumnValue("min_qty",dom));
} catch (Exception ex) if(mmaxqtyStr == null || mmaxqtyStr.length() == 0)
{ {
ex.printStackTrace(); errCode = "VTMMAXQTY";
throw new ITMException(ex); errList.add(errCode);
} finally errFields.add(childNodeName.toLowerCase());
{ }
try if(mmaxqtyStr.length() > 0)
{ {
if (rs != null) mmaxqty=Integer.parseInt(mmaxqtyStr);
{ }
rs.close(); else
rs = null; {
} mmaxqty = 0;
if (pstmt != null) }
{ if(mminqtyStr.length() > 0)
pstmt.close(); {
pstmt = null; mminqty =Integer.parseInt(mminqtyStr);
} }
} catch (Exception e) else
{ {
e.printStackTrace(); mminqty = 0;
throw new ITMException(e); }
} System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mmaxqty [ " + mmaxqty + "] mminqty [" + mminqty + "]");
} if (mmaxqty < mminqty )
return msgType; {
} errCode = "VMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
//Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*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.getApplDateFormat(),genericUtility.getDBDateFormat());
String eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.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");
if( ( mvalid_upto.compareTo( meff_from) ) ==0 )
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
*/
if("valid_upto".equalsIgnoreCase(childNodeName))
{
strvalid_upto = checkNull(genericUtility.getColumnValue("valid_upto",dom)) ;
strmeff_from = checkNull(genericUtility.getColumnValue("eff_from",dom));
if(strvalid_upto.length() > 0 )
{
valid_uptoDate = getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
//mvalid_upto = Timestamp.valueOf(valid_uptoDate+" 00:00:00");
}else{
errCode="VTVLDNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(strmeff_from.length() > 0 )
{
eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
//meff_from = Timestamp.valueOf(eff_fromDate+" 00:00:00");
}
else
{
errCode="VTEFFNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
if(valid_uptoDate.compareTo(eff_fromDate) <= 0)
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("eff_from".equalsIgnoreCase(childNodeName))
{
strvalid_upto = checkNull(genericUtility.getColumnValue("valid_upto",dom)) ;
strmeff_from = checkNull(genericUtility.getColumnValue("eff_from",dom));
if(strvalid_upto.length() > 0 )
{
valid_uptoDate = getValidDateTimeString(strvalid_upto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
}
else
{
errCode="VTVLDNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(strmeff_from.length() > 0 )
{
eff_fromDate= getValidDateTimeString(strmeff_from,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
}
else
{
errCode="VTEFFNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] valid_uptoDate [ " + valid_uptoDate + "] eff_fromDate [" + eff_fromDate + "]");
if(valid_uptoDate.compareTo(eff_fromDate) <= 0)
{
errCode="VMVAL_UPTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
//else if(childNodeName.equals("tax_code"))
// Modified By Sagar to check null for dom value[25-JAN-17] [Start]
//SIR
if("tax_code".equalsIgnoreCase(childNodeName))
{
//String mValue=genericUtility.getColumnValue("tax_code",dom);
mValue=checkNull(genericUtility.getColumnValue("tax_code",dom));
// Modified By Sagar to check null for dom value[25-JAN-17] [End]
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())
{
cnt=rs.getInt("count");
}
if(rs != null){
rs.close();
rs = null;
}
if(cnt==0)
{
errCode = "VTTAX1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// //Modified By Sagar to check null for dom value On [25-JAN-2017] [Start]
/*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());
}
}*/
if("rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTRATE2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("min_rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTMINRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if("max_rate".equalsIgnoreCase(childNodeName))
{
mrateStr = checkNull(genericUtility.getColumnValue(childNodeName,dom));
if(mrateStr.length() > 0)
{
mrate = Double.parseDouble(mrateStr);
}
else
{
mrate = 0 ;
}
System.out.println("25-JAN-2017 validation for [" + childNodeName + "] mrate [ " + mrate + "]");
if( mrate <= 0 )
{
errCode="VTMAXVRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//Modified By Sagar to check null for dom value On [25-JAN-2017] [End]
}
}
break;
}//switch
//}//for
int errListSize = errList.size();
int cntErr = 0;
String errFldName = null, errorType = null;
System.out.println("errListSize ..........[" + errListSize + "]");
if(errList != null && errListSize > 0)
{
for(cntErr = 0; cntErr < errListSize; cntErr ++)
{
errCode = errList.get(cntErr);
errFldName = errFields.get(cntErr);
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)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
}
finally
{
try
{
System.out.println("Closing Connection.....");
if (rs != null)
{
rs.close();
rs = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}catch(Exception se){}
}
errString = errStringXml.toString();
System.out.println("ErrString ::"+errString);
return errString;
}//wfValData
public String getValidDateTimeString(String dateTimeStr, String sourceDateTimeFormat, String targetDateTimeFormat) throws ITMException
{
System.out.println("Getting the valid datetime string for dateTimeStr :"+dateTimeStr+": which is in format :"+sourceDateTimeFormat);
Object date = null;
String retDateStr = "";
try
{
if (!(sourceDateTimeFormat.equalsIgnoreCase(targetDateTimeFormat)))
{
if (sourceDateTimeFormat.indexOf("/") != -1)
{
dateTimeStr.replace('/', '-');
}
else if (sourceDateTimeFormat.indexOf(".") != -1)
{
dateTimeStr.replace('.', '-');
}
date = new SimpleDateFormat(sourceDateTimeFormat).parse(dateTimeStr);
SimpleDateFormat sdfOutput = new SimpleDateFormat(targetDateTimeFormat);
retDateStr = sdfOutput.format(date);
}
else
{
retDateStr = dateTimeStr;
}
}
catch (Exception e)
{
System.out.println("Exception :GenericUtility :getValidDateString :==>"+e.getMessage());
throw new ITMException(e);
}
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;
}
}//class }//class
\ 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