Commit d36ed3fc authored by manohar's avatar manohar

duplicate component with different name removed


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103362 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c9a48973
/********************************************************
Title : CustomerIC
Date : 09/08/12
Developer: Akhilesh Sikarwar
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import org.w3c.dom.CDATASection;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class CustomerMaster extends ValidatorEJB
implements CustomerMasterLocal, CustomerMasterRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
String winName = null;
FinCommon finCommon = null;
ValidatorEJB validator = null;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val xmlString2 :: " + xmlString2);
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String userId = "";
String sql = "";
String errCode = "";
String errorType = "";
String errString = "";
String taxChap = "";
String taxClass = "";
String salesPers = "";
String salesPers1 = "";
String salesPers2 = "";
String localityCode = "";
String currCode = "";
String bankCode = "";
String siteCode = "";
String crTermNp = "";
String priceListDisc = "";
String priceListClg = "";
String locCodeGit = "";
String currCodeCust = "";
String sundryType = "";
String crTerm = "";
String custCode = "";
String custCodeBil = "";
String blackListing = "";
String keyFlag = "";
String stateCode = "";
String active = "";
String channelPartner = "";
String priceList ="";
String siteCodePbus = "";
String countCode = "";
String contactCode = "";
String groupCode= "";
String marketReg = "";
String dlvTerm = "";
String sGroupCode ="";
String cctrCodeAr ="";
String stanCode = "";
String terrCode = "";
String locGroup = "";
String acctCodeAr = "";
String termTableNo = "";
String custType = "";
String siteCodeRcp = "";
String tranCode = "";
String salesOption = "";
double lossPerc =0;
double adhocReplPerc = 0.0;
int ctr = 0;
int currentFormNo = 0;
int cnt = 0;
int cnt1 = 0;
java.util.Date orderDate = null;
SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yy");
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
FinCommon finCommon = new FinCommon();
DistCommon distCommon = new DistCommon();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
this.finCommon = new FinCommon();
this.validator = new ValidatorEJB();
//Changes and Commented By Bhushan on 09-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("CURRENT COLUMN IN VALIDATION ["+childNodeName+"]");
if (childNodeName.equalsIgnoreCase("group_code"))
{
groupCode=this.genericUtility.getColumnValue("group_code", dom);
if (groupCode != null && groupCode.trim().length() > 0 )
{
custCode=checkNull(this.genericUtility.getColumnValue("cust_code", dom));
if(groupCode.equalsIgnoreCase(custCode))
{
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);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select key_flag from transetup where tran_window = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_customer");
rs = pstmt.executeQuery();
if(rs.next())
{
keyFlag = rs.getString("key_flag")== null?"":rs.getString("key_flag");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0 && keyFlag.equalsIgnoreCase("A"))
{
errCode = "VMCUST1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else
{
errCode = "VMGRPNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("cust_type"))
{
custType=this.genericUtility.getColumnValue("cust_type", dom);
if (custType == null || custType.trim().length() == 0 )
{
errCode = "VTTRANTYP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("cust_code__bil"))
{
custCodeBil=this.genericUtility.getColumnValue("cust_code__bil", dom);
if (custCodeBil != null && custCodeBil.trim().length() > 0 )
{
custCode=checkNull(this.genericUtility.getColumnValue("cust_code", dom));
sql = "select key_flag from transetup where tran_window = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_customer");
rs = pstmt.executeQuery();
if(rs.next())
{
keyFlag = rs.getString("key_flag")== null?"":rs.getString("key_flag");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((custCodeBil == null || custCodeBil.trim().length() == 0) && keyFlag.equalsIgnoreCase("A"))
{
errCode = "VEBILLTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(!custCodeBil.equalsIgnoreCase(custCode))
{
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(cnt == 0)
{
errCode = "VMBILLTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else
{
errCode = "VEBILLTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("stan_code"))
{
stanCode=this.genericUtility.getColumnValue("stan_code", dom);
if (stanCode != null && stanCode.trim().length() > 0 )
{
sql = "select count(*) from station where stan_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stanCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTSTAN1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}else
{
errCode = "VMSTAN1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("market_reg"))
{
marketReg=this.genericUtility.getColumnValue("market_reg", dom);
if (marketReg == null || marketReg.trim().length() == 0 )
{
errCode = "VMMSEGNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("terr_code"))
{
terrCode=this.genericUtility.getColumnValue("terr_code", dom);
if (terrCode != null && terrCode.trim().length() > 0)
{
sql = "select count(*) from territory where terr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, terrCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTTERRCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("state_code"))
{
stateCode=checkNull(this.genericUtility.getColumnValue("state_code", dom));
sql = "select count(*) from state where state_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stateCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTSTATE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else if (childNodeName.equalsIgnoreCase("loc_group"))
{
locGroup=this.genericUtility.getColumnValue("loc_group", dom);
if (locGroup == null || locGroup.trim().length() == 0 )
{
errCode = "VMLOCGNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("locality_code"))
{
localityCode=this.genericUtility.getColumnValue("locality_code", dom);
if (localityCode == null || localityCode.trim().length() == 0 )
{
errCode = "VMLOCGNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("count_code"))
{
countCode=this.genericUtility.getColumnValue("count_code", dom);
if (countCode != null && countCode.trim().length() > 0)
{
sql = "select count(*) from country where count_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, countCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTCONTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if (childNodeName.equalsIgnoreCase("cr_term"))
{
crTerm=checkNull(this.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(cnt == 0)
{
errCode = "VTCRTERM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}else
{
errCode = "VECRT2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("cr_term__np"))
{
crTermNp=checkNull(this.genericUtility.getColumnValue("cr_term__np", dom));
if (crTermNp != null && crTermNp.trim().length() > 0)
{
sql = "select count(*) from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTermNp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTINVCRTRM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}else
{
errCode = "VMTERM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("curr_code"))
{
currCode=this.genericUtility.getColumnValue("curr_code", dom);
if(currCode != null && currCode.trim().length() > 0)
{
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);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTCURRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if(editFlag.equalsIgnoreCase("E"))
{
custCode=checkNull(this.genericUtility.getColumnValue("cust_code", dom));
sql = "select curr_code from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
currCodeCust = rs.getString("curr_code")== null?"":rs.getString("curr_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(currCodeCust != null && currCode.equalsIgnoreCase(currCodeCust))
{
sundryType = "C";
sql ="select count(distinct curr_code__ac) from sundrybal where " +
"sundry_code = ? and sundry_type = ? and (dr_amt <> 0 or cr_amt <> 0)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, sundryType);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql ="select count(*) from sundrybal where sundry_code = ? and sundry_type = ? and (dr_amt <> 0 or cr_amt <> 0) and curr_code__ac = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, sundryType);
pstmt.setString(3, currCodeCust);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt1 = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt1 != 0 || cnt > 0)
{
errCode = "VTCURRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}else
{
errCode = "VMCUR2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("acct_code__ar"))
{
acctCodeAr=checkNull(this.genericUtility.getColumnValue("acct_code__ar", dom));
sql ="select count(*) from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCodeAr);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt >0)
{
sql =" select active from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCodeAr);
rs = pstmt.executeQuery();
if(rs.next())
{
active = rs.getString("active")==null?"":rs.getString("active");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(!active.equalsIgnoreCase("Y"))
{
errCode = "VMACCTA";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VTACCTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("cctr_code__ar"))
{
cctrCodeAr = this.genericUtility.getColumnValue("cctr_code__ar", dom);
if(cctrCodeAr != null && cctrCodeAr.trim().length() > 0)
{
sql = "select count(*) from costctr where cctr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cctrCodeAr);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
if (cnt == 0)
{
errCode = "VTCCTRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
acctCodeAr=checkNull(this.genericUtility.getColumnValue("acct_code__ar", dom));
if(acctCodeAr != null && acctCodeAr.trim().length() > 0)
{
valueXmlString.append("<cctr_code__ar>").append("<![CDATA["+""+"]]>").append("</cctr_code__ar>");
}
else
{
errCode = "VMCCTRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("tax_class"))
{
taxClass=this.genericUtility.getColumnValue("tax_class", dom);
if (taxClass != null && taxClass.trim().length() > 0)
{
sql = "select count(*) from taxclass where tax_class = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxClass);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTTAXCLA1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}else
{
errCode = "TAXCLANU";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("tax_chap"))
{
taxChap=this.genericUtility.getColumnValue("tax_chap", dom);
if (taxChap != null && taxChap.trim().length() > 0)
{
sql = "select count(*) from taxchap where tax_chap = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxChap);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTTCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
errCode = "VTTAXCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("price_list"))
{
priceList=this.genericUtility.getColumnValue("price_list", dom);
if (priceList != null && priceList.trim().length() > 0)
{
sql = "select count(*) from pricelist where price_list = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTTAXCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("price_list__clg"))
{
priceListClg=this.genericUtility.getColumnValue("price_list__clg", dom);
if (priceListClg != null && priceListClg.trim().length() > 0)
{
sql = "select count(*) from pricelist where price_list = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceListClg);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTTAXCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("sales_pers"))
{
salesPers=this.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);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMSLPERS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("sales_pers__1"))
{
salesPers1=this.genericUtility.getColumnValue("sales_pers__1", dom);
if (salesPers1 != null && salesPers1.trim().length() > 0)
{
sql = "select count(*) from sales_pers where sales_pers = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, salesPers1);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMSLPERS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("sales_pers__2"))
{
salesPers2=this.genericUtility.getColumnValue("sales_pers__2", dom);
if (salesPers2 != null && salesPers2.trim().length() > 0)
{
sql = "select count(*) from sales_pers where sales_pers = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, salesPers2);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMSLPERS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("tran_code"))
{
tranCode=this.genericUtility.getColumnValue("tran_code", dom);
if (tranCode != null && tranCode.trim().length() > 0)
{
sql = "select count(*) from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTTRANCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VMTRANCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("site_code__rcp"))
{
siteCodeRcp=this.genericUtility.getColumnValue("site_code__rcp", dom);
if (siteCodeRcp != null && siteCodeRcp.trim().length() > 0)
{
sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodeRcp);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VMSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("site_code"))
{
siteCode= checkNull(this.genericUtility.getColumnValue("site_code", dom));
channelPartner=checkNull(this.genericUtility.getColumnValue("channel_partner", dom));
if((siteCode == null || siteCode.trim().length() == 0)&& channelPartner.equalsIgnoreCase("Y"))
{
errCode = "VMSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if(channelPartner.equalsIgnoreCase("Y") && siteCode.trim().length() > 0)
{
errCode = "VNRSITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(channelPartner.equalsIgnoreCase("N") && siteCode.trim().length() > 0)
{
sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0 )
{
errCode = "VMSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
else if (childNodeName.equalsIgnoreCase("black_listing"))
{
blackListing=this.genericUtility.getColumnValue("black_listing", dom);
if(!blackListing.equalsIgnoreCase("P"))
{
errCode = "VMBLACKLIS";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("contact_code"))
{
contactCode=checkNull(this.genericUtility.getColumnValue("contact_code", dom));
if (contactCode != null && contactCode.trim().length() > 0)
{
sql = "select count(*) from contact where contact_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, contactCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VMCONTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
errCode = "VMCONTNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("bank_code"))
{
bankCode=checkNull(this.genericUtility.getColumnValue("bank_code", dom));
if (bankCode != null && bankCode.trim().length() > 0)
{
sql = "select count(*) from bank where bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("price_list__disc"))
{
priceListDisc=checkNull(this.genericUtility.getColumnValue("price_list__disc", dom));
if (priceListDisc != null && priceListDisc.trim().length() > 0)
{
sql = "select count(*) from pricelist where price_list = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceListDisc);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTPLIST1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VTPLIST2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("sales_option"))
{
salesOption=this.genericUtility.getColumnValue("sales_option", dom);
if (salesOption == null || salesOption.trim().length() == 0)
{
errCode = "VTSLOPT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("sales_option"))
{
salesOption=this.genericUtility.getColumnValue("sales_option", dom);
if (salesOption == null || salesOption.trim().length() == 0)
{
errCode = "VTSLOPT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("sgroup_code"))
{
sGroupCode=this.genericUtility.getColumnValue("sgroup_code", dom);
if (sGroupCode == null || sGroupCode.trim().length() == 0)
{
errCode = "VTINULLSAL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("dlv_term"))
{
dlvTerm=this.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);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMDLVTERM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VTDLVNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("loss_perc"))
{
lossPerc=checkDoubleNull(this.genericUtility.getColumnValue("loss_perc", dom));
if(lossPerc < 0 )
{
errCode = "VTADH";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("adhoc_repl_perc"))
{
adhocReplPerc=checkDoubleNull(this.genericUtility.getColumnValue("adhoc_repl_perc", dom));
if(adhocReplPerc < 0 || adhocReplPerc > 100)
{
errCode = "VTADH";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("term_table__no"))
{
termTableNo=this.genericUtility.getColumnValue("term_table__no", dom);
if(termTableNo != null && termTableNo.trim().length() > 0)
{
sql = "select count(1) from sale_term_table where term_table = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, termTableNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VMSALETERM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("site_code__pbus"))
{
siteCodePbus=this.genericUtility.getColumnValue("site_code__pbus", dom);
if(siteCodePbus != null && siteCodePbus.trim().length() > 0)
{
sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodePbus);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0 )
{
errCode = "VTSITECD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
valueXmlString.append("</Detail1>");
}
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if ((errList != null) && (errListSize > 0))
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String)errList.get(cnt);
errFldName = (String)errFields.get(cnt);
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;
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}
catch (Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
return errString;
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams)
throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
System.out.println("hELLO PRINT");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
System.out.println("HELLO1 PRINT");
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
System.out.println("VALUE HELLO PRINT["+valueXmlString+"]");
}
catch (Exception e)
{
System.out.println("Exception : [MiscVal][itemChanged( String, String )] :==>\n" +
e.getMessage());
throw new ITMException(e);
}
System.out.println("VALUE HELLO PRINTA["+valueXmlString+"]");
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams)
throws RemoteException, ITMException
{
System.out.println("sTART PRINT ");
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String sql = "";
String currCode = "";
String custCode = "";
String bankName = "";
String bankCode = "";
String custName = "";
String spName = "";
String chqName = "";
String stateCode = "";
String groupCode = "";
String countCode = "";
String crTerm = "";
String contactCode = "";
String shName = "";
String contPers = "";
String localityCode ="";
String contPfx = "";
String addr1 = "";
String addr2 = "";
String city = "";
String pin = "";
String tele1 = "";
String tele2 = "";
String tele3 = "";
String teleExt = "";
String fax = "";
String salesPers = "";
String descr ="";
String add2 = "";
String stanCode = "";
String blackListed ="";
String keyFlag = "";
String channelPartner = "";
String terrCode = "";
String reasCodeBklist = "";
String loginSite = "";
String custCodeBil = "";
String emailAddr = "";
String ediAddr = "";
String name = "";
String addr3 = "";
String terrdescr = "";
int crDays = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength = 0;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
ArrayList convQtyFactList = new ArrayList();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd");
SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yy");
SimpleDateFormat dateFormat1 = new SimpleDateFormat("dd-MMM-yy");
SimpleDateFormat sdf;
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
FinCommon finCommon = new FinCommon();
DistCommon distCommon = new DistCommon();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
//Changes and Commented By Bhushan on 09-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
conn.setAutoCommit(false);
connDriver = null;
this.finCommon = new FinCommon();
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println("CURRENT COLUMN ["+currentColumn+"]");
if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
localityCode = checkNull(genericUtility.getColumnValue("locality_code", dom));
valueXmlString.append("<locality_code protect = \"1\">").append("<![CDATA["+localityCode+"]]>").append("</locality_code>");
reasCodeBklist = checkNull(genericUtility.getColumnValue("reas_code__bklist", dom));
sql = "select descr from gencodes where fld_name = ? and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "REAS_CODE__BKLIST");
pstmt.setString(2, reasCodeBklist);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = rs.getString(1)==null?"":rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bklist_reason protect = \"0\">").append("<![CDATA["+descr+"]]>").append("</bklist_reason>");
blackListed = checkNull(genericUtility.getColumnValue("black_listed", dom));
if(blackListed.equalsIgnoreCase("N"))
{
valueXmlString.append("<bklist_reason >").append("<![CDATA["+""+"]]>").append("</bklist_reason>");
valueXmlString.append("<reas_code__bklist protect = \"1\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
}
else
{
valueXmlString.append("<reas_code__bklist protect = \"0\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
valueXmlString.append("<site_code>").append("<![CDATA["+loginSite+"]]>").append("</site_code>");
reasCodeBklist = checkNull(genericUtility.getColumnValue("reas_code__bklist", dom));
sql = "select descr from gencodes where fld_name = ? and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "REAS_CODE__BKLIST");
pstmt.setString(2, reasCodeBklist);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = rs.getString(1)==null?"":rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bklist_reason protect = \"0\">").append("<![CDATA["+descr+"]]>").append("</bklist_reason>");
blackListed = checkNull(genericUtility.getColumnValue("black_listed", dom));
if(blackListed.equalsIgnoreCase("N"))
{
valueXmlString.append("<bklist_reason >").append("<![CDATA["+""+"]]>").append("</bklist_reason>");
valueXmlString.append("<reas_code__bklist protect = \"1\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
}
else
{
valueXmlString.append("<reas_code__bklist protect = \"0\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("cust_code"))
{
custCodeBil = checkNull(genericUtility.getColumnValue("cust_code__bil", dom));
if(custCodeBil == null || custCodeBil.trim().length() == 0)
{
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
valueXmlString.append("<cust_code__bil>").append("<![CDATA["+custCode+"]]>").append("</cust_code__bil>");
valueXmlString.append("<group_code >").append("<![CDATA["+custCode+"]]>").append("</group_code>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("stan_code"))
{
stanCode = checkNull(genericUtility.getColumnValue("stan_code", dom));
sql = "select state_code, city, pin from station where stan_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stanCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stateCode = rs.getString("state_code")==null?"":rs.getString("state_code");
city = rs.getString("city")==null?"":rs.getString("city");
pin = rs.getString("pin")==null?"":rs.getString("pin");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select count_code from state where state_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stateCode);
rs = pstmt.executeQuery();
if (rs.next())
{
countCode = rs.getString("count_code")==null?"":rs.getString("count_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from country where count_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, countCode);
rs = pstmt.executeQuery();
if (rs.next())
{
currCode = rs.getString("curr_code")==null?"":rs.getString("curr_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<state_code>").append("<![CDATA["+stateCode+"]]>").append("</state_code>");
valueXmlString.append("<count_code>").append("<![CDATA["+countCode+"]]>").append("</count_code>");
valueXmlString.append("<curr_code>").append("<![CDATA["+currCode+"]]>").append("</curr_code>");
valueXmlString.append("<city>").append("<![CDATA["+city+"]]>").append("</city>");
valueXmlString.append("<pin>").append("<![CDATA["+pin+"]]>").append("</pin>");
}
else if (currentColumn.trim().equalsIgnoreCase("cust_name"))
{
custName = checkNull(genericUtility.getColumnValue("cust_name", dom));
chqName = checkNull(genericUtility.getColumnValue("chq_name", dom));
if(chqName== null || chqName.trim().length() == 0)
{
valueXmlString.append("<chq_name>").append("<![CDATA["+custName+"]]>").append("</chq_name>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("terr_code"))
{
terrCode = checkNull(genericUtility.getColumnValue("terr_code", dom));
sql = "select descr from territory where terr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, terrCode);
rs = pstmt.executeQuery();
if (rs.next())
{
terrdescr = rs.getString("descr")==null?"":rs.getString("descr");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<territory_descr>").append("<![CDATA["+terrdescr+"]]>").append("</territory_descr>");
}
else if (currentColumn.trim().equalsIgnoreCase("sales_pers"))
{
salesPers = checkNull(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())
{
spName = rs.getString("sp_name")==null?"":rs.getString("sp_name");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<sp_name>").append("<![CDATA["+spName+"]]>").append("</sp_name>");
}
else if (currentColumn.trim().equalsIgnoreCase("contact_code"))
{
contactCode = checkNull(genericUtility.getColumnValue("contact_code", dom));
sql = "select name, sh_name, cont_pers, cont_pfx, addr1, addr2, addr3, city, pin, state_code, count_code, tele1," +
" tele2, tele3, tele_ext, fax, email_addr, edi_addr from contact where contact_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, contactCode);
rs = pstmt.executeQuery();
if (rs.next())
{
name = rs.getString("name")== null?"":rs.getString("name");
shName = rs.getString("sh_name")==null?"":rs.getString("sh_name");
contPers = rs.getString("cont_pers")== null?"":rs.getString("cont_pers");
contPfx = rs.getString("cont_pfx")==null?"":rs.getString("cont_pfx");
addr1 = rs.getString("addr1")==null?"":rs.getString("addr1");
addr2 = rs.getString("addr2")==null?"":rs.getString("addr2");
addr3 = rs.getString("addr3")==null?"":rs.getString("addr3");
city = rs.getString("city")==null?"":rs.getString("city");
pin = rs.getString("pin")==null?"":rs.getString("pin");
stateCode = rs.getString("state_code")==null?"":rs.getString("state_code");
countCode = rs.getString("count_code")==null?"":rs.getString("count_code");
tele1 = rs.getString("tele1")==null?"":rs.getString("tele1");
tele2 = rs.getString("tele2")==null?"":rs.getString("tele2");
tele3 = rs.getString("tele3")==null?"":rs.getString("tele3");
teleExt = rs.getString("tele_ext")==null?"":rs.getString("tele_ext");
fax = rs.getString("fax")==null?"":rs.getString("fax");
emailAddr = rs.getString("email_addr")==null?"":rs.getString("email_addr");
ediAddr = rs.getString("edi_addr")==null?"":rs.getString("edi_addr");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
custName = checkNull(genericUtility.getColumnValue("cust_name", dom));
if(custName == null || custName.trim().length() == 0)
{
valueXmlString.append("<cust_name>").append("<![CDATA["+name+"]]>").append("</cust_name>");
valueXmlString.append("<chq_name>").append("<![CDATA["+name+"]]>").append("</chq_name>");
valueXmlString.append("<sh_name>").append("<![CDATA["+shName+"]]>").append("</sh_name>");
}
contPfx = checkNull(genericUtility.getColumnValue("cont_pfx", dom));
if(contPfx == null || contPfx.trim().length() == 0)
{
valueXmlString.append("<cont_pfx>").append("<![CDATA["+contPfx+"]]>").append("</cont_pfx>");
}
addr1 = checkNull(genericUtility.getColumnValue("addr1", dom));
if(addr1 == null || addr1.trim().length() == 0)
{
valueXmlString.append("<addr1>").append("<![CDATA["+contPfx+"]]>").append("</addr1>");
valueXmlString.append("<addr2>").append("<![CDATA["+add2+"]]>").append("</addr2>");
valueXmlString.append("<addr3>").append("<![CDATA["+addr3+"]]>").append("</addr3>");
valueXmlString.append("<city>").append("<![CDATA["+city+"]]>").append("</city>");
valueXmlString.append("<pin>").append("<![CDATA["+pin+"]]>").append("</pin>");
valueXmlString.append("<count_code>").append("<![CDATA["+countCode+"]]>").append("</count_code>");
valueXmlString.append("<tele1>").append("<![CDATA["+tele1+"]]>").append("</tele1>");
valueXmlString.append("<tele2>").append("<![CDATA["+tele2+"]]>").append("</tele2>");
valueXmlString.append("<tele_ext>").append("<![CDATA["+teleExt+"]]>").append("</tele_ext>");
valueXmlString.append("<fax>").append("<![CDATA["+fax+"]]>").append("</fax>");
}
emailAddr = checkNull(genericUtility.getColumnValue("email_addr", dom));
if(emailAddr == null || emailAddr.trim().length() == 0)
{
valueXmlString.append("<email_addr>").append("<![CDATA["+emailAddr+"]]>").append("</email_addr>");
}
ediAddr = checkNull(genericUtility.getColumnValue("edi_addr", dom));
if(ediAddr == null || ediAddr.trim().length() == 0)
{
valueXmlString.append("<edi_addr>").append("<![CDATA["+ediAddr+"]]>").append("</edi_addr>");
}
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
sql = "select key_flag from transetup where tran_window = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_customer");
rs = pstmt.executeQuery();
if (rs.next())
{
keyFlag = rs.getString("key_flag")==null?"":rs.getString("key_flag");
}
if(custCode == null && !keyFlag.equalsIgnoreCase("A"))
{
contactCode = checkNull(genericUtility.getColumnValue("contact_code", dom));
valueXmlString.append("<cust_code>").append("<![CDATA["+contactCode+"]]>").append("</cust_code>");
}
custCodeBil = checkNull(genericUtility.getColumnValue("cust_code__bil", dom));
if(custCodeBil == null)
{
contactCode = checkNull(genericUtility.getColumnValue("contact_code", dom));
valueXmlString.append("<cust_code__bil>").append("<![CDATA["+contactCode+"]]>").append("</cust_code__bil>");
}
groupCode = checkNull(genericUtility.getColumnValue("group_code", dom));
if(groupCode == null)
{
contactCode = checkNull(genericUtility.getColumnValue("contact_code", dom));
valueXmlString.append("<group_code>").append("<![CDATA["+contactCode+"]]>").append("</group_code>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("bank_code"))
{
bankCode = checkNull(genericUtility.getColumnValue("bank_code", dom));
sql = "select bank_name from bank where bank_code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
bankName = rs.getString("bank_name")==null?"":rs.getString("bank_name");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bank_name>").append("<![CDATA["+bankName+"]]>").append("</bank_name>");
}
else if (currentColumn.trim().equalsIgnoreCase("channel_partner"))
{
channelPartner = checkNull(genericUtility.getColumnValue("channel_partner", dom));
if(channelPartner.equalsIgnoreCase("Y"))
{
valueXmlString.append("<site_code protect = \"0\">").append("<![CDATA["+""+"]]>").append("</site_code>");
valueXmlString.append("<fin_link protect = \"0\" >").append("<![CDATA["+""+"]]>").append("</fin_link>");
valueXmlString.append("<dis_link protect = \"0\">").append("<![CDATA["+""+"]]>").append("</dis_link>");
}
else
{
valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA["+""+"]]>").append("</site_code>");
valueXmlString.append("<fin_link protect = \"1\">").append("<![CDATA["+""+"]]>").append("</fin_link>");
valueXmlString.append("<dis_link protect = \"1\">").append("<![CDATA["+""+"]]>").append("</dis_link>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("black_listed"))
{
blackListed = checkNull(genericUtility.getColumnValue("black_listed", dom));
if(blackListed.equalsIgnoreCase("Y"))
{
valueXmlString.append("<black_listed_date protect = \"0\">").append("<![CDATA["+""+"]]>").append("</black_listed_date>");
valueXmlString.append("<reas_code__bklist protect = \"0\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
}
else
{
valueXmlString.append("<black_listed_date protect = \"1\">").append("<![CDATA["+""+"]]>").append("</black_listed_date>");
valueXmlString.append("<reas_code__bklist protect = \"1\">").append("<![CDATA["+""+"]]>").append("</reas_code__bklist>");
valueXmlString.append("<bklist_reason protect = \"1\">").append("<![CDATA["+""+"]]>").append("</bklist_reason>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("reas_code__bklist"))
{
reasCodeBklist = checkNull(genericUtility.getColumnValue("reas_code__bklist", dom));
sql = " select descr from gencodes where fld_name = ? and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "REAS_CODE__BKLIST");
pstmt.setString(2, reasCodeBklist);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = rs.getString("descr")==null?"":rs.getString("descr");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bklist_reason>").append("<![CDATA["+descr+"]]>").append("</bklist_reason>");
}
else if (currentColumn.trim().equalsIgnoreCase("cr_term"))
{
crTerm = checkNull(genericUtility.getColumnValue("cr_term", dom));
sql = "select cr_days from crterm where cr_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, crTerm);
rs = pstmt.executeQuery();
if (rs.next())
{
crDays = rs.getInt("cr_days");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<credit_prd>").append("<![CDATA["+crDays+"]]>").append("</credit_prd>");
}
else if (currentColumn.trim().equalsIgnoreCase("locality_code"))
{
localityCode = checkNull(genericUtility.getColumnValue("locality_code", dom));
sql = "SELECT descr FROM LOCALITY where locality_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, localityCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = rs.getString("descr")==null?"":rs.getString("descr");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<locality_descr>").append("<![CDATA["+descr+"]]>").append("</locality_descr>");
}
valueXmlString.append("</Detail1>");
}
valueXmlString.append("</Root>");
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (pstmt != null)
pstmt.close();
if (rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
conn = null;
}
}
catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
return valueXmlString.toString();
}
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
private int checkIntNull(String str)
{
if(str == null || str.trim().length() == 0 )
{
return 0;
}
else
{
return Integer.parseInt(str) ;
}
}
private double checkDoubleNull(String str)
{
if(str == null || str.trim().length() == 0)
{
return 0.0;
}
else
{
return Double.parseDouble(str) ;
}
}
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();
while (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
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;
}
private static void setNodeValue( Document dom, String nodeName, double nodeVal ) throws Exception
{
setNodeValue( dom, nodeName, Double.toString( nodeVal ) );
}
private static void setNodeValue( Document dom, String nodeName, int nodeVal ) throws Exception
{
setNodeValue( dom, nodeName, Integer.toString( nodeVal ) );
}
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;
}
public String CheckForTtem(String siteCodeShip,String itemCode,Connection conn) throws ITMException
{
System.out.println("In CheckForTtem siteCodeShip and itemCode"+ siteCodeShip+""+itemCode);
String errCode = "",varValue = "",blkList = "",active = "";
String sql = "",str="" ,modName = "D-ORD";
int count = 0;
PreparedStatement pstmt =null;
ResultSet rs = null;
try
{
sql = "select active from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
active = rs.getString(1);
}
else
{
errCode = "VTITEM1";
}
if(active == null && active.trim().length() == 0)
{
active="Y";
}
if(!active.equals("Y"))
{
if(modName.equals("S-RET") || modName.equals("SRFRM") )
{
errCode = "VTITEM9";
}
else
{
errCode = "VTITEM4";
}
}
sql = "select var_value from disparm where prd_code = ? and var_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "999999");
pstmt.setString(2, "SITE_SPECIFIC_ITEM");
rs = pstmt.executeQuery();
if (rs.next())
{
varValue = rs.getString(1);
}
if(varValue.equals("Y"))
{
sql = "select case when active is null then 'Y' else active end from siteitem where site_code = ? and item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodeShip);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
active = rs.getString(1);
}
else
{
if(modName.equalsIgnoreCase("D-ORD"))
{
errCode = "VTITEM3A";
}
else
{
errCode = "VTITEM3";
}
}
if(active.equals("N"))
{
errCode = "VTITEM4";}
}
else
{
sql = "select count(*) from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt(1);
}
if(count==0)
{
errCode="VTITEM1";
}
}
}
catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
return errCode;
}
}
/********************************************************
Title : CustomerICLocal
Date : 09/08/2012
Developer: Akhilesh Sikarwar
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface CustomerMasterLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, 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;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : CustomerICRemote
Date : 09/08/2012
Developer: Akhilesh Sikarwar
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface CustomerMasterRemote extends ValidatorRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, 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;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
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