Commit 1f7c853d authored by mchauhan's avatar mchauhan

validation for mod name, fld name and same for the item change.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202687 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5492d46a
......@@ -75,6 +75,7 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
int childNodeLength = 0;
int currentFormNo = 0;
int ctr = 0, cnt = 0;
int fldWidth=0;
Connection conn = null;
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
......@@ -85,27 +86,21 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
Node childNode = null;
String childNodeName = "";
String userId = "";
String currcode = "",acccode = "",sundry_type = "",tranDateStr="",tranSer="";
String sundtype = "";
String currcode = "",acccode = "",descr = "",tranDateStr="",tranSer="";
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 fldName="",fldValue,modName,val,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
{
......@@ -116,8 +111,7 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
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);
......@@ -134,28 +128,146 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
// change by mukesh on 17/06/2019
// change by mukesh on 27/06/2019 START
if(childNodeName.equalsIgnoreCase("mod_name"))
{
val= checkNull(genericUtility.getColumnValue("mod_name", dom));
modName= checkNull(genericUtility.getColumnValue("mod_name", dom));
sql="SELECT COUNT(*) FROM genmst WHERE mod_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, val);
pstmt.setString(1, modName);
rs = pstmt.executeQuery();
if(rs.next()) {
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0 )
{
System.out.println("count:"+cnt);
errCode = "VTINMODNM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}// end of if block for cust_code
// change by mukesh on 17/06/2019
}
}
else if(childNodeName.equalsIgnoreCase("fld_value"))
{
fldValue= checkNull(genericUtility.getColumnValue("fld_value", dom));
System.out.println("fld value :"+fldValue);
modName= checkNull(genericUtility.getColumnValue("mod_name", dom));
fldName= checkNull(genericUtility.getColumnValue("fld_name", dom));
if(fldValue==null || fldValue.trim().length()== 0)
{
errCode = "VMCODNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if("A".equalsIgnoreCase(editFlag))
{
sql="SELECT COUNT(*) FROM gencodes WHERE fld_value=? and mod_name = ? and fld_name=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, fldValue);
pstmt.setString(2, modName);
pstmt.setString(3, fldName);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt > 0 )
{
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql="SELECT fld_width FROM genmst WHERE fld_name=? and mod_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, fldName);
pstmt.setString(2, modName);
rs = pstmt.executeQuery();
if(rs.next())
{
fldWidth=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(fldWidth == 0)
{
fldWidth = 20;
}
if(fldWidth<fldValue.trim().length())
{
errCode = "VTGENLEN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
else if(childNodeName.equalsIgnoreCase("descr"))
{
descr= (genericUtility.getColumnValue("descr", dom));
if(descr==null || descr.trim().length()== 0)
{
errCode = "VTMARDESC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("fld_name"))
{
modName= checkNull(genericUtility.getColumnValue("mod_name", dom));
fldName= checkNull(genericUtility.getColumnValue("fld_name", dom));
if(fldName==null || fldName.trim().length()== 0)
{
errCode = "VTINFLDNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if(modName!=null && modName.trim().length()>0)
{
sql="SELECT COUNT(*) FROM genmst WHERE mod_name = ? and fld_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, modName);
pstmt.setString(2, fldName);
rs = pstmt.executeQuery();
if(rs.next()) {
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0 )
{
System.out.println("count:"+cnt);
errCode = "VTINFLDNM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
// change by mukesh on 27/06/2019 END
}
int errListSize = errList.size();
cnt = 0;
......@@ -258,6 +370,9 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext,String currentColumn, String editFlag, String xtraParams)throws RemoteException, ITMException
{
Document dom = null;
Document domhr = null;
Document domAll = null;
......@@ -288,7 +403,121 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
return retString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String modname="";
String fldname="";
String sql = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
E12GenericUtility genericUtility= new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0, childNodeListLength=0;
String columnValue="",hdrTranId = "",itemCode = "";
String tranDateStr = "", loginSiteDesc= "", siteCode = "",loginSite= "", deptCode = "", deptDesc = "";
String stkOpt = "",itemDescr = "",unit = "",locCode = "",lotNo = "",lotSl = "",locDescr = "",quantityStr="",rateStr = "";
String grossWeightStr = "",tareWeightStr ="",packCode = "";
String custCode = "",reStr = "",expdateStr="",effDateStr ="",mfgDateStr ="",expDateStr="",netWeightStr="";
int pos=0;
double amount= 0.0,quantity =0.0,rate =0.0,netWeight =0.0,grossWeight =0.0,tareWeight=0.0,stkQuantity =0.0;
double shipperQty = 0.0 ,integralQty = 0.0,qtyPerArt =0.0,grossper=0.0,tareper=0.0,netper=0.0;
long noArt =0;
double noOfArt = 0d, shipperSize = 0d, mGrossWeight = 0d, mNetWeight = 0d, mGrosswt = 0d, mNetWt = 0d, mTareWt = 0d;
try
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
conn = getConnection();
conn.setAutoCommit(false);
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
System.out.println("Now the date is :=> " + sysDate);
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'");
valueXmlString.append("<Detail1>");
//Changes and Commented By Mukesh on 26-06-2019 :START
if ("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
if(!"A".equalsIgnoreCase(editFlag))
{
modname = genericUtility.getColumnValue("mod_name", dom);
fldname = genericUtility.getColumnValue("fld_name", dom);
valueXmlString.append("<mod_name protect =\"1\">").append("<![CDATA[" + modname + "]]>").append("</mod_name>");
valueXmlString.append("<fld_name protect =\"1\">").append("<![CDATA[" + fldname + "]]>").append("</fld_name>");
}
}
valueXmlString.append("</Detail1>");
break;
//Changes and Commented By Mukesh on 26-06-2019 :END
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ 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();
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
String msgType = "";
......@@ -355,4 +584,12 @@ public class GencodesIC extends ValidatorEJB implements GencodesICLocal,Gencodes
{
return input == null ? "" : input;
}
private Object Round(double d)
{
// TODO Auto-generated method stub
return null;
}
}
\ 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