Commit 41fb5ded authored by caluka's avatar caluka

Ejb added to run Physical count Schedule Process in metis [D14DSUN018]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95743 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 18e4c40e
/********************************************************
Title : PhysicalCountPrcIC[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
public class PhysicalCountPrcIC extends ValidatorEJB implements PhysicalCountPrcICLocal, PhysicalCountPrcICRemote
{
// method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
System.out.println("xmlString............."+xmlString);
System.out.println("xmlString1............"+xmlString);
System.out.println("xmlString2............"+xmlString);
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [PhysicalCountPrcIC][itemChanged( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
// method for item change
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String childNodeName = null;
String sql = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0;
String columnValue="",loginSiteCode="",loginEmpCode="";
try
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
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();
ctr = 0;
valueXmlString.append("<Detail1>");
int 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(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("@@@@@@@@ itm_defaultedit called @@@@@@@@");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA["+loginSiteCode+"]]>").append("</site_code>");
}
valueXmlString.append("</Detail1>");
break;
}
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 checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
/********************************************************
Title : PhysicalCountPrcICLocal[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PhysicalCountPrcICLocal extends ValidatorLocal
{
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : PhysicalCountPrcICRemote[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface PhysicalCountPrcICRemote extends ValidatorRemote
{
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : PhysicalCountProcess[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.rmi.RemoteException;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class PhysicalCountProcess extends ProcessEJB implements PhysicalCountProcessLocal,PhysicalCountProcessRemote
{
String loginSiteCode = null;
String loginEmpCode = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String currDateTs = null;
String chgUser = "";
String chgTerm = "";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String process(String xmlString, String xmlString2, String windowName, String xtraParams)
throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
String retStr = "";
System.out.println("Process method called......");
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :PhysicalCountProcess :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}//END OF PROCESS (1)
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
String resultString = "", errString = "";
boolean isError = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
ibase.utility.UserInfoBean userInfo = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
System.out.println("loginSiteCode["+loginSiteCode+"]"+"loginEmpCode["+loginEmpCode+"]");
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
PhysicalCountSchedule phycntprc = new PhysicalCountSchedule();
phycntprc.insertSchedule(loginSiteCode, loginEmpCode,userInfo);
} // end of try code
catch(Exception e)
{
isError = true;
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)rs.close();
rs = null;
if(pstmt != null)pstmt.close();
pstmt = null;
if(conn != null)
{
if(isError)
{
conn.rollback();
System.out.println("connection rollback.............");
resultString = itmDBAccessEJB.getErrorString("","PROCFAILED",userId);
}
else
{
conn.commit();
System.out.println("commiting connection.............");
if(errString.equals(""))
{
errString = "PROCSUCC";
}
resultString = itmDBAccessEJB.getErrorString("",errString,userId);
}
conn.close();
conn = null;
}
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
}
System.out.println("returning from "+resultString);
return resultString;
} //end process
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
/********************************************************
Title : PhysicalCountProcessLocal[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
import ibase.webitm.utility.ITMException;
@Local // added for ejb3`
public interface PhysicalCountProcessLocal extends ProcessLocal
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : PhysicalCountProcessRemote[D14DSUN018]
Date : 22/07/14
Developer: Chandrashekar
********************************************************/
package ibase.webitm.utility.wms;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface PhysicalCountProcessRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ 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