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;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.util.Date;
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.HashMap;
import java.util.List;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Session Bean implementation class EnterpriseIC
*/
@Stateless
public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote, SRLContainerICLocal
{
......@@ -74,7 +72,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
PreparedStatement pstmt = null;
ResultSet rs = null ;
int currentFormNo = 0 , cnt = 0 , detlCnt = 0;
String updateFlag = "", detItemCode="", contentType = "", itemCodeDtl = "";
String updateFlag = "", detItemCode="", contentType = "", itemCodeDtl = "", quantity = "";
List<String> DetItemCodeList = new ArrayList<String>();
try
{
......@@ -100,6 +98,17 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
childNodeName = childNode.getNodeName();
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))
{
......@@ -114,47 +123,115 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
errFields.add("no_art");
}
else if(noArt != null && noArt.length() > 0)
{
try
{
int noArtValue = Integer.parseInt(noArt);
if(noArtValue == 0)
if(noArtValue == 0 || noArtValue < 0)
{
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
else if("item_code".equalsIgnoreCase(childNodeName))
{
itemCode = checkNullAndTrim(genericUtility.getColumnValue("item_code",dom)).trim();
inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim();
System.out.println("[ITEM CODE ["+itemCode+"]] \n [Inventory Type ["+inventoryType+"]] ");
if("0".equalsIgnoreCase(inventoryType))
{
//if("0".equalsIgnoreCase(inventoryType))
//{
if(itemCode == null || itemCode.length() == 0)
{
errCode = "VTITEMBLK";
errList.add(errCode);
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,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))
{
inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim();
//inventoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type",dom)).trim();
lotNo = checkNullAndTrim(genericUtility.getColumnValue("lot_no",dom)).trim();
System.out.println("[Inventory Type ["+inventoryType+"]] \n [Lot Number ["+lotNo+"]]");
if("2".equalsIgnoreCase(inventoryType))
{
System.out.println("[Lot Number ["+lotNo+"]]");
//if("2".equalsIgnoreCase(inventoryType))
//{
if(lotNo == null || lotNo.length() == 0)
{
errCode = "VMLOTNONUL";
errList.add(errCode);
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
else if("lot_sl".equalsIgnoreCase(childNodeName))
{
lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim();
......@@ -213,7 +290,6 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
childNodeName = childNode.getNodeName();
System.out.println("[childNodeName[Validation][Detail2]===========> ]"+childNodeName);
if("serial_no__content".equalsIgnoreCase(childNodeName))
{
serialNoContent = checkNullAndTrim(genericUtility.getColumnValue("serial_no__content",dom)).trim();
......@@ -226,6 +302,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
errFields.add("serial_no__content");
}
}//end of validation for serial_no__content
else if("item_code".equalsIgnoreCase(childNodeName))
{
inverntoryType = checkNullAndTrim(genericUtility.getColumnValue("inventory_type", dom1));
......@@ -234,15 +311,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
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+"] ");
if("0".equalsIgnoreCase(contentType) && "0".equalsIgnoreCase(contentType))
{
//if("0".equalsIgnoreCase(contentType) && "0".equalsIgnoreCase(contentType))
//{
if(itemCodeDtl == null || itemCodeDtl.trim().length() == 0)
{
errCode = "VTITEMCD";
errList.add(errCode);
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))
{
int detlCnt1 = getNumOfNonDelDetail(dom2,2); System.out.println("Detal Count in Itemchange ::::["+detlCnt1+"]");
......@@ -269,6 +374,50 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
}
}
}//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))
{
lotSl = checkNullAndTrim(genericUtility.getColumnValue("lot_sl",dom)).trim();
......@@ -302,12 +451,43 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
}
if(cnt > 0)
{
errCode = "VTINVLOTSL";
errCode = "VTINVSRIAL";//"VTINVLOTSL";
errList.add(errCode);
errFields.add("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 ---------------------------------
break;
......@@ -441,10 +621,12 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
Node childNode = null;
NodeList childNodeList = null;
int childNodeListLength = 0 , cnt = 0;
SimpleDateFormat sdf;
String serialNo = "", serialDate = "", description = "", numOfArticle="", inverntoryType="", contentLevel="",itemCode="",lotNo="",lotSl="",createSource="",srlNoSource="";
try
{
conn = getConnection();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
......@@ -467,8 +649,16 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn-----for case1--->>[" + currentColumn + "]");
if("itm_defaultedit".equalsIgnoreCase(currentColumn.trim()))
if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
valueXmlString.append("<serial_date>").append("<![CDATA[" + sdf.format(new Date())+ "]]>").append("</serial_date>");
}
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));
sql = "select descr from item where item_code=?";
pstmt = conn.prepareStatement(sql);
......@@ -543,7 +733,7 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
if(rs.next())
{
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)
{
......@@ -714,7 +904,8 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
throw new ITMException(e);
}
return cntr;
}
}//end of method getNumOfNonDelDetail
public String getAttributeVal(Node dom, String attribName )throws ITMException
{
System.out.println("Inside getAttributeVal method is !!!!!!!!!!!!!!");
......@@ -742,11 +933,11 @@ public class SRLContainerIC extends ValidatorEJB implements SRLContainerICRemote
}
catch (Exception e)
{
System.out.println("Exception : : searchNode :"+e);
System.out.println("Exception ::: searchNode :"+e);
throw new ITMException(e);
}
return AttribValue;
}
}//end of method getAttributeVal
}//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