Commit 08aa26ab authored by dpawar's avatar dpawar

add component for pre save


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98168 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3920d358
/**
* PURPOSE : Pre Save Logic implementation for Picking component.
* AUTHOR : Gulzar on 15/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.ArrayList;
import org.w3c.dom.*;
import javax.ejb.*;
@javax.ejb.Stateless
public class MultiPickWizPrs extends ValidatorEJB implements MultiPickWizPrsLocal,MultiPickWizPrsRemote
{
public String preSave() throws RemoteException,ITMException
{
return "";
}
public String preSave(String xmlString, String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException
{
System.out.println("MultiPickWizPrs EJB called");
Document dom = null;
String retString = "";
try
{
System.out.println("xmlString in PickIssPrs : preSaveRec---->>["+xmlString+"]");
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString);
retString = executepreSave( dom, editFlag, xtraParams, conn );
}
}
catch(Exception e)
{
System.out.println("Exception :MultiPickWizPrs :" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("retString final------->>["+retString+"]");
return retString;
}
private String executepreSave( Document dom, String editFlag, String xtraParams, Connection conn ) throws RemoteException, ITMException
{
String sql = "";
String tranId = "";
String transMode = "",errString = "",ptcn = "";
int pachDetCnt = 0;
ArrayList<String> ptcnList = new ArrayList <String>();
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{
conn.setAutoCommit(false);
GenericUtility genericUtility = GenericUtility.getInstance();
tranId = checkNull(genericUtility.getColumnValue( "tran_id", dom, "2" ));
System.out.println("executepreSave tranId------>["+tranId+"]");
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
//transMode = checkNull(genericUtility.getColumnValue( "trans_mode", dom, "1" ));
//if( tranId.trim().length() > 0 && transMode.equalsIgnoreCase("E") )
if(dom != null )
{
System.out.println("------------Generate Error String-----------------");
NodeList nList = dom.getElementsByTagName("Detail2");
System.out.println("Length111------>>"+nList.getLength());
for (int temp = 0; temp < nList.getLength(); temp++)
{
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE)
{
Element eElement = (Element) nNode;
Node node1 = eElement.getElementsByTagName("attribute").item(0);
NamedNodeMap attrsMap = node1.getAttributes();
int noOfAttrs = attrsMap.getLength();
for( int cnt = 0 ; cnt < noOfAttrs; cnt++ )
{
Node attr = attrsMap.item(cnt);
String attrName = attr.getNodeName() ;
String attrValue = attr.getNodeValue() ;
attrName = attrName == null ? "" : attrName.trim();
attrValue = attrValue == null ? "" : attrValue.trim();
System.out.println("attrName : [" + attrName+"]");
System.out.println("attrValue : [" + attrValue+"]");
if( "updateFlag".equalsIgnoreCase(attrName) && "D".equalsIgnoreCase(attrValue) )
{
ptcn = eElement.getElementsByTagName("ptcn").item(0).getTextContent();
ptcnList.add(ptcn);
System.out.println("Deleted ptcn : [" + ptcn+"]");
}
else
{
continue;
}
}
}
}
System.out.println("Deleted ptcnList: [" + ptcnList+"]");
if(ptcnList != null && ptcnList.size() > 0)
{
sql = "select count(*) from pack_det where trim(carton_no) in "
+ "(select trim(carton_no) from carton_master where ptcn = ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcnList.get(0));
rs = pstmt.executeQuery();
if(rs.next())
{
pachDetCnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("pachDetCnt------>>[" + pachDetCnt+"]");
if(pachDetCnt > 0)
{
errString = itmdbAccess.getErrorString("", "VTCNDPTCN", "", "", conn);
return errString;
}
}
}
}
catch (SQLException sqe)
{
System.out.println("The SQLException occurs in PickIssPrs :"+sqe);
sqe.printStackTrace();
throw new ITMException(sqe);
}
catch(Exception e)
{
System.out.println("The Exception occurs in PickIssPrs :"+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)
{
System.err.println("Exception :PickIssPrs :\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
}
/**
* PURPOSE : Local Interface
* Author : Gulzar on 15/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.sql.*;
import java.rmi.RemoteException;
// The local interface declares all the utility functions to be used in your EJB component
@javax.ejb.Local
public interface MultiPickWizPrsLocal extends ValidatorLocal
{
public String preSave()throws RemoteException,ITMException;
public String preSave(String xmlString, String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
/**
* PURPOSE : Remote Interface
* Author : Gulzar on 15/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.sql.*;
import java.rmi.RemoteException;
// The remote interface declares all the utility functions to be used in your EJB component
@javax.ejb.Remote
public interface MultiPickWizPrsRemote extends ValidatorRemote//, EJBObject
{
public String preSave()throws RemoteException,ITMException;
public String preSave(String xmlString, String editFlag, String xtraParams, Connection conn)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