Commit 42d3109b authored by Ajit Deshmukh's avatar Ajit Deshmukh

Added checkNull method while fetching the value from the DOM

parent 06ad2fba
......@@ -316,7 +316,7 @@ public class ReqForQuotationConfirm extends ActionHandlerEJB {
InputSource is = new InputSource(new StringReader(processRequestResult));
Document doc = builder.parse(is);
// 🔹 Check SUCCESS
// =9 Check SUCCESS
NodeList detailNodeList = doc.getElementsByTagName("Detail");
if (detailNodeList != null && detailNodeList.getLength() > 0) {
......@@ -325,7 +325,7 @@ public class ReqForQuotationConfirm extends ActionHandlerEJB {
if ("Success".equalsIgnoreCase(detailValue)) {
BaseLogger.log("3", null, null, "Transaction SUCCESS");
// Success logic
//  Success logic
String tranIdOfSalesQuotaion = doc.getElementsByTagName("TranID").item(0)
.getTextContent();
BaseLogger.log("3", null, null,
......@@ -414,6 +414,12 @@ public class ReqForQuotationConfirm extends ActionHandlerEJB {
}
} else {
BaseLogger.log("3", null, null, "Sales Quotation Generation Failed: ");
errString = itmdbAccessLocal.getErrorString(
"confirmed",
"VTCONFERR",
"",
"",
conn);
}
} catch (Exception e) {
......@@ -504,4 +510,4 @@ public class ReqForQuotationConfirm extends ActionHandlerEJB {
return result;
}
}
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
/**
* AUTHOR : MANISH MHATRE 10-3-2021
* COMPONENT : VALIDATION AND ITEMCHANGE OF SALES QUOTATION
**/
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
@Stateless
public class SalesQuotationIC extends ValidatorEJB implements ValidatorLocal,ValidatorRemote
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
DistCommon distCommon = new DistCommon();
FinCommon finCommon = new FinCommon();
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
String retString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
BaseLogger.log("3", getUserInfo(), null, "xmlString............." + xmlString);
BaseLogger.log("3", getUserInfo(), null, "xmlString1............" + xmlString1);
BaseLogger.log("3", getUserInfo(), null, "xmlString2............" + xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = wfValData(dom, dom1, dom2, objContext, editFlag,xtraParams);
BaseLogger.log("3", getUserInfo(), null, "ErrString :" + retString);
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
NodeList parentList = null;
Node parentNode = null;
NodeList childList = null;
Node childNode = null;
String childNodeName = "";
String userId = "";
Connection conn = null;
int currentFormNo = 0;
int ctr = 0;
int cnt = 0;
String siteCode = "" , modName = "";
String custCode="",currCode="",empCodeConf="",itemCode="",unit="",unitRate="",crTerm="",dlvTerm="",packCode="";
String taxClass="",taxChap="",taxEnv="", custCodeStk="", stockistCode="";
Timestamp quotDate = null;
SimpleDateFormat dateFormat = null;
UtilMethods utilMethods = new UtilMethods();
DistCommon disCommon = new DistCommon();
FinCommon finCommon = new FinCommon();
String sql = "",salesPers = "",opprId = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String errCode = "" , errString = "" , errorType = "";
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
{
BaseLogger.log("3", getUserInfo(), null, "Inside wfValdata ***********");
conn = getConnection();
dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo)
{
case 1:
{
parentList = dom.getElementsByTagName("Detail1");
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
// Mohammed.D 20-04-2026 addid date validation for effective_date and valid_upto
// ================== DATE VALIDATION ==================
String effDateStr = checkNull(genericUtility.getColumnValue("eff_date", dom));
String validUptoStr = checkNull(genericUtility.getColumnValue("valid_upto", dom));
Timestamp effDate = null;
Timestamp validUpto = null;
if(effDateStr.trim().length() > 0) {
effDate = Timestamp.valueOf(
genericUtility.getValidDateString(
effDateStr,
genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat()
) + " 00:00:00.0"
);
}
if(validUptoStr.trim().length() > 0) {
validUpto = Timestamp.valueOf(
genericUtility.getValidDateString(
validUptoStr,
genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat()
) + " 00:00:00.0"
);
}
if(effDate != null && validUpto != null && effDate.after(validUpto)) {
errCode = "VTINVEFDT";
errList.add(errCode);
errFields.add("eff_date");
errFields.add("valid_upto");
}
for (ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = genericUtility.getColumnValue("cust_code", dom);
BaseLogger.log("3", getUserInfo(), null, "custCode ["+custCode+"]");
if(custCode == null || custCode.trim().length() == 0)
{
errCode="VMCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql="select count(*) from customer where cust_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt==0)
{
errCode="VTCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("curr_code"))
{
currCode= genericUtility.getColumnValue("curr_code", dom);
if(currCode==null || currCode.trim().length()==0)
{
errCode="VECUR2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql="select count(*) from currency where curr_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt==0)
{
errCode="VTCURRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("emp_code__conf")) {
empCodeConf = genericUtility.getColumnValue("em_code__conf", dom);
if (empCodeConf != null && empCodeConf.trim().length() > 0) {
sql = "select count(*) from employee where emp_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeConf);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (cnt == 0) {
errCode = "VMEMP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("cr_term"))
{
crTerm= genericUtility.getColumnValue("cr_term", dom);
if(crTerm!=null && crTerm.trim().length()>0)
{
sql = "select count(*) from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTCRTERM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("item_ser"))
{
String itemSer= genericUtility.getColumnValue("item_ser", dom);
if (itemSer == null || itemSer.trim().length() == 0) {
errCode = "VTITEMSER5";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from itemser where item_ser = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTITMSER1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("dlv_term"))
{
dlvTerm= genericUtility.getColumnValue("dlv_term", dom);
if(dlvTerm!=null && dlvTerm.trim().length()>0)
{
sql = "select count(*) from delivery_term where dlv_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dlvTerm);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMDLVTERM1"; //new message defined
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("sales_pers")) {
salesPers = genericUtility.getColumnValue("sales_pers", dom);
if (salesPers != null && salesPers.trim().length() > 0) {
sql = "select count(*) from sales_pers where sales_pers= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, salesPers);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (cnt == 0) {
errCode = "VTSALPRN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("oppr_id")) {
opprId = genericUtility.getColumnValue("oppr_id", dom);
if (opprId != null && opprId.trim().length() > 0) {
sql = "select count(*) from opportunity where oppr_id= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, opprId);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (cnt == 0) {
errCode = "VTOPPRID";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//Added By Sakshi P on 29/Oct/2025
// tax_class
else if (childNodeName.equalsIgnoreCase("tax_class")) {
taxClass = checkNull(genericUtility.getColumnValue("tax_class", dom));
BaseLogger.log("3", getUserInfo(), null, "taxClass: " + taxClass);
if (taxClass.trim().length() != 0) {
if (!(isExist(conn, "taxclass", "tax_class", taxClass))) {
errCode = "VTTCLASS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
BaseLogger.log("3", getUserInfo(), null, "Tax class not define in tax class master.");
}
}
}
// tax_chap
else if (childNodeName.equalsIgnoreCase("tax_chap")) {
taxChap = checkNull(genericUtility.getColumnValue("tax_chap", dom));
BaseLogger.log("3", getUserInfo(), null, "taxChap: " + taxChap);
if (taxChap.trim().length() > 0) {
if (!(isExist(conn, "taxchap", "tax_chap", taxChap))) {
errCode = "VTTCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
BaseLogger.log("3", getUserInfo(), null, "Tax chapter not define in tax chapter master");
}
}
}
// tax_env
else if (childNodeName.equalsIgnoreCase("tax_env")) {
taxEnv = checkNull(genericUtility.getColumnValue("tax_env", dom));
quotDate = Timestamp.valueOf(
genericUtility.getValidDateString(genericUtility.getColumnValue("quot_date", dom),
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())
+ " 00:00:00.0");
if (taxEnv.trim().length() != 0) {
if (!(isExist(conn, "taxenv", "tax_env", taxEnv))) {
errCode = "VTTENV1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
BaseLogger.log("3", getUserInfo(), null, "TAX ENVIRONMENT NOT DEFINED");
} else {
errCode = distCommon.getCheckTaxEnvStatus(taxEnv, quotDate, "S", conn);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
BaseLogger.log("3", getUserInfo(), null, "TAX ENVIRONMENT NOT DEFINED");
}
}
}
}
} // end for
} // End of Case 1
break;
case 2 :
{
parentList = dom.getElementsByTagName("Detail" + currentFormNo);
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
for (ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code", dom);
if(itemCode==null || itemCode.trim().length()==0)
{
errCode = "VITMCODE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTITEM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("unit"))
{
unit= genericUtility.getColumnValue("unit", dom);
if(unit==null || unit.trim().length()==0)
{
errCode = "VMUNIT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from uom where unit = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unit);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTUNIT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("unit__rate"))
{
unitRate= genericUtility.getColumnValue("unit__rate", dom);
if(unitRate==null || unitRate.trim().length()==0)
{
//errCode = "VMBUSUNI01";
errCode = "VMUNIT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from uom where unit = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitRate);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTUNIT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("quantity"))
{
String qtyStr = genericUtility.getColumnValue("quantity", dom);
double qtyVal = (qtyStr == null || qtyStr.trim().length() == 0) ? 0 : Double.parseDouble(qtyStr);
if(qtyVal < 0)
{
errCode = "VTQTYN"; // Quantity cannot be negative
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("rate"))
{
String rateStr = genericUtility.getColumnValue("rate", dom);
double rateVal = (rateStr == null || rateStr.trim().length() == 0) ? 0 : Double.parseDouble(rateStr);
if(rateVal < 0)
{
errCode = "VTRATENEG"; // Rate cannot be negative
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("cr_term"))
{
crTerm= genericUtility.getColumnValue("cr_term", dom);
if(crTerm!=null && crTerm.trim().length()>0)
{
sql = "select count(*) from crterm where cr_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTCRTERM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("dlv_term"))
{
dlvTerm= genericUtility.getColumnValue("dlv_term", dom);
if(dlvTerm!=null && dlvTerm.trim().length()>0)
{
sql = "select count(*) from delivery_term where dlv_term = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dlvTerm);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMDLVTERM1"; //new message defined
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("pack_code"))
{
packCode= genericUtility.getColumnValue("pack_code", dom);
if(packCode!=null && packCode.trim().length()>0)
{
sql = "select count(*) from packing where pack_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, packCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTPKCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}//end for
} //end case 2
break;
// case 3 start
//Added by Ajit on 06-MARCH to add the validation if the transaction is not acknowedge [Start]
case 3 :
{
parentList = dom.getElementsByTagName("Detail" + currentFormNo);
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
for (ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
childNodeName = childNode.getNodeName();
BaseLogger.log("3", getUserInfo(), null, "Case 3 salesQuotationIC");
if(childNodeName.equalsIgnoreCase("cust_code__stk"))
{
custCodeStk = checkNull(genericUtility.getColumnValue("cust_code__stk", dom));
BaseLogger.log("3", getUserInfo(), null, "Case 3 custCodeStk"+ custCodeStk);
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
BaseLogger.log("3", getUserInfo(), null, "Case 3 custCode"+ custCode);
if(custCodeStk != null && custCodeStk.trim().length() > 0)
{
String sqlObj = "SELECT CPD.CUST_CODE__STK FROM CUSTOMER_PREF_DIST CPD WHERE CPD.CUST_CODE = ? AND CPD.CUST_CODE__STK = ?";
pstmt = conn.prepareStatement(sqlObj);
pstmt.setString(1, custCode);
pstmt.setString(2, custCodeStk);
rs = pstmt.executeQuery();
if(rs.next())
{
stockistCode = rs.getString("CUST_CODE__STK");
}
else
{
stockistCode = "";
errList.add("VCCUSTSTK");
errFields.add("cust_code__stk");
}
if(rs != null) rs.close();
if(pstmt != null) pstmt.close();
}
}
String quotNo = genericUtility.getColumnValue("quot_no", dom1);
BaseLogger.log("3", getUserInfo(), null, "Case 3 itm_default salesQuotationIC quotNo::"+quotNo);
String status = "";
String checkAcknowledgeStatusSql = "select status from sales_quot where quot_no = ?";
PreparedStatement checkAcknowledgeStatusPs = conn.prepareStatement(checkAcknowledgeStatusSql);
checkAcknowledgeStatusPs.setString(1, quotNo);
ResultSet checkAcknowledgeStatusRs = checkAcknowledgeStatusPs.executeQuery();
while(checkAcknowledgeStatusRs.next()) {
status = checkAcknowledgeStatusRs.getString("status");
BaseLogger.log("3", getUserInfo(), null, "Case 3 itm_default salesQuotationIC status::"+status);
}
if(!status.trim().equalsIgnoreCase("A")) {
BaseLogger.log("3", getUserInfo(), null, "Case 3 itm_default salesQuotationIC transaction is not acknowledged: status::"+status);
errCode = "NOACKN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(checkAcknowledgeStatusRs != null)
{
checkAcknowledgeStatusRs.close();
checkAcknowledgeStatusRs = null;
}
if(checkAcknowledgeStatusPs != null)
{
checkAcknowledgeStatusPs.close();
checkAcknowledgeStatusPs = null;
}
}
}//end case 3
break;
//Added by Ajit on 06-MARCH to add the validation if the transaction is not acknowedge [End]
} //end switch
int errListSize = errList.size();
BaseLogger.log("3", getUserInfo(), null, "errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
BaseLogger.log("3", getUserInfo(), null, " testing :errCode .:" + errCode+"errString>>>>>>>>>"+errString);
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");
}//end of if for errList
else
{
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
BaseLogger.log("3", getUserInfo(), null, "testing : final errString : " + errString);
return errString;
}
public String itemChanged(String xmString, String xmString1, String xmString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
BaseLogger.log("3", getUserInfo(), null, "currFrmXmlStr26Feb::"+xmString);
BaseLogger.log("3", getUserInfo(), null, "hdrFrmXmlStr::"+xmString1);
BaseLogger.log("3", getUserInfo(), null, "allFrmXmlStr::"+xmString2);
try
{
if (xmString != null && xmString.trim().length()!=0)
{
dom = genericUtility.parseString(xmString);
}
if (xmString1 != null && xmString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmString1);
}
if (xmString2 != null && xmString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch (Exception e)
{
System.out.println ( "Exception : ItemChanged(String,String):" + e.getMessage() + ":" );
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String itemChanged( Document dom , Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
String valueXmlStringForAck = "";
NodeList parentNodeList = null,detailNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
boolean AcknowledgmentFlag = false;
int ctr = 0;
int childNodeListLength = 0;
String columnValue="";
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
int cnt =0;
int currentFormNo = 0;
Timestamp todaysDate = null;
SimpleDateFormat sdf =null;
FinCommon finCommon = new FinCommon();
UtilMethods utilMethods = new UtilMethods();
DistCommon disCommon = new DistCommon();
String currentDateTime = "",loginSite="",loginCode="";
String custCode="",custDescr="",contPers="",contPrefix="",currCode="",currCodeFinEnt="",salesPers="",salesPersDescr="",actionTitle="";
String detCntStr="",quotNo="",unit="",itemCode="",itemDescr="",unitRate="",samplQty="",unitSampl="",schDate="",schDateUpto="",crTerm="",dlvAt="",dlvTerm="",packCode="",packInstr="",remarks="",itemSpec="",specDescr="",expectedResult="";
int linecnt=0;
double exchRate=0;
try
{
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationIc --> editFlag ["+editFlag+"]");
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationIc --> xtraParams ["+xtraParams.toString()+"]");
conn = getConnection();
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
actionTitle = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "actionTitle"));
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationIc --> actionTitle ["+actionTitle+"]");
quotNo= checkNull(genericUtility.getColumnValue("quot_no", dom));
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationIc --> quotNo ["+quotNo+"]");
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
todaysDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currentDateTime = sdf.format(todaysDate);
//tranDate = sdf.format(todaysDate.toString());
//BaseLogger.log("3", getUserInfo(), null, "tranDate ---["+tranDate+"]");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
valueXmlString.append( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch ( currentFormNo )
{
case 1:
{
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
BaseLogger.log("3", getUserInfo(), null, "CURRENT COLUMN ["+currentColumn+"]");
if(currentColumn.equalsIgnoreCase("itm_default"))
{
BaseLogger.log("3", getUserInfo(), null, "dom case1*>>>> Elements>>SalesQuotationIC case 1:itmDefault["+genericUtility.serializeDom(dom).toString()+"]");//added for testing
valueXmlString.append("<quot_date>").append("<![CDATA["+currentDateTime+"]]>").append("</quot_date>");
valueXmlString.append("<inq_date>").append("<![CDATA["+currentDateTime+"]]>").append("</inq_date>");
valueXmlString.append("<valid_upto>").append("<![CDATA["+currentDateTime+"]]>").append("</valid_upto>");
valueXmlString.append("<status_date>").append("<![CDATA["+currentDateTime+"]]>").append("</status_date>");
}
else if(currentColumn.equalsIgnoreCase("itm_defaultedit")) {
BaseLogger.log("3", getUserInfo(), null, "Entered itm_defaultedit block");
String status = "";
String checkAcknowledgeStatusSql = "select status from sales_quot where quot_no = ?";
BaseLogger.log("3", getUserInfo(), null,
"Executing query: " + checkAcknowledgeStatusSql + " for quotNo: " + quotNo);
PreparedStatement checkAcknowledgeStatusPs = conn.prepareStatement(checkAcknowledgeStatusSql);
checkAcknowledgeStatusPs.setString(1, quotNo);
ResultSet checkAcknowledgeStatusRs = checkAcknowledgeStatusPs.executeQuery();
if(checkAcknowledgeStatusRs.next()) { //  better than while
status = checkAcknowledgeStatusRs.getString("status");
BaseLogger.log("3", getUserInfo(), null, "Fetched status: [" + status + "]");
}
//  APPLY ONLY WHEN STATUS = A
if(status != null && status.trim().equalsIgnoreCase("A")) {
BaseLogger.log("3", getUserInfo(), null,
"Status is A (Acknowledged). Applying protect flag.");
NodeList detailList = dom.getElementsByTagName("Detail1");
if (detailList != null && detailList.getLength() > 0) {
Element detailElem = (Element) detailList.item(0);
NodeList childNodes = detailElem.getChildNodes();
BaseLogger.log("3", getUserInfo(), null,
"Detail1 child count: " + childNodes.getLength());
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) node;
String tagName = elem.getTagName();
// =9 Get value
String value = "";
if (elem.getFirstChild() != null) {
value = elem.getFirstChild().getNodeValue();
}
// =9 Handle null string
if (value == null || "null".equalsIgnoreCase(value)) {
value = "";
}
// =9 Append to valueXmlString (fixed)
valueXmlString.append("<")
.append(tagName)
.append(" protect=\"1\">")
.append("<![CDATA[")
.append(value.trim())
.append("]]>")
.append("</")
.append(tagName)
.append(">");
BaseLogger.log("3", getUserInfo(), null,
"Applied protect=1 and appended tag: " + tagName +
" value: " + value);
}
}
}
else {
BaseLogger.log("3", getUserInfo(), null, "Detail1 node NOT found in DOM");
}
}
else {
BaseLogger.log("3", getUserInfo(), null,
"Status is NOT A. Skipping protect. Status: " + status);
}
// =9 Close resources
if(checkAcknowledgeStatusRs != null) {
checkAcknowledgeStatusRs.close();
checkAcknowledgeStatusRs = null;
}
if(checkAcknowledgeStatusPs != null) {
checkAcknowledgeStatusPs.close();
checkAcknowledgeStatusPs = null;
}
}
else if(currentColumn.equalsIgnoreCase("cust_code"))
{
String lsItemser="",lsSiteCode="",taxChapHdr="",taxClassHdr="",taxEnvHdr="";
String custTaxOpt="",orderType="",stanCodeFr="",custCodeTax="",custCodeBill="",stanCodeTo="",lsCustCodeDlv="";
custCode=genericUtility.getColumnValue("cust_code", dom);
lsItemser = checkNull(genericUtility.getColumnValue("item_ser", dom));
lsSiteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
BaseLogger.log("3", getUserInfo(), null, "custCode ::::::: "+custCode + "\t" + "lsItemser ::::::"+lsItemser);
sql= "select cust_name,cont_pers,cont_pfx,curr_code,sales_pers,cr_term,dlv_term from customer where cust_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
custDescr=rs.getString("cust_name");
contPers=rs.getString("cont_pers");
contPrefix=rs.getString("cont_pfx");
currCode=rs.getString("curr_code");
salesPers=rs.getString("sales_pers");
crTerm=rs.getString("cr_term");
dlvTerm=rs.getString("dlv_term");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<cust_name>").append("<![CDATA["+custDescr +"]]>").append("</cust_name>");
valueXmlString.append("<cont_pers>").append("<![CDATA["+contPers +"]]>").append("</cont_pers>");
valueXmlString.append("<sales_pers>").append("<![CDATA["+salesPers+"]]>").append("</sales_pers>");
valueXmlString.append("<cr_term>").append("<![CDATA["+crTerm+"]]>").append("</cr_term>");
valueXmlString.append("<dlv_term>").append("<![CDATA["+dlvTerm+"]]>").append("</dlv_term>");
sql= "select sp_name from sales_pers where sales_pers= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,salesPers);
rs = pstmt.executeQuery();
if(rs.next())
{
salesPersDescr=rs.getString("sp_name");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<sp_name>").append("<![CDATA["+salesPersDescr+"]]>").append("</sp_name>");
if(currCode!=null && currCode.trim().length()>0)
{
valueXmlString.append("<curr_code>").append("<![CDATA["+currCode+"]]>").append("</curr_code>");
}
sql= "select curr_code from finent f, site s "
+" where f.fin_entity=s.fin_entity and s.site_code =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
currCodeFinEnt=rs.getString("curr_code");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currCodeFinEnt.equalsIgnoreCase(currCode))
{
valueXmlString.append("<exch_rate protect = \"1\" >").append("<![CDATA[" + 1 + "]]>").append("</exch_rate>");
}
else
{
exchRate=finCommon.getDailyExchRateSellBuy(currCode, currCodeFinEnt, loginSite, currentDateTime, "S", conn);
BaseLogger.log("3", getUserInfo(), null, "exch rate by calling fincommon method>>"+exchRate);
valueXmlString.append("<exch_rate protect = \"0\" >").append("<![CDATA[" + exchRate + "]]>").append("</exch_rate>");
}
//Added by Sakshi.P on 15/Oct/2025
sql = "select stan_code from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSiteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
stanCodeFr = rs.getString("stan_code");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
sql = "select stan_code from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next()) {
stanCodeTo = rs.getString("stan_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
BaseLogger.log("3", getUserInfo(), null, "stanCodeFr======["+stanCodeFr+"]");
BaseLogger.log("3", getUserInfo(), null, "stanCodeTo====== ["+stanCodeTo+"]");
taxChapHdr = distCommon.getTaxChap("", lsItemser, "C", custCode, lsSiteCode, conn);
taxClassHdr = distCommon.getTaxClass("C", custCode, "", lsSiteCode, conn);
sql = " select tax_env from site_customer where site_code = ? and cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSiteCode);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
taxEnvHdr= rs.getString("tax_env");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(taxEnvHdr==null || taxEnvHdr.trim().length()==0)
{
sql = " select tax_env from customer where cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
taxEnvHdr= rs.getString("tax_env");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(taxEnvHdr==null || taxEnvHdr.trim().length()==0)
{
taxEnvHdr = distCommon.getTaxEnv(stanCodeFr, stanCodeTo, taxChapHdr, taxClassHdr, lsSiteCode, conn);
}
}
BaseLogger.log("3", getUserInfo(), null, "tax class======["+taxClassHdr+"]");
BaseLogger.log("3", getUserInfo(), null, "tax chap======["+taxChapHdr+"]");
BaseLogger.log("3", getUserInfo(), null, "tax env 11111::taxChapHdr["+taxEnvHdr+"]");
valueXmlString.append("<tax_class>").append("<![CDATA[" + taxClassHdr + "]]>").append("</tax_class>");
setNodeValue(dom, "tax_class", getAbsString(taxClassHdr));
valueXmlString.append("<tax_chap>").append("<![CDATA[" + taxChapHdr + "]]>").append("</tax_chap>");
setNodeValue(dom, "tax_chap", getAbsString(taxChapHdr));
valueXmlString.append("<tax_env>").append("<![CDATA[" + taxEnvHdr + "]]>").append("</tax_env>");
setNodeValue(dom, "tax_env", getAbsString(taxEnvHdr));
//end
}
else if(currentColumn.equalsIgnoreCase("sales_pers"))
{
salesPers=genericUtility.getColumnValue("sales_pers", dom);
sql= "select sp_name from sales_pers where sales_pers= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,salesPers);
rs = pstmt.executeQuery();
if(rs.next())
{
salesPersDescr=rs.getString("sp_name");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<sp_name>").append("<![CDATA["+salesPersDescr+"]]>").append("</sp_name>");
}
else if(currentColumn.equalsIgnoreCase("curr_code"))
{
currCode=genericUtility.getColumnValue("curr_code", dom);
sql= "select curr_code from finent f, site s "
+" where f.fin_entity=s.fin_entity and s.site_code =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
currCodeFinEnt=rs.getString("curr_code");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(currCodeFinEnt.equalsIgnoreCase(currCode))
{
valueXmlString.append("<exch_rate protect = \"1\" >").append("<![CDATA[" + 1 + "]]>").append("</exch_rate>");
}
else
{
exchRate=finCommon.getDailyExchRateSellBuy(currCode, currCodeFinEnt, loginSite, currentDateTime, "S", conn);
BaseLogger.log("3", getUserInfo(), null, "exch rate by calling fincommon method>>"+exchRate);
valueXmlString.append("<exch_rate protect = \"0\" >").append("<![CDATA[" + exchRate + "]]>").append("</exch_rate>");
}
}
valueXmlString.append("</Detail1>");
}
break;
case 2:
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
BaseLogger.log("3", getUserInfo(), null, "CURRENT COLUMN ["+currentColumn+"]");
if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
BaseLogger.log("3", getUserInfo(), null, "Entered itm_defaultedit block");
String status = "";
String checkAcknowledgeStatusSql = "select status from sales_quot where quot_no = ?";
BaseLogger.log("3", getUserInfo(), null,
"Executing query: " + checkAcknowledgeStatusSql + " for quotNo: " + quotNo);
PreparedStatement checkAcknowledgeStatusPs = conn.prepareStatement(checkAcknowledgeStatusSql);
checkAcknowledgeStatusPs.setString(1, quotNo);
ResultSet checkAcknowledgeStatusRs = checkAcknowledgeStatusPs.executeQuery();
if(checkAcknowledgeStatusRs.next()) { //  better than while
status = checkAcknowledgeStatusRs.getString("status");
BaseLogger.log("3", getUserInfo(), null, "Fetched status: [" + status + "]");
}
//  APPLY ONLY WHEN STATUS = A
if(status != null && status.trim().equalsIgnoreCase("A")) {
BaseLogger.log("3", getUserInfo(), null,
"Status is A (Acknowledged). Applying protect flag.");
NodeList detailList = dom.getElementsByTagName("Detail2");
if (detailList != null && detailList.getLength() > 0) {
Element detailElem = (Element) detailList.item(0);
NodeList childNodes = detailElem.getChildNodes();
BaseLogger.log("3", getUserInfo(), null,
"Detail1 child count: " + childNodes.getLength());
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) node;
String tagName = elem.getTagName();
// =9 Get value
String value = "";
if (elem.getFirstChild() != null) {
value = elem.getFirstChild().getNodeValue();
}
// =9 Handle null string
if (value == null || "null".equalsIgnoreCase(value)) {
value = "";
}
// =9 Append to valueXmlString (fixed)
valueXmlString.append("<")
.append(tagName)
.append(" protect=\"1\">")
.append("<![CDATA[")
.append(value.trim())
.append("]]>")
.append("</")
.append(tagName)
.append(">");
BaseLogger.log("3", getUserInfo(), null,
"Applied protect=1 and appended tag: " + tagName +
" value: " + value);
}
}
}
else {
BaseLogger.log("3", getUserInfo(), null, "Detail1 node NOT found in DOM");
}
}
else {
BaseLogger.log("3", getUserInfo(), null,
"Status is NOT A. Skipping protect. Status: " + status);
}
// =9 Close resources
if(checkAcknowledgeStatusRs != null) {
checkAcknowledgeStatusRs.close();
checkAcknowledgeStatusRs = null;
}
if(checkAcknowledgeStatusPs != null) {
checkAcknowledgeStatusPs.close();
checkAcknowledgeStatusPs = null;
}
BaseLogger.log("3", getUserInfo(), null, "Item Default Edit+++++");
String lcrate1 = "", lcQty1 = "" , taxAmtStr= "" , discountStr= "";
double lcrate = 0 ,lcQty =0 , taxamt= 0 , discount = 0, netAmount = 0.0;
lcrate1 = checkNull(genericUtility.getColumnValue("rate", dom));
lcrate = (lcrate1 == null || lcrate1.trim().length() == 0) ? 0 : Double.parseDouble(lcrate1);
lcQty1 = checkNull(genericUtility.getColumnValue("quantity", dom));
lcQty = (lcQty1 == null || lcQty1.trim().length() == 0) ? 0 : Double.parseDouble(lcQty1);
taxAmtStr = checkNull(genericUtility.getColumnValue("tax_amt", dom,"2"));
BaseLogger.log("3", getUserInfo(), null, "taxAmtStr----)[" + taxAmtStr + "]");
taxamt = (taxAmtStr == null || taxAmtStr.trim().length() == 0) ? 0 : Double.parseDouble(taxAmtStr);
BaseLogger.log("3", getUserInfo(), null, "Quantity[" + lcQty+ "]");
BaseLogger.log("3", getUserInfo(), null, "Rate[" + lcrate+ "]");
netAmount = (lcQty*lcrate)+taxamt ;
netAmount = finCommon.getRequiredDecimal(netAmount,2);
BaseLogger.log("3", getUserInfo(), null, "Net Amount(lcQty*lcrate)+taxamt-discount)[" + netAmount+ "]");
valueXmlString.append("<net_amt>").append("<![CDATA["+netAmount+"]]>").append("</net_amt>");
}
else if(currentColumn.equalsIgnoreCase("itm_default"))
{
quotNo= genericUtility.getColumnValue("quot_no", dom);
detCntStr = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"detCnt");
BaseLogger.log("3", getUserInfo(), null, "Values of detCntStr ["+detCntStr+"]");
detailNodeList = dom2.getElementsByTagName("Detail2");
linecnt = detailNodeList.getLength();
valueXmlString.append("<quot_no>").append("<![CDATA[" + quotNo + "]]>").append("</quot_no>");
// above commented pb code migrated to the following
if (linecnt > 1 )
{
Node currDetail = detailNodeList.item(linecnt - 1);
unit= genericUtility.getColumnValueFromNode("unit", currDetail);
itemCode= genericUtility.getColumnValueFromNode("item_code", currDetail);
itemDescr= genericUtility.getColumnValueFromNode("item_descr", currDetail);
unitRate= genericUtility.getColumnValueFromNode("unit__rate", currDetail);
samplQty= genericUtility.getColumnValueFromNode("sampl_qty", currDetail);
unitSampl= genericUtility.getColumnValueFromNode("unit__sampl", currDetail);
BaseLogger.log("3", getUserInfo(), null, "before getting dom");
schDate = checkNull(genericUtility.getColumnValueFromNode("sch_date",currDetail));
schDateUpto = checkNull(genericUtility.getColumnValueFromNode("sch_date_upto",currDetail));
BaseLogger.log("3", getUserInfo(), null, "schdate>>>"+schDate+" "+"sch date upto>>>>"+schDateUpto);
crTerm= checkNull(genericUtility.getColumnValueFromNode("cr_term", currDetail));
dlvAt= genericUtility.getColumnValueFromNode("dlv_at", currDetail);
dlvTerm= checkNull(genericUtility.getColumnValueFromNode("dlv_term", currDetail));
packCode= checkNull(genericUtility.getColumnValueFromNode("pack_code", currDetail));
packInstr= genericUtility.getColumnValueFromNode("pack_instr", currDetail);
remarks= genericUtility.getColumnValueFromNode("remarks", currDetail);
itemSpec= genericUtility.getColumnValueFromNode("item_spec", currDetail);
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit__rate>").append("<![CDATA[" + unitRate + "]]>").append("</unit__rate>");
valueXmlString.append("<sampl_qty>").append("<![CDATA[" + samplQty + "]]>").append("</sampl_qty>");
valueXmlString.append("<unit__sampl>").append("<![CDATA[" + unitSampl + "]]>").append("</unit__sampl>");
valueXmlString.append("<sch_date>").append("<![CDATA[" + schDate + "]]>").append("</sch_date>");
valueXmlString.append("<sch_date_upto>").append("<![CDATA[" + schDateUpto + "]]>").append("</sch_date_upto>");
valueXmlString.append("<dlv_at>").append("<![CDATA[" + dlvAt + "]]>").append("</dlv_at>");
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<pack_instr>").append("<![CDATA[" + packInstr + "]]>").append("</pack_instr>");
valueXmlString.append("<remarks>").append("<![CDATA[" + remarks + "]]>").append("</remarks>");
valueXmlString.append("<item_spec>").append("<![CDATA[" + itemSpec + "]]>").append("</item_spec>");
valueXmlString.append("<cr_term>").append("<![CDATA[" + crTerm + "]]>").append("</cr_term>");
valueXmlString.append("<dlv_term>").append("<![CDATA[" + dlvTerm + "]]>").append("</dlv_term>");
}
else
{
crTerm= genericUtility.getColumnValue("cr_term", dom1);
dlvTerm= genericUtility.getColumnValue("dlv_term", dom1);
valueXmlString.append("<cr_term>").append("<![CDATA[" + crTerm + "]]>").append("</cr_term>");
valueXmlString.append("<dlv_term>").append("<![CDATA[" + dlvTerm + "]]>").append("</dlv_term>");
}
}
else if(currentColumn.equalsIgnoreCase("item_code"))
{
itemCode=genericUtility.getColumnValue("item_code", dom);
sql= "select descr,unit from item where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemDescr=rs.getString("descr");
unit=rs.getString("unit");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<item_descr>").append("<![CDATA["+itemDescr+"]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA["+unit+"]]>").append("</unit>");
valueXmlString.append("<unit__rate>").append("<![CDATA["+unit+"]]>").append("</unit__rate>");
valueXmlString.append("<unit__sampl>").append("<![CDATA["+unit+"]]>").append("</unit__sampl>");
sql= "Select a.spec_descr, b.expected_result "
+" from qc_tabledet b, "
+" qlty_specs a "
+" where a.spec_code = b.spec_code and "
+" b.qc_tableno = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
specDescr=rs.getString("spec_descr");
expectedResult=rs.getString("expected_result");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
itemSpec=itemSpec + specDescr + " " +expectedResult; //str1 = str1 + s1 + ' ' + s2 + space(101 - len(s1+s2))
valueXmlString.append("<item_spec>").append("<![CDATA["+itemSpec+"]]>").append("</item_spec>");
//Added by Sakshi.P on 27/Oct/2025
String lsTaxChapHdr="",lsTaxClassHdr="",lsTaxEnvHdr="",lsSiteCode="",stanCodeFr="",stanCodeTo="",lsItemser="";
String taxChapHdr="",taxClassHdr="",taxEnvHdr="",custCode1="";
lsTaxChapHdr = checkNull(genericUtility.getColumnValue("tax_chap", dom1));
lsTaxClassHdr = checkNull(genericUtility.getColumnValue("tax_class", dom1));
lsTaxEnvHdr = checkNull(genericUtility.getColumnValue("tax_env", dom1));
lsSiteCode= checkNull(genericUtility.getColumnValue("site_code", dom1));
lsItemser= checkNull(genericUtility.getColumnValue("item_ser", dom1));
custCode1=genericUtility.getColumnValue("cust_code", dom1);
BaseLogger.log("3", getUserInfo(), null, "lsTaxChapHdr dom1:["+lsTaxChapHdr+"] lsTaxClassHdr dom1 ["+lsTaxClassHdr+"]lsTaxEnvHdr dom1"+lsTaxEnvHdr);
sql = "select stan_code from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSiteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
stanCodeFr = rs.getString("stan_code");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
sql = "select stan_code from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode1);
rs = pstmt.executeQuery();
if (rs.next()) {
stanCodeTo = rs.getString("stan_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
BaseLogger.log("3", getUserInfo(), null, "stanCodeFr======["+stanCodeFr+"]");
BaseLogger.log("3", getUserInfo(), null, "stanCodeTo====== ["+stanCodeTo+"]");
taxChapHdr = distCommon.getTaxChap(itemCode, lsItemser, "C", custCode1, lsSiteCode, conn);
taxClassHdr = distCommon.getTaxClass("C", custCode1, itemCode, lsSiteCode, conn);
BaseLogger.log("3", getUserInfo(), null, "lsTaxChap from method ["+taxChapHdr+"]lsTaxClass"+taxClassHdr);
if (lsTaxEnvHdr == null || lsTaxEnvHdr.trim().length() == 0) {
sql = " select tax_env from site_customer where site_code = ? and cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSiteCode);
pstmt.setString(2, custCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
taxEnvHdr= rs.getString("tax_env");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(taxEnvHdr==null || taxEnvHdr.trim().length()==0)
{
sql = " select tax_env from customer where cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
taxEnvHdr= rs.getString("tax_env");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(taxEnvHdr==null || taxEnvHdr.trim().length()==0)
{
taxEnvHdr = distCommon.getTaxEnv(stanCodeFr, stanCodeTo, taxChapHdr, taxClassHdr, lsSiteCode, conn);
BaseLogger.log("3", getUserInfo(), null, "tax ENV From discommon["+taxEnvHdr+"]");
}
}
}
else
{
taxEnvHdr = lsTaxEnvHdr;
}
BaseLogger.log("3", getUserInfo(), null, "tax class222======["+taxClassHdr+"]");
BaseLogger.log("3", getUserInfo(), null, "tax chap222======["+taxChapHdr+"]");
BaseLogger.log("3", getUserInfo(), null, "tax env2222 taxChapHdr["+taxEnvHdr+"]");
valueXmlString.append("<tax_class>").append("<![CDATA[" + taxClassHdr + "]]>").append("</tax_class>");
setNodeValue(dom, "tax_class", getAbsString(taxClassHdr));
valueXmlString.append("<tax_chap>").append("<![CDATA[" + taxChapHdr + "]]>").append("</tax_chap>");
setNodeValue(dom, "tax_chap", getAbsString(taxChapHdr));
valueXmlString.append("<tax_env>").append("<![CDATA[" + taxEnvHdr + "]]>").append("</tax_env>");
setNodeValue(dom, "tax_env", getAbsString(taxEnvHdr));
}
else if(currentColumn.equalsIgnoreCase("pack_code"))
{
packCode=genericUtility.getColumnValue("pack_code", dom);
sql= "select descr from packing where pack_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,packCode);
rs = pstmt.executeQuery();
if(rs.next())
{
packInstr=rs.getString("descr");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<pack_instr>").append("<![CDATA["+packInstr+"]]>").append("</pack_instr>");
}
else if(currentColumn.equalsIgnoreCase("rate"))
{
//Added by Sakshi p on 16/Oct/2025
valueXmlString = (gbfIcRate(valueXmlString, dom, dom1, dom2, editFlag, xtraParams, objContext,
conn));
}
valueXmlString.append("</Detail2>");
}
break;
// case 3 start
// Added by Mohammed on 06-MARCH: Populate cust_code__dist from cust_code__stk.
case 3:
{
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail3>");
childNodeListLength = childNodeList.getLength();
String custName = "";
String custCodeStk = "";
String custCodeDist = "";
String stockistName = "";
String distributorName = "";
String siteCode = "";
String cityName = "";
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
BaseLogger.log("3", getUserInfo(), null, "Case 3 CURRENT COLUMN gsb ["+currentColumn+"]");
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
custName = checkNull(genericUtility.getColumnValue("cust_name", dom1));
custCodeDist = checkNull(genericUtility.getColumnValue("cust_code__dist", dom ));
custCodeStk = checkNull(genericUtility.getColumnValue("cust_code__stk", dom));
/* CUSTOMER */
if(custCode.trim().length() > 0)
{
sql = "SELECT CITY FROM CUSTOMER WHERE CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cityName = rs.getString("city");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}
/* ===== STOCKIST NAME + CITY ===== */
if(custCodeStk.trim().length() > 0)
{
sql = "SELECT CUST_NAME, CITY FROM CUSTOMER WHERE CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeStk);
rs = pstmt.executeQuery();
if(rs.next())
{
stockistName = rs.getString("cust_name");
cityName = rs.getString("city");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}
if (currentColumn.equalsIgnoreCase("itm_default"))
{
BaseLogger.log("3", getUserInfo(), null, "Detail3 itm_default triggered");
valueXmlString.append("<cust_code>").append("<![CDATA[" + custCode + "]]>").append("</cust_code>");
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName + "]]>").append("</cust_name>");
valueXmlString.append("<customer_city>").append("<![CDATA[" + checkNull(cityName) + "]]>").append("</customer_city>");
valueXmlString.append("<site_code__pbus>").append("<![CDATA[" + checkNull(siteCode) + "]]>").append("</site_code__pbus>");
BaseLogger.log("3", getUserInfo(), null, "siteCode 1791 [" + siteCode + "]");
valueXmlString.append("<distributor_name>").append("<![CDATA[" + checkNull(distributorName) + "]]>").append("</distributor_name>");
BaseLogger.log("3", getUserInfo(), null, "distributorName 1791 [" + distributorName + "]");
}
if(currentColumn.equalsIgnoreCase("itm_defaultedit"))
{
BaseLogger.log("3", getUserInfo(), null, "Detail3 itm_defaultedit triggered gsb");
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
custCodeStk = checkNull(genericUtility.getColumnValue("cust_code__stk", dom));
BaseLogger.log("3", getUserInfo(), null, "DOM itm_defaultedit custCodeStk ["+custCodeStk+"]");
custCodeDist = "";
distributorName = "";
siteCode = "";
if(custCodeStk.trim().length() > 0 && custCode.trim().length() > 0)
{
sql = "SELECT CUST_CODE__DIST FROM CUSTOMER_PREF_DIST WHERE CUST_CODE__STK = ? AND CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeStk);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
custCodeDist = rs.getString("cust_code__dist");
}
if(rs != null) { rs.close(); rs = null; }
if(pstmt != null) { pstmt.close(); pstmt = null; }
custCodeDist = checkNull(custCodeDist);
if(custCodeDist.trim().length() > 0)
{
sql = "SELECT CUST_NAME, SITE_CODE__PBUS FROM CUSTOMER WHERE CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeDist);
rs = pstmt.executeQuery();
if(rs.next())
{
distributorName = rs.getString("cust_name");
siteCode = rs.getString("site_code__pbus");
}
if(rs != null) { rs.close(); rs = null; }
if(pstmt != null) { pstmt.close(); pstmt = null; }
distributorName = checkNull(distributorName);
siteCode = checkNull(siteCode);
setNodeValue(dom, "cust_code__dist", custCodeDist);
setNodeValue(dom, "site_code__pbus", siteCode);
setNodeValue(dom, "distributor_name", distributorName);
}
}
else
{
custCodeDist = "";
distributorName = "";
siteCode = "";
setNodeValue(dom, "cust_code__dist", "");
setNodeValue(dom, "site_code__pbus", "");
setNodeValue(dom, "distributor_name", "");
}
BaseLogger.log("3", getUserInfo(), null, "DOM custCodeDist ["+custCodeDist+"]");
valueXmlString.append("<cust_name><![CDATA["+custName+"]]></cust_name>");
setNodeValue(dom, "cust_name", custName);
valueXmlString.append("<customer_city><![CDATA["+checkNull(cityName)+"]]></customer_city>");
setNodeValue(dom, "customer_city", cityName);
valueXmlString.append("<stockist_name><![CDATA["+checkNull(stockistName)+"]]></stockist_name>");
setNodeValue(dom, "stockist_name", stockistName);
valueXmlString.append("<cust_code__dist><![CDATA["+custCodeDist+"]]></cust_code__dist>");
valueXmlString.append("<site_code__pbus><![CDATA["+checkNull(siteCode)+"]]></site_code__pbus>");
valueXmlString.append("<distributor_name><![CDATA["+checkNull(distributorName)+"]]></distributor_name>");
}
/* ================= STOCKIST CHANGE ================= */
if(currentColumn.equalsIgnoreCase("cust_code__stk"))
{
custCodeStk = checkNull(genericUtility.getColumnValue("cust_code__stk", dom));
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
BaseLogger.log("3", getUserInfo(), null, "custCodeStk [" + custCodeStk + "]");
BaseLogger.log("3", getUserInfo(), null, "custCode [" + custCode + "]");
if(custCodeStk.trim().length() == 0)
{
BaseLogger.log("3", getUserInfo(), null, "Detail3 cust_code__stk triggered 1820");
setNodeValue(dom, "cust_code__stk", "");
setNodeValue(dom, "cust_code__dist", "");
setNodeValue(dom, "site_code__pbus", "");
setNodeValue(dom, "distributor_name", "");
valueXmlString.append("<cust_code__stk><![CDATA[]]></cust_code__stk>");
valueXmlString.append("<stockist_name><![CDATA[]]></stockist_name>");
valueXmlString.append("<cust_code__dist><![CDATA[]]></cust_code__dist>");
valueXmlString.append("<distributor_name><![CDATA[]]></distributor_name>");
valueXmlString.append("<site_code__pbus><![CDATA[]]></site_code__pbus>");
valueXmlString.append("<city><![CDATA[]]></city>");
}
else if(custCodeStk.trim().length() > 0 && custCode.trim().length() > 0)
{
sql = "SELECT CUST_CODE__DIST FROM CUSTOMER_PREF_DIST WHERE CUST_CODE__STK = ? AND CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeStk);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
custCodeDist = rs.getString("cust_code__dist");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
custCodeDist = checkNull(custCodeDist);
if(custCodeDist.trim().length() > 0)
{
sql = "SELECT CUST_NAME, SITE_CODE__PBUS FROM CUSTOMER WHERE CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeDist);
rs = pstmt.executeQuery();
if(rs.next())
{
distributorName = rs.getString("cust_name");
siteCode = rs.getString("site_code__pbus");
}
rs.close(); pstmt.close();
distributorName = checkNull(distributorName);
siteCode = checkNull(siteCode);
setNodeValue(dom, "site_code__pbus", siteCode);
setNodeValue(dom, "distributor_name", distributorName);
setNodeValue(dom, "cust_code__dist", custCodeDist);
}
valueXmlString.append("<cust_code__dist>").append("<![CDATA["+custCodeDist+"]]>").append("</cust_code__dist>");
valueXmlString.append("<stockist_name>").append("<![CDATA["+checkNull(stockistName)+"]]>").append("</stockist_name>");
valueXmlString.append("<city>").append("<![CDATA["+checkNull(cityName)+"]]>").append("</city>");
valueXmlString.append("<site_code__pbus>").append("<![CDATA["+checkNull(siteCode)+"]]>").append("</site_code__pbus>");
BaseLogger.log("3", getUserInfo(), null, "siteCode 1877 [" + siteCode + "]");
valueXmlString.append("<distributor_name>").append("<![CDATA["+checkNull(distributorName)+"]]>").append("</distributor_name>");
}
}
valueXmlString.append("</Detail3>");
}
break;
}
valueXmlString.append("</Root>\r\n");
} //end try
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception from itemchanged method --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception from itemchanged method --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
public String checkNull(String inputStr) throws ITMException
{
try
{
if(inputStr != null && inputStr.trim().length() > 0)
{
return inputStr.trim();
}
else
{
return "";
}
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception in checknull--["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
private static void setNodeValue(Document dom, String nodeName, String nodeVal) throws Exception {
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null) {
if (tempNode.getFirstChild() == null) {
CDATASection cDataSection = dom.createCDATASection(nodeVal);
tempNode.appendChild(cDataSection);
} else {
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
private static String getAbsString(String str) {
return (str == null || str.trim().length() == 0 || "null".equalsIgnoreCase(str.trim()) ? "" : str.trim());
}
private StringBuffer gbfIcRate(StringBuffer valueXmlString, Document dom, Document dom1, Document dom2,
String editFlag, String xtraParams, String objContext, Connection conn) throws ITMException {
// TODO Auto-generated method stub
PreparedStatement pstmt = null;
ResultSet rs = null;
double ldRate = 0.00, mQty = 0.00,lcOrdValue = 0.00;
try {
ldRate = Double.parseDouble(checkDouble(genericUtility.getColumnValue("rate", dom)));
BaseLogger.log("3", getUserInfo(), null, "@ Rate is:" + ldRate);
mQty = Double.parseDouble(checkDouble(genericUtility.getColumnValue("quantity", dom)));
BaseLogger.log("3", getUserInfo(), null, "mQty>>>>>" + mQty);
double netAmount = 0.0, discount = 0.0 , taxamt= 0.0;
String discountStr = "" , taxAmtStr= "";
taxAmtStr = checkNull(genericUtility.getColumnValue("tax_amt", dom));
BaseLogger.log("3", getUserInfo(), null, "taxAmtStr----)[" + taxAmtStr + "]");
taxamt = (taxAmtStr == null || taxAmtStr.trim().length() == 0) ? 0 : Double.parseDouble(taxAmtStr);
netAmount = (mQty*ldRate);
netAmount = finCommon.getRequiredDecimal(netAmount,2);
BaseLogger.log("3", getUserInfo(), null, "Net Amount(lcQty*lcrate)+taxamt-discount)[" + netAmount+ "]");
valueXmlString.append("<net_amt>").append("<![CDATA["+netAmount+"]]>").append("</net_amt>");
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw e; //Added By Mukesh Chauhan on 06/08/19
} catch (ITMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw e; //Added By Mukesh Chauhan on 05/08/19
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ITMException(e); //Added By Mukesh Chauhan on 05/08/19
}
return valueXmlString;
}
public double checkNullForDouble(String inputStr) throws ITMException
{
double retVal = 0.0;
try
{
if(inputStr == null || inputStr.trim().length() == 0)
{
retVal = 0.0;
}
else
{
retVal = Double.parseDouble(inputStr);
}
}
catch(Exception e)
{
BaseLogger.log("3", getUserInfo(), null, "Exception in checknull--["+e.getMessage()+"]");
e.printStackTrace();
retVal = 0.0;
throw new ITMException(e);
}
return retVal;
}
private String checkDouble(String input) {
if (input == null || input.trim().length() == 0) {
input = "0";
}
return input;
}
private String errorType(Connection conn , String errorCode)
{
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();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
private boolean isExist(Connection conn, String tableName, String columnName, String value)
throws ITMException, RemoteException {
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
boolean status = false;
try {
sql = "SELECT count(*) from " + tableName + " where " + columnName + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next()) {
if (rs.getBoolean(1)) {
status = true;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception e) {
BaseLogger.log("3", getUserInfo(), null, "Exception in isExist ");
e.printStackTrace();
throw new ITMException(e);
}
BaseLogger.log("3", getUserInfo(), null, "returning String from isExist ");
return status;
}
}
\ 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