Commit e7b21798 authored by mchauhan's avatar mchauhan

Gencodes - if genmst not defined proper message to be given

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202117 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c67ae67c
/********************************************************
Title : CountryIC
Date : 20/10/14
Developer: Vallabh Kadam
********************************************************/
package ibase.webitm.ejb.sys;
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 ibase.utility.E12GenericUtility;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.apache.poi.hwpf.usermodel.DateAndTime;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.ibm.db2.jcc.b.ca;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.ITMException;
@Stateless
public class GencodesIC extends ValidatorEJB implements GencodesICLocal, GencodesICRemote
{
//changes and commented by sarita on 31/05/2017
//GenericUtility genericUtility = GenericUtility.getInstance();
public class GencodesIC extends ValidatorEJB implements GencodesICLocal,GencodesICRemote{
E12GenericUtility genericUtility = new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
ValidatorEJB validator = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
DistCommon distComm = new DistCommon();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
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;
String retString = "";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} catch (Exception e)
retString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println("retString:::" + retString);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return errString;
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
int cc, xx, initialField = 1, lastField = 1, fldcase = 0, li_fld_width=0,sfieldno = '0';
String fldname = "", Errcode, ls_val, ls_val1, ls_val2, fldnm,modname="";
Date mdate1, mdate2;
Long ll_count = 0L;
NodeList parentNodeList = null;
String childNodeName = null;
NodeList childNodeList = null;
int childNodeListLength;
Node parentNode = null;
Node childNode = null;
String existFlag = "";
String fld_value = "";
int count=0;
String fld_value1 = "";
String fld_value2 = "";
String fld_width="";
String descrstr="";
StringBuffer valueXmlString = new StringBuffer();
String userId = "", sql = "", errCode = "", errorType = "", errString = "", tranId = "", blankVar = "";
String countCode = "", keyFlag = "", descr = "", currCode = "", transCode = "", regCode = "", validUpto = "", regDate = "";
int ctr = 0, currentFormNo = 0, cnt = 0, cnt1 = 0;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
int childNodeLength = 0;
int currentFormNo = 0;
int ctr = 0, cnt = 0;
Connection conn = null;
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
NodeList parentNodeList = null;
Node parentNode = null;
NodeList childNodeList = null;
Node childNode = null;
String childNodeName = "";
String userId = "";
String currcode = "",acccode = "",sundry_type = "",tranDateStr="",tranSer="";
String sundtype = "";
String sql = "";
String errCode = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
String errorType = "", errString = "";
int cc, initialField = 1, lastField = 1, li_cnt;
String fldname="",val,val1,val2,site,tranid;
String type;
Timestamp tranDate;
String exprcpdate=null;
double cnt0 = 0 ,dispAmt,osAmt=0,disputeAmt=0;
String disputeamt;
String refser[],refno[] ,curr,Val3,sFieldNo,mval,mval1,xx;
String refser1[],refno1[],errcode,recref,lstype,scode,custcode,adjduedate;
double net,totnet,recamt,num,confamt, nget1,dispamt = 0;
SimpleDateFormat simpleDateFormat = null;
String startStr,endStr,descrStr,descrStart,descrEnd,lsmsg1 = null,rcptype=null;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf;
try
{
this.finCommon = new FinCommon();
this.validator = new ValidatorEJB();
//changes and commented by Mukesh on 06/06/2019 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if ((objContext != null) && (objContext.trim().length() > 0))
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("userId = "+userId);
site = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("xtraParams = "+xtraParams);
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
tranDateStr = sdf.format(currentDate.getTime());
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();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
cc = childNodeList.getLength();
for(ctr = 0; ctr < cc; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
//changes and commented by Mukesh on 06/06/2019 :START
if(childNodeName.equalsIgnoreCase("fld_value"))
// change by mukesh on 17/06/2019
if(childNodeName.equalsIgnoreCase("mod_name"))
{
fld_value = genericUtility.getColumnValue("fldname", dom);
fld_value1 = genericUtility.getColumnValue("fld_value", dom1);
fld_value2 = genericUtility.getColumnValue("mod_name", dom2);
System.out.println("fld_value: " + fld_value);
if (fld_value == null || fld_value.trim().length() == 0) {
errCode = "VMCODNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Site Code can not be blank!!");
} else {
if (fld_value != null && fld_value.trim().length() > 0) {
if (!(isExist(conn, "site", "fld_value", fld_value))) {
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(editFlag.equalsIgnoreCase("A"))
{
errCode="VMDUPL1";
}
else
{
sql="select count(*) from genmst where fld_name = ? and mod_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,fldname);
pstmt.setString(2,modname);
rs = pstmt.executeQuery();
if(count>0)
{
errCode="VMDUPL1";
}
else
{
sql="select fld_width from genmst where fld_name = ? and mod_name = ?";
if (fld_width == null)
{
li_fld_width = 20 ;
}
else if(li_fld_width < fld_value.trim().length())
{
errCode="VTGENLEN";
}
}
}
}
else if (childNodeName.equalsIgnoreCase("descr"))
{
descrstr = (String) checkNull(genericUtility.getColumnValue("descr", dom));
System.out.println("@@@@ descr[" + descrstr + "]");
if (descrstr != null && descrstr.trim().length() > 0)
{
errCode="VTMARDESC";
errList.add(descrstr);
errFields.add(childNodeName.toLowerCase());
}
val= checkNull(genericUtility.getColumnValue("mod_name", dom));
sql="SELECT COUNT(*) FROM genmst WHERE mod_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, val);
rs = pstmt.executeQuery();
if(rs.next()) {
cnt=rs.getInt(1);
}
}//End of else Statement
}
valueXmlString.append("</Detail1>");
break;
}// End of for loop Statement
//End
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.trim().equalsIgnoreCase("reg_code"))
{
regCode = this.genericUtility.getColumnValue("reg_code", dom);
if (regCode != null)
if(cnt == 0 )
{
cnt = 0;
sql = "select count(*) as cnt from reg_requirements where reg_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, regCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VTRCODEXT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else
{
errCode = "VTRCODNULL";
errCode = "VTINMODNM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.trim().equalsIgnoreCase("reg_date"))
{
regDate = this.genericUtility.getColumnValue("reg_date", dom);
if (regDate == null)
{
errCode = "VTREGNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.trim().equalsIgnoreCase("valid_upto"))
{
validUpto = this.genericUtility.getColumnValue("valid_upto", dom);
regDate = this.genericUtility.getColumnValue("reg_date", dom);
if(validUpto==null){
errCode = "VTVALNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}else if (regDate != null)
{
Timestamp validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(validUpto, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
Timestamp regDateNew = Timestamp.valueOf(genericUtility.getValidDateString(regDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if (validUptoDate.compareTo(regDateNew) <= 0)
{
errCode = "VTVALREGDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
valueXmlString.append("</Detail1>");
}// end of if block for cust_code
// change by mukesh on 17/06/2019
}
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if ((errList != null) && (errListSize > 0))
System.out.println("errListSize [" + errListSize+ "] errFields size [" + errFields.size() + "]");
if (errList != null && errListSize > 0)
{
for (cnt = 0; cnt < errListSize; cnt++)
System.out.println("errList["+ errList.toString() +"]");
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt);
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errFldName ..........[" + errFldName+"]");
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString ..........[" + errString+"]");
errorType = errorType(conn, errCode);
if (errString.length() > 0)
if("VTUREC1".equalsIgnoreCase(errCode))
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
startStr = errString.substring(0,errString.indexOf("<description>") + 13);
endStr = errString.substring(errString.indexOf("</description>"),errString.length());
descrStr = errString.substring(errString.indexOf("<description>") + 13,errString.indexOf("</description>"));
descrStart = descrStr.substring(0, descrStr.indexOf("]"));
descrEnd = descrStr.substring(descrStr.indexOf("]"),descrStr.length());
System.out.println("lsmsg1@@@["+lsmsg1+"]");
val ="" + lsmsg1;
System.out.println("Value ::: "+ val);
descrStart = descrStart.concat(val).concat(descrEnd);
System.out.println("descrStart@@@["+descrStart+"]");
errString = startStr.concat(descrStart).concat(endStr);
}
System.out.println("errorType ..........[" + errorType+"]");
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"))
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
} else
}
else
{
errStringXml = new StringBuffer("");
}
} catch (Exception e)
}// End of try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
} finally
}
finally
{
try
{
if (conn != null)
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
private Object checkNull(String input) {
return input == null ? "" : input;
}
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) {
System.out.println("Exception in isExist ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from isExist ");
return status;
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext,String currentColumn, String editFlag, String xtraParams)throws RemoteException, ITMException
{
Document dom = null, dom1 = null, dom2 = null;
String valueXmlString = "";
Document dom = null;
Document domhr = null;
Document domAll = null;
String retString = "";
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0)
System.out.println("************** Inside itemChanged method ****************");
if (xmlString != null && xmlString.trim().length() > 0)
{
dom2 = parseString(xmlString2);
dom = genericUtility.parseString(xmlString);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
System.out.println("valueXmlString[" + valueXmlString + "]");
} catch (Exception e)
{
System.out.println("Exception : [MiscVal][itemChanged( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String colname,ls_fld_name="",ls_mod_name="";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String sql = "", sql1 = "", sql2 = "";
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null, rs1 = null, rs2 = null;
String currCode = "", currCodeDesr = "", regCode = "", regDescr = "";
int ctr = 0, currentFormNo = 0, childNodeListLength = 0;
java.util.Date reqDate = null, statusDate = null;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
SimpleDateFormat sdf;
String columnValue="",loginSite="";
String fld_value="";
String fld_value2="";
StringBuffer valueXmlString = new StringBuffer();
//changes and commented by sarita on 31/05/2017
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
//changes and commented by sarita for DBConnection on 01/06/2017 :START
//conn = connDriver.getConnectDB("DriverITM");
//conn.setAutoCommit(false);
//connDriver = null;
conn = getConnection();
//changes and commented by sarita for DBConnection on 01/06/2017 :END
this.finCommon = new FinCommon();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0))
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
domhr = genericUtility.parseString(xmlString1);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
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));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("----------- inside itm_default ---------------");
fld_value = genericUtility.getColumnValue("fldname", dom);
fld_value2 = genericUtility.getColumnValue("mod_name", dom2);
valueXmlString.append("<fld_name>").append("<![CDATA[" + ls_fld_name + "]]>").append("</tran_date>");
valueXmlString.append("<mod_name>").append("<![CDATA[" + ls_mod_name + "]]>").append("</disburs_date>");
}
valueXmlString.append("</Detail1>");
System.out.println(" itemchanged case 2 valueXmlString : "+valueXmlString);
break;
domAll = genericUtility.parseString(xmlString2);
}
valueXmlString.append("</Root>");
}// end of try block
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
retString = itemChanged(dom, domhr, domAll, objContext, currentColumn, editFlag, xtraParams);
System.out.println("retString::::::::::" + retString);
}
finally
catch (Exception e)
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}// end of finally statement
return valueXmlString.toString();
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return retString;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
String msgType = "";
......@@ -541,31 +300,21 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal, Gencode
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next())
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
} catch (Exception ex)
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
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
throw new ITMException(ex);
}
finally
{
try
{
......@@ -579,7 +328,8 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal, Gencode
pstmt.close();
pstmt = null;
}
} catch (Exception e)
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
......@@ -587,4 +337,22 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal, Gencode
}
return msgType;
}
}
public String checkNullAndTrim( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
}
\ 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