Upload New File

parent cb817639
package ibase.utility.training;
import javax.naming.InitialContext;
import ibase.ejb.CommonDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Random;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import ibase.bi.common.system.config.DBInfo;
import ibase.ejb.CommonDBAccessEJB;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.servlet.APISampleServlet;
import ibase.webitm.utility.ITMException;
public class GenerateXml extends ActionHandlerEJB
{
// APISampleServlet generApiSampleServlet=new APISampleServlet();
String database = "";
/// at here change datatype of string to connn --
public String actionHandler(String tranID, String xtraParam,Connection Conn)
throws RemoteException, ITMException {
AppConnectParm appConnect = new AppConnectParm();
InitialContext initialContext;
try {
initialContext = new InitialContext(appConnect.getProperty());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BaseLogger.log("3", null, null, "xtraParamvalues : [" + xtraParam + "]");
UserInfoBean userInfo = getUserInfo();
String userInfoStr = userInfo.getUserName();
BaseLogger.log("3", null, null, "userInfo : [" + userInfo + "]");
BaseLogger.log("3", null, null, "userInfoStr : [" + userInfoStr + "]");
StringBuffer xmlBuffer = new StringBuffer();
xmlBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlBuffer.append("<Root>");
xmlBuffer.append(" <Detail1>");
xmlBuffer.append(" <tran_id><![CDATA[P2BPH0091]]></tran_id>");
xmlBuffer.append(" <ref_ser><![CDATA[TOOL]]></ref_ser>");
xmlBuffer.append(" <ref_id><![CDATA[45671]]></ref_id>");
xmlBuffer.append(" <status_date><![CDATA[2020/11/23]]></status_date>");
xmlBuffer.append(" <stage_descr><![CDATA[initiated]]></stage_descr>");
xmlBuffer.append(" <remarks><![CDATA[Acknowledgement Accepted]]></remarks>");
xmlBuffer.append(" <error_det><![CDATA[format created successfully]]></error_det>");
xmlBuffer.append(" <add_date><![CDATA[2020/11/23]]></add_date>");
xmlBuffer.append(" <add_term><![CDATA[SYSTEM]]></add_term>");
xmlBuffer.append(" <add_user><![CDATA[TWINKLE]]></add_user>");
xmlBuffer.append(" <chg_date><![CDATA[2021/11/23]]></chg_date>");
xmlBuffer.append(" <chg_user><![CDATA[TWINKLE]]></chg_user>");
xmlBuffer.append(" <chg_term><![CDATA[SYSTEM]]></chg_term>");
xmlBuffer.append(" </Detail1>");
xmlBuffer.append("</Root>");
String xmlString = xmlBuffer.toString();
//Amol
//MasterStatefulLocal masterStateful=null;
xmlBuffer.append("</Header0></group0></DocumentRoot>");
String XmlString = xmlBuffer.toString();
System.out.println("returnString:::::FOR XmlString 111 :: "+XmlString);
MasterStatefulLocal masterStateful = (MasterStatefulLocal)initialContext.lookup("ibase/MasterStatefulEJB/local");
String reString = masterStateful.processRequest( getUserInfo(), XmlString, true, Conn);
System.out.println("returnString:::::FOR DUMY 111 ::"+reString);
//
BaseLogger.log("3", null, null, "GET xmlString : [" + xmlString + "]");
boolean isPartOfExtTrans = true;
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null;
String resultgenerate="";
BaseLogger.log("3", null, null, "Inside the method..");
//
BaseLogger.log("3", null, null, "GET tranID [" + tranID + "]");
BaseLogger.log("3", null, null, "GET forcedFlag [" + conn + "]");
BaseLogger.log("3", null, null, "GET xtraParam [" + xtraParam + "]");
// MasterStatefulEJB masterStatefulEJB= new MasterStatefulEJB();
// String processRequestResult = masterStatefulEJB.processRequest(userInfoStr, xmlString,isPartOfExtTrans, getConnection());
// BaseLogger.log("3", null, null, "Entri in processRequest [" + processRequestResult + "]");
////// MasterStatefulEJB//////
// try {
// MasterStatefulEJB masterStatefulEJB = new MasterStatefulEJB();
// String processRequestResult = masterStatefulEJB.processRequest(userInfoStr, xmlString, isPartOfExtTrans, getConnection());
// }
// catch (Exception e)
// {
//
// e.printStackTrace();
// BaseLogger.log("3", null, null, "Exception in processRequest [" + e + "]");
//
// }
PreparedStatement statement = null;
ResultSet resultSet = null;
try {
ConnDriver conDriver = new ConnDriver();
conn = conDriver.getConnectDB(DBInfo.getDataProfileName("DriverBI"));
conn = conDriver.getConnectDB("Driver");
String query = "SELECT * FROM Misc_payment WHERE TRAN_ID=? and confirmed='Y'";
statement = conn.prepareStatement(query);
statement.setString(1, tranID);
resultSet = statement.executeQuery();
BaseLogger.log("3", null, null, "GET resultset [" + resultSet + "]");
String loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParam, "loginCode");
if (resultSet.next()) {
// String tran_ID = resultSet.getString("TRAN_ID");
BaseLogger.log("3", null, null, "Inside actionHandler loginCode[" + loginCode + "]");
// getDetailXMLDomString();
resultgenerate = getDetailXMLDomString("misc_pay", "1", "V", tranID, null, loginCode);
BaseLogger.log("3", null, null, "Inside returnresult[" + resultgenerate + "]");
}
else {
//c String result = itmDBAccessEJB.getErrorString("", "XMLGENF", loginCode, "", conn);
//c return result;
}
} catch (Exception e) {
// Handle SQLException
e.printStackTrace();
} finally {
try {
if (resultSet != null)
resultSet.close();
if (statement != null)
statement.close();
//c if (conn != null)
//c conn.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
return resultgenerate;
}
private String getDetailXMLDomString(String objName, String objContext, String editFlag, String pkValues,
String argFieldValues, String userCode)
throws RemoteException, ibase.webitm.utility.ITMException, ITMException {
String resultString = "";
// Added By Nilesh Start ::12-05-2017
MasterStatefulLocal masterStateful = null;
// Added By Nilesh End ::12-05-2017
try {
// create user info from user code.
CommonDBAccessEJB commonDBAccessEJB = new CommonDBAccessEJB();
UserInfoBean userInfo = commonDBAccessEJB.createUserInfo(userCode);
masterStateful = (MasterStatefulLocal) getInitialContext().lookup("ibase/MasterStatefulEJB/local");
int randInt = new Random().nextInt();
masterStateful.setEditorId("" + randInt);
masterStateful.setUserInfo(userInfo);
resultString = masterStateful.getDetailXMLDomString(objName, objContext, editFlag, pkValues,
argFieldValues);
} catch (NamingException e) {
BaseLogger.log("0", null, null, "NamingException :: getDetailXMLDomString() :==>\n" + e.getMessage());
throw new ITMException(e);
}
// Added By Nilesh Start ::12-05-2017
catch (BaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (masterStateful != null) {
masterStateful.remove();
masterStateful = null;
}
}
// Added By Nilesh End ::12-05-2017
return resultString;
}
private InitialContext getInitialContext() throws ITMException {
InitialContext ctx = null;
try {
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
} catch (ITMException itme) {
BaseLogger.log("0", null, null, "ITMException : getInitialContext : " + itme.getMessage());
throw itme;
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception : getInitialContext : " + e.getMessage());
throw new ITMException(e);
}
return ctx;
}
public Connection getConnection(String transDB)throws RemoteException,ITMException
{
BaseLogger.log("3", null, null, "Inside the getConnection...");
Connection conn = null;
try
{
BaseLogger.log("3",getUserInfo(),null,"IN getConnection METHOD");
ConnDriver connDriver = null;
connDriver = new ConnDriver();
//Added by Pankaj T on 19-12-17 [changes for multitenancy]
conn = connDriver.getConnectDB(transDB);
//conn = connDriver.getConnectDB(transDB); //$NON-NLS-1$
conn.setAutoCommit(false);
//Added By Pankaj T. on 16-06-2021 to get dbName from connection url instead of Commonconstant
database = connDriver.getDBName();
}
catch(Exception e)
{
BaseLogger.log("0",getUserInfo(),null,"Exception : [DocumentHandlerEJB][getConnection] :==>\n"+e.getMessage()); //$NON-NLS-1$
e.printStackTrace();
throw new ITMException(e);
}
return conn;
}
}
\ 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