Commit 743fa7e4 authored by Ajit Deshmukh's avatar Ajit Deshmukh

Added validations and item change

parent 032c6f10
......@@ -51,7 +51,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams,String formName) throws RemoteException,ITMException
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
......@@ -95,7 +95,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams,String formName) throws RemoteException,ITMException
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
E12GenericUtility genericUtility = new ibase.utility.E12GenericUtility();
......@@ -114,6 +114,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{
Connection connectionObject = null;
PreparedStatement pstmt = null;
ResultSet rSet = null ;
ResultSet rs = null ;
String propDateValue = "";
int firstMonth = 01;
int lastMonth = 12;
......@@ -128,6 +130,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{
AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
itmDBAccessLocal = new ITMDBAccessEJB();
String sql="";
System.out.println("wfValData objContext StrgBrandActWiz:: ["+objContext+"]");
if(objContext != null && objContext.trim().length()>0)
{
......@@ -135,6 +139,139 @@ public class ReqForQuotationWiz extends ValidatorEJB{
}
switch ( currentFormNo )
{
case 1:
{
if( errString.indexOf( "<Errors>" ) == -1 )
{
parentList = dom.getElementsByTagName("Detail"+ currentFormNo);
int parentNodeListLength = parentList.getLength();
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++ )
{
parentNode = parentList.item(prntCtr);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
childNodeName = childNode.getNodeName();
BaseLogger.log("3", null, null, "ReqForQuotationWiz childNodeName [" + childNodeName + "]");
if( childNodeName.equalsIgnoreCase("cust_code") )
{
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz custCode wfValData case 1 [" + custCode + "]");
String checkCustCodeSql = "select count(cust_code) as custCodeCount from customer where cust_code = ?";
PreparedStatement checkCustCodePs = connectionObject.prepareStatement(checkCustCodeSql);
checkCustCodePs.setString(1, custCode);
ResultSet checkCustCodeRs = checkCustCodePs.executeQuery();
while(checkCustCodeRs.next()) {
int custCodeCont = checkCustCodeRs.getInt("custCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationWiz custCode wfValData case 1 custCodeCont::[" + custCodeCont + "]");
if(custCodeCont<=0) {
errString = getErrorString("cust_code", "VTCUST1", userId);
break;
}
}
if(checkCustCodeRs != null)
{
checkCustCodeRs.close();
checkCustCodeRs = null;
}
if(checkCustCodePs != null)
{
checkCustCodePs.close();
checkCustCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("site_code") )
{
String siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz siteCode wfValData case 1 [" + siteCode + "]");
String checkSiteCodeSql = "select count(site_code) as siteCodeCount from site where site_code = ?";
PreparedStatement checkSiteCodePs = connectionObject.prepareStatement(checkSiteCodeSql);
checkSiteCodePs.setString(1, siteCode);
ResultSet checkSiteCodeRs = checkSiteCodePs.executeQuery();
while(checkSiteCodeRs.next()) {
int siteCodeCont = checkSiteCodeRs.getInt("siteCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationWiz siteCode wfValData case 1 siteCodeCont::[" + siteCodeCont + "]");
if(siteCodeCont<=0) {
errString = getErrorString("site_code", "VTSITCD1", userId);
break;
}
}
if(checkSiteCodeRs != null)
{
checkSiteCodeRs.close();
checkSiteCodeRs = null;
}
if(checkSiteCodePs != null)
{
checkSiteCodePs.close();
checkSiteCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("item_ser") )
{
String itemSerStr = checkNull(genericUtility.getColumnValue("item_ser", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemSerStr wfValData case 1 [" + itemSerStr + "]");
if (itemSerStr != null && itemSerStr.length() > 0) {
String[] itemSerArr = itemSerStr.split(",");
for (String itemSer : itemSerArr) {
BaseLogger.log("3", null, null, "ReqForQuotationWiz item_ser wfValData case 1 itemSer [" + itemSer + "]");
sql = "SELECT count(1) FROM itemser WHERE item_ser = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, itemSer.trim());
rs = pstmt.executeQuery();
long count = 0;
if (rs.next()) {
count = rs.getLong(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count == 0) {
errString = getErrorString("item_ser", "VTITEMSER1", userId);
break;
}
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
}//end of inner for loop
}//end of first for loop
}
break;
}
case 2:
{
if( errString.indexOf( "<Errors>" ) == -1 )
......@@ -159,28 +296,60 @@ public class ReqForQuotationWiz extends ValidatorEJB{
columnValue = childNode.getFirstChild().getNodeValue();
}
childNodeName = childNode.getNodeName();
BaseLogger.log("3", null, null, "ReqForQuotationWiz childNodeName [" + childNodeName + "]");
if( childNodeName.equalsIgnoreCase("item_code") )
{
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 [" + itemCode + "]");
String checkItemCodeSql = "select count(item_code) as itemCodeCount from item where cust_code = ?";
PreparedStatement checkItemCodePs = connectionObject.prepareStatement(checkItemCodeSql);
checkItemCodePs.setString(1, itemCode);
ResultSet checkItemCodeRs = checkItemCodePs.executeQuery();
while(checkItemCodeRs.next()) {
int itemCodeCont = checkItemCodeRs.getInt("itemCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 itemCodeCont::[" + itemCodeCont + "]");
if(itemCodeCont<=0) {
errString = getErrorString("item_code", "STKVALITNE", userId);
break;
}
}
if(checkItemCodeRs != null)
{
checkItemCodeRs.close();
checkItemCodeRs = null;
}
if(checkItemCodePs != null)
{
checkItemCodePs.close();
checkItemCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("ptr_flag") )
{
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String competitorRate = checkNull(genericUtility.getColumnValue("competitor_rate", dom));
String competitorItem = checkNull(genericUtility.getColumnValue("competitor_item", dom));
String competitorName = checkNull(genericUtility.getColumnValue("competitor_name", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC ptrFlag wfValData [" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorRate wfValData [" + competitorRate + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorItem wfValData [" + competitorItem + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorNane wfValData [" + competitorName + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz ptrFlag wfValData [" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz competitorRate wfValData [" + competitorRate + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz competitorItem wfValData [" + competitorItem + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz competitorNane wfValData [" + competitorName + "]");
if (ptrFlag.equalsIgnoreCase("N") || ptrFlag.trim().isEmpty()) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition ptrFlag wfValData::: [" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz in condition ptrFlag wfValData::: [" + ptrFlag + "]");
// Check if any of the competitor fields are null or blank
if ((competitorRate == null || competitorRate.trim().isEmpty())
|| (competitorItem == null || competitorItem.trim().isEmpty())
|| (competitorName == null || competitorName.trim().isEmpty())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in competitor details null [" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz in competitor details null [" + ptrFlag + "]");
errString = getErrorString("ptr_flag", "COMPDETM", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in competitor details null errString:: [" + errString + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz in competitor details null errString:: [" + errString + "]");
break;
}
}
......@@ -189,6 +358,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
}//end of inner for loop
}//end of first for loop
}//end of errorstring
break;
}
}//end of validation of first form
......@@ -498,21 +668,28 @@ public class ReqForQuotationWiz extends ValidatorEJB{
String custCodeForIC = checkNull(genericUtility.getColumnValue("cust_code",dom,"1"));
String custName = "";
String custName = "",addr1="", addr2="", addr3="";
BaseLogger.log("0", null,userId,"case 1---------custCodeForIC------[" +custCodeForIC + "]");
String custNameSql = "select cust_name from customer where cust_code = ?";
String custNameSql = "select cust_name, addr1 , addr2 , addr3 from customer where cust_code = ?";
PreparedStatement custNamePs = conn.prepareStatement(custNameSql);
custNamePs.setString(1, custCodeForIC);
ResultSet custNameRs = custNamePs.executeQuery();
while(custNameRs.next()) {
custName = custNameRs.getString("cust_name");
addr1 = custNameRs.getString("addr1");
addr2 = custNameRs.getString("addr2");
addr3 = custNameRs.getString("addr3");
}
valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"qc_resentry_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" );
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName + "]]>").append("</cust_name>");
valueXmlString.append("<addr1>").append("<![CDATA[" + addr1 + "]]>").append("</addr1>");
valueXmlString.append("<addr2>").append("<![CDATA[" + addr2 + "]]>").append("</addr2>");
valueXmlString.append("<addr3>").append("<![CDATA[" + addr3 + "]]>").append("</addr3>");
valueXmlString.append("</Detail"+objContext+">");
if (custNameRs != null)
......
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