Commit 50431ab7 authored by arawankar's avatar arawankar

Version created from ibase3-webitm-fin5-11-0-30-1


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191732 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 48290e35
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class UserSiteIC extends ValidatorEJB implements UserSiteRemote,UserSiteLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
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);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println("errString---["+errString+"]");
}
catch(Exception e)
{
System.out.println("Exception from wfValData--["+ e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
int currentFormNo = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr=0;
int childNodeListLength = 0;
int count = 0;
String loginUserId = "";
String childNodeName = "";
String userId = "";
String errcode = "";
String errType = "";
String errString = "";
String siteCode = "";
String profileId = "";
java.util.Vector profileIdVec = new java.util.Vector();
String profileName = "";
String traceInfo = "";
Connection conn = null;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
E12GenericUtility genericUtility = null;
ITMDBAccessEJB itmDbAccessEjb = null;
StringTokenizer st = null;
try
{
conn = getConnection();
genericUtility = new E12GenericUtility();
itmDbAccessEjb = new ITMDBAccessEJB();
loginUserId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("currentFormNo--["+currentFormNo+"]");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("user_id"))
{
userId = checkNull(genericUtility.getColumnValue("user_id", dom));
if(userId == null || userId.trim().length() == 0)
{
errcode = "VMUSER1";
errString = itmDbAccessEjb.getErrorString("user_id", errcode, loginUserId,"",conn);
errType = getErrorType(errcode, conn);
if("E".equalsIgnoreCase(errType))
{
break;
}
}
else
{
sql = "select count(*) as cnt from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
// if the user ID does not exist in the 'users' master
errcode = "VMUSER2";
errString = itmDbAccessEjb.getErrorString("user_id", errcode, loginUserId,"",conn);
errType = getErrorType(errcode, conn);
if("E".equalsIgnoreCase(errType))
{
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
if(siteCode == null || siteCode.trim().length() == 0)
{
errcode = "VMSITE1";
errString = itmDbAccessEjb.getErrorString("siteCode", errcode, loginUserId,"",conn);
errType = getErrorType(errcode, conn);
if("E".equalsIgnoreCase(errType))
{
break;
}
}
else
{
sql = "select count(*) as cnt from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
errcode = "VMSITE1";
errString = itmDbAccessEjb.getErrorString("user_id", errcode, loginUserId,"",conn);
errType = getErrorType(errcode, conn);
if("E".equalsIgnoreCase(errType))
{
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("profile_id"))
{
profileId = checkNull(genericUtility.getColumnValue("profile_id", dom));
if( profileId != null && profileId.trim().length() > 0 )
{
System.out.println("profileId---["+profileId+"]");
st = new StringTokenizer( profileId, "," );
profileIdVec.clear();
while ( st.hasMoreTokens() )
{
profileIdVec.add( st.nextToken() );
}
System.out.println("profileIdVec============["+profileIdVec+"]");
if( profileIdVec.size() != 0 )
{
System.out.println("SQL Input=!=0========"+profileIdVec.size());
sql = "select count(*) as cnt from profile where profile_id = ?";
pstmt = conn.prepareStatement(sql);
for(int i=0; i < profileIdVec.size(); i++)
{
profileName = (String)profileIdVec.get( i );
pstmt.setString(1, profileName);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
pstmt.clearParameters();
if(count == 0)
{
errcode = "VTINVPROFL";
errString = itmDbAccessEjb.getErrorString("profile_id", errcode, loginUserId,"",conn);
traceInfo = "Profile Id ["+profileName+"] not exist in master.";
errString = setTraceInfo(errString, traceInfo);
errType = getErrorType(errcode, conn);
if("E".equalsIgnoreCase(errType))
{
break;
}
}
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
}
}
}
}
}
catch(Exception e)
{
System.out.println("Exception from wfValData---["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception from wfValData---["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
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 = "";
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);
}
System.out.println("xmlString--["+xmlString+"]\n xmlString1--["+xmlString1+"]\n xmlString2---["+xmlString2+"]");
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [UserSiteIC][itemChanged(String,String)] :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Connection conn = null;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
int ctr=0;
int childNodeListLength = 0;
int count = 0;
int currentFormNo = 0;
String userId = "";
String userName = "";
String siteCode = "";
String siteDescription = "";
StringBuffer valueXmlString = null;
E12GenericUtility genericUtility = null;
try
{
conn = getConnection();
genericUtility = new E12GenericUtility();
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("FORM NO:::" + currentFormNo);
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();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
} while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println("CURRENT COLUMN [" + currentColumn + "]");
if(currentColumn.equalsIgnoreCase("user_id"))
{
userId = checkNull(genericUtility.getColumnValue("user_id", dom));
System.out.println("userId--["+userId+"]");
sql = "select name as user_name from users where code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
userName = checkNull(rs.getString("user_name"));
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<users_name>").append("<![CDATA[" + userName + "]]>").append("</users_name>");
}
else if(currentColumn.equalsIgnoreCase("site_code"))
{
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select descr as site_descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescription = checkNull(rs.getString("site_descr"));
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescription + "]]>").append("</site_descr>");
}
valueXmlString.append("</Detail1 >");
System.out.println("itemchange string :::" +valueXmlString);
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
System.out.println("Exception : [UserSiteIC][itemChanged(dom,dom1)] :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception from itemchange---["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
private String getErrorType(String errorCode , Connection conn) throws RemoteException, ITMException
{
String errorType = "";
String sqlStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sqlStr = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next())
{
errorType = checkNull(rs.getString("MSG_TYPE"));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(errorType == null || errorType.trim().length() == 0)
{
errorType = "E";
}
}
catch (Exception e)
{
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception get error type component--["+e1.getMessage()+"]");
throw new ITMException(e1);
}
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e1)
{
e1.printStackTrace();
throw new ITMException(e1);
}
}
return errorType;
}
public String setTraceInfo(String errorMessage,String traceInfo)throws ITMException
{
E12GenericUtility genericUtility = null;
Document dom = null;
String errorStringChanged = "";
try
{
genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(errorMessage);
setNodeValue(dom,"trace",traceInfo);
errorStringChanged = genericUtility.serializeDom(dom);
System.out.println("errorStringChanged---["+errorStringChanged+"]");
}
catch(Exception e)
{
System.out.println("Exception in setTraceInfo---["+ e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return errorStringChanged;
}
private void setNodeValue(Document dom, String nodeName,String nodeVal) throws Exception
{
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null)
{
if (tempNode.getFirstChild() == null)
{
CDATASection cDataSection = dom.createCDATASection(nodeVal);
tempNode.appendChild(cDataSection);
}
else
{
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
}
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface UserSiteLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface UserSiteRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
---ADDED BY ANJALI R. ON[08/10/2018][START]----
SET DEFINE OFF;
update SYSTEM_EVENTS set SERVICE_CODE = 'poic_default_ejb',COMP_TYPE = 'JB',COMP_NAME ='ibase.webitm.ejb.sys.UserSiteIC' where OBJ_NAME ='user_site' and EVENT_CODE = 'post_item_change';
UPDATE system_events SET SERVICE_CODE = 'prv_default_ejb',COMP_TYPE = 'JB',COMP_NAME = 'ibase.webitm.ejb.sys.UserSiteIC' WHERE obj_name ='user_site' AND EVENT_CODE = 'pre_validate';
COMMIT;
insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION)
values ('VTINVPROFL','Invalid Profile id.','The profile id entered does not exist in the profile master. First you have to define it in the master','E','Y',null,null,null,SYSDATE,'BASE','BASE',null,null);
insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION)
values ('VMSITE1','Invalid site code.','The site code entered does not exist in the site master. First you have to define it in the master','E','Y',null,null,null,to_date('24-05-01','DD-MM-RR'),'SUN ','NITIN ',null,null);
insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION)
values ('VMUSER2','User not found in User master','User not found in User master.','E','Y',null,null,null,TO_DATE('27-04-06','DD-MM-RR'),'BASE ','BASE ',null,null);
insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,ERR_SOURCE,CHG_DATE,CHG_USER,CHG_TERM,OVERRIDE_INPUT,MAIL_OPTION)
values ('VMUSER1','BLANK USER ID','Please enter user id.','E','Y',null,null,null,TO_DATE('27-04-06','DD-MM-RR'),'BASE ','BASE ',null,null);
COMMIT;
---ADDED BY ANJALI R. ON[08/10/2018][END]----
\ 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