Commit 8df78967 authored by sjagtap's avatar sjagtap

Sun pharama business component use for multitancancy server

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187646 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4a3ee48c
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>webitm-sod</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
package ibase.webitm.ejb.SOD;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class SodRiskEJB extends ValidatorEJB implements SodRiskEJBLocal,
SodRiskEJBRemote {
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String editFlag,
String xtraParams) throws RemoteException {
System.out.println("In wfValData");
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = "";
try {
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0)) {
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0)) {
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0)) {
allDom = parseString(allFrmXmlStr);
}
errString = validate(currDom, hdrDom, allDom, objContext, editFlag,
xtraParams);
} catch (Exception e) {
System.out
.println("Exception : [PurcRCPIc][wfValData(String currFrmXmlStr)] : ==>\n"
+ e.getMessage());
}
return errString;
}
public String validate(Document currDom, Document hdrDom, Document allDom,
String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException {
System.out.println("In validate Data");
GenericUtility genericUtility = GenericUtility.getInstance();
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
int count = 0;
String errString = "";
String errorType = "";
String errCode = "";
StringBuffer errStringXml = new StringBuffer(
"<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String childNodeName = "";
String sql = "";
int noOfChilds = 0;
ResultSet rs1 = null;
String loginSiteCode = "";
Connection conn = null;
PreparedStatement pstmt1 = null;
int currentFormNo = 0;
int cnt = 0;
ConnDriver connDriver = null;
Node childNode = null;
try {
System.out.println("************xtraParams*************"
+ xtraParams);
connDriver = new ConnDriver();
//Comment by sanket J on 06/JUL/2018 for multitancy server
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,
"loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,
"loginSiteCode");
System.out.println("**************loginCode************" + userId);
if ((objContext != null) && (objContext.trim().length() > 0)) {
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail"
+ currentFormNo);
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom);
switch (currentFormNo) {
case 1:
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++) {
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1) {
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
System.out.println("childNodeName: " + childNodeName);
if ("risk_id".equalsIgnoreCase(childNodeName)) {
if (childNode.getFirstChild() == null) {
System.out.println("VTBLKRSKID");
errList.add("VTBLKRSKID");
errFields.add(childNodeName.toLowerCase());
break;
} else {
String risk_id = checkNull(genericUtility
.getColumnValue("risk_id", currDom));
System.out.println("editFlag in risk_id:"
+ editFlag);
if (editFlag.equalsIgnoreCase("A")) {
String sql1 = "SELECT COUNT(*) AS COUNT FROM SOD_RISK WHERE risk_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, risk_id);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
count = rs1.getInt("COUNT");
}
System.out.println("Count: " + count);
if (count > 0) {
errList.add("VTINVRSKID");
errFields.add(childNodeName.toLowerCase());
break;
}
System.out.println("risk_id.length(): "
+ risk_id.length());
if (risk_id.length() > 6) {
errList.add("VTINVRSKLT");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
if ("risk_lvl".equalsIgnoreCase(childNodeName)) {
if (childNode.getFirstChild() == null) {
System.out.println("VTBLKRSKLV");
errList.add("VTBLKRSKLV");
errFields.add(childNodeName.toLowerCase());
break;
} else {
String risk_lvl = checkNull(genericUtility
.getColumnValue("risk_lvl", currDom));
String sql1 = "SELECT COUNT(*) AS COUNT FROM GENCODES WHERE FLD_NAME = 'SOD_RISK_LVL' AND MOD_NAME='W_SOD_RISK' AND FLD_VALUE = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, risk_lvl.trim());
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
count = rs1.getInt("COUNT");
}
System.out.println("Count: " + count);
if (count <= 0) {
errList.add("VTINVRSKLV");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if ((errList != null) && (errListSize > 0)) {
for (cnt = 0; cnt < errListSize; cnt++) {
errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if (errString.length() > 0) {
String bifurErrString = errString.substring(
errString.indexOf("<Errors>") + 8,
errString.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(
errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."
+ errStringXml);
errString = "";
}
if (errorType.equalsIgnoreCase("E")) {
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
} else {
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
} catch (Exception e) {
System.out.println("Exception in StockTransferGrlIC == >");
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
if ((conn != null) && (!conn.isClosed()))
conn.close();
} catch (Exception e) {
System.out.println("Exception :InvBankDtlsIC:wfValData :==>\n"
+ e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
private String errorType(Connection conn, String errorCode) {
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next())
msgType = rs.getString("MSG_TYPE");
} catch (Exception ex) {
ex.printStackTrace();
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
}
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return msgType;
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs) {
try {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
private String checkNull(String inputVal) {
if (inputVal == null) {
inputVal = "";
}
return inputVal;
}
}
\ No newline at end of file
package ibase.webitm.ejb.SOD;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import ibase.webitm.ejb.ValidatorLocal;
@Local
public interface SodRiskEJBLocal extends ValidatorLocal {
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String editFlag,
String xtraParams) throws RemoteException ;
}
package ibase.webitm.ejb.SOD;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import ibase.webitm.ejb.ValidatorRemote;
@Remote
public interface SodRiskEJBRemote extends ValidatorRemote{
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String editFlag,
String xtraParams) throws RemoteException ;
}
This diff is collapsed.
package ibase.webitm.ejb.SOD;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Local
public interface SodRuleEJBLocal extends ValidatorLocal {
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String editFlag,
String xtraParams) throws RemoteException;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException;
}
package ibase.webitm.ejb.SOD;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface SodRuleEJBRemote extends ValidatorRemote{
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String editFlag,
String xtraParams) throws RemoteException ;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,
String allFrmXmlStr, String objContext, String currentColumn,
String editFlag, String xtraParams) 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