Commit f5ba6ca6 authored by ssalve's avatar ssalve

Sarita: Done changes to add validation for quantity,lot_no,lot_sl and item_code on 08MARCH2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@181686 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c5e01bdc
...@@ -3,22 +3,20 @@ package ibase.webitm.ejb.dis; ...@@ -3,22 +3,20 @@ package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.util.Date;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/**
* Session Bean implementation class EnterpriseIC
*/
@Stateless @Stateless
public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote, SRLContainerICLocal public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote, SRLContainerICLocal
{ {
...@@ -74,7 +72,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -74,7 +72,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
int currentFormNo = 0 , cnt = 0 , detlCnt = 0; int currentFormNo = 0 , cnt = 0 , detlCnt = 0;
String updateFlag = "", detItemCode="", contentType = "", itemCodeDtl = ""; String updateFlag = "", detItemCode="", contentType = "", itemCodeDtl = "", quantity = "";
List<String> DetItemCodeList = new ArrayList<String>(); List<String> DetItemCodeList = new ArrayList<String>();
try try
{ {
...@@ -100,6 +98,17 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -100,6 +98,17 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("[childNodeName[Validation][Detail1]===========> ]"+childNodeName); System.out.println("[childNodeName[Validation][Detail1]===========> ]"+childNodeName);
if("serial_date".equalsIgnoreCase(childNodeName))
{
String serialDate = checkNullAndTrim(genericUtility.getColumnValue("serial_date",dom)).trim();
System.out.println("Date is :::["+serialDate+"]");
/*if(serialDate == null || serialDate.trim().length() == 0)
{
errCode = "DSSRDATE";
errList.add(errCode);
errFields.add("serial_date");
}*/
}
if("no_art".equalsIgnoreCase(childNodeName)) if("no_art".equalsIgnoreCase(childNodeName))
{ {
...@@ -115,46 +124,114 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -115,46 +124,114 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
} }
else if(noArt != null && noArt.length() > 0) else if(noArt != null && noArt.length() > 0)
{ {
int noArtValue = Integer.parseInt(noArt); try
if(noArtValue == 0)
{ {
errCode = "VMNOART"; int noArtValue = Integer.parseInt(noArt);
errList.add(errCode); if(noArtValue == 0 || noArtValue < 0)
errFields.add("no_art"); {
errCode = "VMNOART";
errList.add(errCode);
errFields.add("no_art");
}
}
catch(NumberFormatException ex)
{
System.out.println("Getting NumberFormatException in [SRLContainerIC] ::"+ex);
errCode = "SRWIZQTY1";
errList.add(errCode);
errFields.add("no_art");
} }
} }
}//End of Validation for no_art }//End of Validation for no_art
else if("item_code".equalsIgnoreCase(childNodeName)) else if("item_code".equalsIgnoreCase(childNodeName))
{ {
itemCode = checkNullAndTrim(genericUtility.getColumnValue("item_code",dom)).trim(); itemCode = checkNullAndTrim(genericUtility.getColumnValue("item_code",dom)).trim();
inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim(); inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim();
System.out.println("[ITEM CODE ["+itemCode+"]] \n [Inventory Type ["+inventoryType+"]] "); System.out.println("[ITEM CODE ["+itemCode+"]] \n [Inventory Type ["+inventoryType+"]] ");
if("0".equalsIgnoreCase(inventoryType)) //if("0".equalsIgnoreCase(inventoryType))
{ //{
if(itemCode == null || itemCode.length() == 0) if(itemCode == null || itemCode.length() == 0)
{ {
errCode = "VTITEMBLK"; errCode = "VTITEMBLK";
errList.add(errCode); errList.add(errCode);
errFields.add("item_code"); errFields.add("item_code");
} }
} else if(itemCode != null && itemCode.trim().length() > 0)
}//End of Validation for item_code {
sql = "select count(*) as cnt from item where item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
System.out.println("Cnt..item_code :"+cnt);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "IVITMCDASN";
errList.add(errCode);
errFields.add("item_code");
}
}
//}
}//End of Validation for item_code
else if("lot_no".equalsIgnoreCase(childNodeName)) else if("lot_no".equalsIgnoreCase(childNodeName))
{ {
inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim(); //inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim();
lotNo = checkNullAndTrim(genericUtility.getColumnValue("lot_no",dom)).trim(); lotNo = checkNullAndTrim(genericUtility.getColumnValue("lot_no",dom)).trim();
System.out.println("[Inventory Type ["+inventoryType+"]] \n [Lot Number ["+lotNo+"]]"); System.out.println("[Lot Number ["+lotNo+"]]");
if("2".equalsIgnoreCase(inventoryType)) //if("2".equalsIgnoreCase(inventoryType))
{ //{
if(lotNo == null || lotNo.length() == 0) if(lotNo == null || lotNo.length() == 0)
{ {
errCode = "VMLOTNONUL"; errCode = "VMLOTNONUL";
errList.add(errCode); errList.add(errCode);
errFields.add("lot_no"); errFields.add("lot_no");
} }
} else if(lotNo != null && lotNo.length() > 0)
{
sql = "select count(*) as cnt from Stock where lot_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lotNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "VTLOTASN";
errList.add(errCode);
errFields.add("lot_no");
}
}
//}
}//end of validation for lot_no }//end of validation for lot_no
else if("lot_sl".equalsIgnoreCase(childNodeName)) else if("lot_sl".equalsIgnoreCase(childNodeName))
{ {
lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim(); lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim();
...@@ -212,8 +289,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -212,8 +289,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("[childNodeName[Validation][Detail2]===========> ]"+childNodeName); System.out.println("[childNodeName[Validation][Detail2]===========> ]"+childNodeName);
if("serial_no__content".equalsIgnoreCase(childNodeName)) if("serial_no__content".equalsIgnoreCase(childNodeName))
{ {
serialNoContent = checkNullAndTrim(genericUtility.getColumnValue("serial_no__content",dom)).trim(); serialNoContent = checkNullAndTrim(genericUtility.getColumnValue("serial_no__content",dom)).trim();
...@@ -226,6 +302,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -226,6 +302,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
errFields.add("serial_no__content"); errFields.add("serial_no__content");
} }
}//end of validation for serial_no__content }//end of validation for serial_no__content
else if("item_code".equalsIgnoreCase(childNodeName)) else if("item_code".equalsIgnoreCase(childNodeName))
{ {
inverntoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type", dom1)); inverntoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type", dom1));
...@@ -234,15 +311,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -234,15 +311,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
itemCodeDtl = checkNullAndTrim(genericUtility.getColumnValue("item_code", dom)); itemCodeDtl = checkNullAndTrim(genericUtility.getColumnValue("item_code", dom));
System.out.println("Inventory Type ====> ["+inverntoryType+"] \t Item Code Header=====> ["+itemCode+"]\t Content Type ======>["+contentType+"]\t Item Code Detail ["+itemCodeDtl+"] "); System.out.println("Inventory Type ====> ["+inverntoryType+"] \t Item Code Header=====> ["+itemCode+"]\t Content Type ======>["+contentType+"]\t Item Code Detail ["+itemCodeDtl+"] ");
if("0".equalsIgnoreCase(contentType) && "0".equalsIgnoreCase(contentType)) //if("0".equalsIgnoreCase(contentType) && "0".equalsIgnoreCase(contentType))
{ //{
if(itemCodeDtl == null || itemCodeDtl.trim().length() == 0) if(itemCodeDtl == null || itemCodeDtl.trim().length() == 0)
{ {
errCode = "VTITEMCD"; errCode = "VTITEMCD";
errList.add(errCode); errList.add(errCode);
errFields.add("item_code"); errFields.add("item_code");
} }
} else if(itemCode != null && itemCode.trim().length() > 0)
{
sql = "select count(*) as cnt from item where item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCodeDtl);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
System.out.println("Cnt..item_code :"+cnt);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "IVITMCDASN";
errList.add(errCode);
errFields.add("item_code");
}
}
//}
else if("0".equalsIgnoreCase(inverntoryType)) else if("0".equalsIgnoreCase(inverntoryType))
{ {
int detlCnt1 = getNumOfNonDelDetail(dom2,2); System.out.println("Detal Count in Itemchange ::::["+detlCnt1+"]"); int detlCnt1 = getNumOfNonDelDetail(dom2,2); System.out.println("Detal Count in Itemchange ::::["+detlCnt1+"]");
...@@ -269,6 +374,50 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -269,6 +374,50 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
} }
} }
}//end of validation for item_code }//end of validation for item_code
else if("lot_no".equalsIgnoreCase(childNodeName))
{
lotNo = checkNullAndTrim(genericUtility.getColumnValue("lot_no",dom)).trim();
contentType = checkNullAndTrim(genericUtility.getColumnValue("content_type", dom));
System.out.println("[Lot Number ["+lotNo+"]] \t [Content Type ["+contentType+"]]");
if("0".equalsIgnoreCase(contentType))
{
if(lotNo == null || lotNo.trim().length() == 0)
{
errCode = "VMLOTNONUL";
errList.add(errCode);
errFields.add("lot_no");
}
}
if(lotNo != null && lotNo.length() > 0)
{
sql = "select count(*) as cnt from Stock where lot_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lotNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "VTLOTASN";
errList.add(errCode);
errFields.add("lot_no");
}
}
}//end of validation for lot_no
else if("lot_sl".equalsIgnoreCase(childNodeName)) else if("lot_sl".equalsIgnoreCase(childNodeName))
{ {
lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim(); lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim();
...@@ -302,12 +451,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -302,12 +451,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
} }
if(cnt > 0) if(cnt > 0)
{ {
errCode = "VTINVLOTSL"; errCode = "VTINVSRIAL";//"VTINVLOTSL";
errList.add(errCode); errList.add(errCode);
errFields.add("lot_sl"); errFields.add("lot_sl");
} }
} }
}//end of validation for lot_sl }//end of validation for lot_sl
else if("quantity".equalsIgnoreCase(childNodeName))
{
quantity = checkNullAndTrim(genericUtility.getColumnValue("quantity",dom)).trim();
System.out.println("Quantity is ::: ["+quantity+"]");
if(quantity == null || quantity.trim().length() == 0)
{
errCode = "VTQUNT2";
errList.add(errCode);
errFields.add("quantity");
}
else if(quantity != null && quantity.length() > 0)
{
try
{
int qty = Integer.parseInt(quantity);
if(qty == 0)
{
errCode = "VMNOART";
errList.add(errCode);
errFields.add("quantity");
}
}
catch(NumberFormatException e)
{
errCode = "SRWIZQTY1";
errList.add(errCode);
errFields.add("quantity");
}
}
}//end of validation for quantity
} }
}//----------------------- End of Case2 --------------------------------- }//----------------------- End of Case2 ---------------------------------
break; break;
...@@ -441,10 +621,12 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -441,10 +621,12 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
Node childNode = null; Node childNode = null;
NodeList childNodeList = null; NodeList childNodeList = null;
int childNodeListLength = 0 , cnt = 0; int childNodeListLength = 0 , cnt = 0;
SimpleDateFormat sdf;
String serialNo = "", serialDate = "", description = "", numOfArticle="", inverntoryType="", contentLevel="",itemCode="",lotNo="",lotSl="",createSource="",srlNoSource=""; String serialNo = "", serialDate = "", description = "", numOfArticle="", inverntoryType="", contentLevel="",itemCode="",lotNo="",lotSl="",createSource="",srlNoSource="";
try try
{ {
conn = getConnection(); conn = getConnection();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
...@@ -466,9 +648,17 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -466,9 +648,17 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
valueXmlString.append("<Detail1>\r\n"); valueXmlString.append("<Detail1>\r\n");
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn-----for case1--->>[" + currentColumn + "]"); System.out.println("currentColumn-----for case1--->>[" + currentColumn + "]");
if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
valueXmlString.append("<serial_date>").append("<![CDATA[" + sdf.format(new Date())+ "]]>").append("</serial_date>");
}
if("itm_defaultedit".equalsIgnoreCase(currentColumn.trim())) else if("itm_defaultedit".equalsIgnoreCase(currentColumn.trim()))
{ {
serialDate = checkNullAndTrim(genericUtility.getColumnValue("serial_date", dom));
valueXmlString.append("<serial_date>").append("<![CDATA[" + serialDate + "]]>").append("</serial_date>");
itemCode = checkNullAndTrim(genericUtility.getColumnValue("item_code", dom)); itemCode = checkNullAndTrim(genericUtility.getColumnValue("item_code", dom));
sql = "select descr from item where item_code=?"; sql = "select descr from item where item_code=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -543,7 +733,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -543,7 +733,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
if(rs.next()) if(rs.next())
{ {
item_descr = rs.getString("descr"); item_descr = rs.getString("descr");
System.out.println("Item Description is [Detail]===========>"+item_descr); System.out.println("Item Description is [Detail2]===========>"+item_descr);
} }
if(pstmt != null) if(pstmt != null)
{ {
...@@ -714,7 +904,8 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -714,7 +904,8 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
throw new ITMException(e); throw new ITMException(e);
} }
return cntr; return cntr;
} }//end of method getNumOfNonDelDetail
public String getAttributeVal(Node dom, String attribName )throws ITMException public String getAttributeVal(Node dom, String attribName )throws ITMException
{ {
System.out.println("Inside getAttributeVal method is !!!!!!!!!!!!!!"); System.out.println("Inside getAttributeVal method is !!!!!!!!!!!!!!");
...@@ -742,11 +933,11 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote ...@@ -742,11 +933,11 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception : : searchNode :"+e); System.out.println("Exception ::: searchNode :"+e);
throw new ITMException(e); throw new ITMException(e);
} }
return AttribValue; return AttribValue;
} }//end of method getAttributeVal
}//end of class SRLContainerIC }//end of class SRLContainerIC
......
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