first commit

This commit is contained in:
2025-07-28 13:56:49 +05:30
commit e9eb805edb
3438 changed files with 520990 additions and 0 deletions

View File

@@ -0,0 +1,295 @@
package wenrgise.ejb.common.business;
import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.UserInfo;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.session.UserSession;
import wenrgise.ejb.common.session.UserSessionHome;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.ejb.common.utility.ServiceLocator;
public abstract class BaseBO {
public static Logger log = Logger.getLogger("wenrgise.ejb.common.business.BaseBO");
protected String headerTable = null;
private String headerPKColumnName = null;
private String detailTable = null;
private String detailPKColumnName = null;
protected DateFormat userDateFormat;
protected DateFormat defaultDateFormat;
protected Locale userLocale;
protected Locale defaultLocale;
protected UserInfo oUserInfo;
public BaseBO() {}
public BaseBO(UserInfo oUserInfo) {
this.oUserInfo = oUserInfo;
}
private void setDateFormatAndLocale() throws EnrgiseSystemException {
this.userDateFormat = new SimpleDateFormat("dd/MM/yyyy");
this.defaultDateFormat = new SimpleDateFormat("dd/MM/yyyy");
try {
UserSessionHome oHome = (UserSessionHome)ServiceLocator.getLocator().getService("UserSession");
UserSession oUser = oHome.create();
this.userDateFormat = oUser.getUserDateFormat();
this.defaultDateFormat = oUser.getDefaultDateFormat();
this.userLocale = oUser.getUserLocale();
this.defaultLocale = oUser.getDefaultLocale();
this.oUserInfo = oUser.getUserInfo();
} catch (RemoteException oEx) {
log.severe(oEx.getMessage());
throw new EnrgiseSystemException();
} catch (CreateException oCrt) {
log.severe(oCrt.getMessage());
throw new EnrgiseSystemException();
}
}
public String saveData(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
String sScreenHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
String sHeaderPrimaryKey = sScreenHeaderPrimaryKey;
if (sScreenMode.equals("U"))
initializeBOImpl();
if (sScreenMode.equals("U"))
if (bHeaderDataChanged || bDetailDataChanged)
if (oWhenPicked != null) {
if (!checkHeaderTimeStamp(oBaseHeaderBean.getHeaderPrimaryKey(), oDetailPicked))
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
} else if (!checkHeaderTimeStamp(null, oDetailPicked)) {
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
}
additionalFieldValidationImpl(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked);
additionalTimestampValidationImpl(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked);
additionalBusinessValidationImpl(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked);
if (bHeaderDataChanged) {
sHeaderPrimaryKey = saveHeaderImpl(oBaseHeaderBean, sScreenMode);
if (sHeaderPrimaryKey == null && !sScreenMode.equalsIgnoreCase("D"))
sHeaderPrimaryKey = sScreenHeaderPrimaryKey;
}
if (bDetailDataChanged && !sScreenMode.equalsIgnoreCase("D"))
if (oBaseHeaderBean == null) {
saveDetailImpl(sHeaderPrimaryKey, sScreenName, oDetailBeanArray);
if (oWhenPicked != null)
updateHeaderTimeStamp(sHeaderPrimaryKey);
} else if (!EnrgiseUtil.checkString(oBaseHeaderBean.getPseudoHeader())) {
saveDetailImpl(sHeaderPrimaryKey, sScreenName, oDetailBeanArray);
if (oWhenPicked != null)
updateHeaderTimeStamp(sHeaderPrimaryKey);
} else {
saveDetailImpl(oBaseHeaderBean, sScreenName, oDetailBeanArray);
}
return sHeaderPrimaryKey;
}
private boolean updateHeaderTimeStamp(String sPrimaryKey) throws EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, this.headerTable));
oParameters.add(new DBObject(2, 1, 12, sPrimaryKey));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "COMMONPROCEDURES.proc_UpdateHeaderTimeStamp(?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
String sSuccessFlag = (String)oOutObject.getObject();
if (!sSuccessFlag.trim().equals("Y"))
return false;
return true;
}
public void initializeBO(String sHeaderTable, String sDetailTable) {
this.headerTable = sHeaderTable;
}
public void initializeBO(String sHeaderTable) {
this.headerTable = sHeaderTable;
}
private boolean checkHeaderTimeStamp(String sPrimaryKey, Timestamp oWhenPicked) throws EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, this.headerTable));
oParameters.add(new DBObject(2, 1, 12, sPrimaryKey));
oParameters.add(new DBObject(3, 1, 93, oWhenPicked));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 12));
oParameters.add(new DBObject(7, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "COMMONPROCEDURES.proc_CheckHeaderTimeStamp(?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
String sSuccessFlag = (String)oOutObject.getObject();
if (!sSuccessFlag.trim().equals("Y"))
return false;
return true;
}
private boolean checkDetailTimeStamp(String sPrimaryKey, Timestamp oWhenDetailPicked) throws EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, this.headerTable));
oParameters.add(new DBObject(2, 1, 12, this.detailTable));
oParameters.add(new DBObject(3, 1, 12, sPrimaryKey));
oParameters.add(new DBObject(4, 1, 93, oWhenDetailPicked));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 12));
oParameters.add(new DBObject(7, 2, 12));
oParameters.add(new DBObject(8, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "COMMONPROCEDURES.proc_CheckDetailTimeStamp(?,?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
String sSuccessFlag = (String)oOutObject.getObject();
if (!sSuccessFlag.trim().equals("Y"))
return false;
return true;
}
public void reportError(ArrayList oList) throws EnrgiseSystemException, EnrgiseApplicationException {
if (oList.size() > 0) {
boolean bFirstTime = true;
EnrgiseApplicationException oApp = null;
EnrgiseSystemException oSys = null;
Object obj = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
obj = oIt.next();
if (obj instanceof EnrgiseApplicationException || obj instanceof EnrgiseMessageKeyException) {
if (!bFirstTime) {
oApp.addToList((EnrgiseApplicationException)obj);
continue;
}
bFirstTime = false;
oApp = (EnrgiseApplicationException)obj;
continue;
}
oSys = (EnrgiseSystemException)obj;
throw oSys;
}
throw oApp;
}
}
public abstract String saveHeaderImpl(BaseHeaderBean paramBaseHeaderBean, String paramString) throws EnrgiseMessageKeyException, EnrgiseApplicationException, EnrgiseSystemException;
public abstract void saveDetailImpl(String paramString1, String paramString2, ArrayList paramArrayList) throws EnrgiseApplicationException, EnrgiseSystemException;
public void saveDetailImpl(BaseHeaderBean oBaseHeaderBean, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {}
public abstract void initializeBOImpl();
public abstract void additionalFieldValidationImpl(BaseHeaderBean paramBaseHeaderBean, Timestamp paramTimestamp1, String paramString1, String paramString2, boolean paramBoolean1, ArrayList paramArrayList, boolean paramBoolean2, Timestamp paramTimestamp2) throws EnrgiseApplicationException, EnrgiseSystemException;
public abstract void additionalTimestampValidationImpl(BaseHeaderBean paramBaseHeaderBean, Timestamp paramTimestamp1, String paramString1, String paramString2, boolean paramBoolean1, ArrayList paramArrayList, boolean paramBoolean2, Timestamp paramTimestamp2) throws EnrgiseApplicationException, EnrgiseSystemException;
public abstract void additionalBusinessValidationImpl(BaseHeaderBean paramBaseHeaderBean, Timestamp paramTimestamp1, String paramString1, String paramString2, boolean paramBoolean1, ArrayList paramArrayList, boolean paramBoolean2, Timestamp paramTimestamp2) throws EnrgiseApplicationException, EnrgiseSystemException;
public UserInfo getOUserInfo() {
return this.oUserInfo;
}
public void setOUserInfo(UserInfo newOUserInfo) {
this.oUserInfo = newOUserInfo;
}
public String approve(String sTableName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, ArrayList oDetailBeanArray, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
initializeBOImpl();
if (sHeaderPrimaryKey != null) {
if (oWhenPicked != null &&
!checkHeaderTimeStamp(sHeaderPrimaryKey, oWhenPicked))
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
validateApprove(sHeaderPrimaryKey);
if (EnrgiseUtil.checkString(sTableName)) {
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("update ").concat(String.valueOf(sTableName))).concat(String.valueOf(" set status_flag='"))).concat(String.valueOf("A"))).concat(String.valueOf("',modified_site_id = 100, user_id_modified = 100, modified_time_stamp = sysdate where id="))).concat(String.valueOf(sHeaderPrimaryKey));
int i = oBean.executeUpsert(sQuery);
}
} else {
throw new EnrgiseApplicationException("wenrgise.common.norecordfound", "M");
}
return sHeaderPrimaryKey;
}
public String callWorkFlow(BaseHeaderBean oBaseHeaderBean, ArrayList arylstDetailBeanArray, String activity) throws EnrgiseApplicationException, EnrgiseSystemException {
if (activity.equals("A"))
return "FinallyApproved";
if (activity.equals("R"))
return "R";
return "success";
}
public void validateApprove(String sHeaderPrimaryKey) {}
public void validateReject(String sHeaderPrimaryKey) {}
public void validateRevise(String sHeaderPrimaryKey) {}
public String submit(String sTableName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, ArrayList oDetailBeanArray, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
initializeBOImpl();
if (sHeaderPrimaryKey != null)
if (oWhenPicked != null)
if (!checkHeaderTimeStamp(sHeaderPrimaryKey, oWhenPicked))
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
return oBaseHeaderBean.getHeaderPrimaryKey();
}
public String reject(String sTableName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, ArrayList oDetailBeanArray, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
if (sHeaderPrimaryKey != null) {
initializeBOImpl();
if (!checkHeaderTimeStamp(sHeaderPrimaryKey, oWhenPicked))
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
validateReject(sHeaderPrimaryKey);
if (EnrgiseUtil.checkString(sTableName)) {
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("update ").concat(String.valueOf(sTableName))).concat(String.valueOf(" set status_flag='"))).concat(String.valueOf("R"))).concat(String.valueOf("',modified_site_id = 100, user_id_modified = 100, modified_time_stamp = sysdate where id="))).concat(String.valueOf(sHeaderPrimaryKey));
int i = oBean.executeUpsert(sQuery);
}
} else {
throw new EnrgiseApplicationException("wenrgise.common.norecordfound", "M");
}
return sHeaderPrimaryKey;
}
public String revise(String sTableName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, ArrayList oDetailBeanArray, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
if (sHeaderPrimaryKey != null) {
initializeBOImpl();
if (!checkHeaderTimeStamp(sHeaderPrimaryKey, oWhenPicked))
throw new EnrgiseApplicationException("wenrgise.common.changed", "M");
validateRevise(sHeaderPrimaryKey);
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("update ").concat(String.valueOf(sTableName))).concat(String.valueOf(" sTablename set sTablename.status_flag = '"))).concat(String.valueOf("V"))).concat(String.valueOf("', sTablename.rev_no=sTablename.rev_no+1,sTablename.modified_site_id = 200, sTablename.user_id_modified = 200, sTablename.modified_time_stamp = sysdate where sTablename.code in (select code from "))).concat(String.valueOf(sTableName))).concat(String.valueOf(" where id="))).concat(String.valueOf(sHeaderPrimaryKey))).concat(String.valueOf(")"));
int i = oBean.executeUpsert(sQuery);
} else {
throw new EnrgiseApplicationException("wenrgise.common.norecordfound", "M");
}
return sHeaderPrimaryKey;
}
}

View File

@@ -0,0 +1,365 @@
package wenrgise.ejb.common.business;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.bean.AccessBean;
import wenrgise.common.bean.DynamicMenuBean;
import wenrgise.common.bean.EmpInfoBean;
import wenrgise.common.bean.MenuBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
public class SecurityBO {
public HashMap getDisabledFields(String sScreenName, String sHdrDtlFlag, String sScreenMode, String sPageStatus) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
Timestamp oWhenPicked = null;
int count = 0;
BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
HashMap oMap = new HashMap();
if (sHdrDtlFlag.equalsIgnoreCase("Header")) {
oParameters.add(new DBObject(1, 1, 12, sScreenName));
oParameters.add(new DBObject(2, 1, 12, sHdrDtlFlag));
oParameters.add(new DBObject(3, 1, 12, sScreenMode));
oParameters.add(new DBObject(4, 1, 12, sPageStatus));
oParameters.add(new DBObject(5, 1, 12, "D"));
oParameters.add(new DBObject(6, 2, -10));
oParameters.add(new DBObject(7, 2, 12));
oParameters.add(new DBObject(8, 2, 12));
oParameters.add(new DBObject(9, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "commonprocedures.proc_getfielddisableinfo(?,?,?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
ArrayList arylstFields = new ArrayList();
while (oIt.hasNext()) {
oRow = oIt.next();
arylstFields.add(oRow.get("disabled_field").getString());
}
oMap.put("D", arylstFields);
}
} else if (sHdrDtlFlag.equalsIgnoreCase("Detail")) {
oParameters.add(new DBObject(1, 1, 12, sScreenName));
oParameters.add(new DBObject(2, 1, 12, sHdrDtlFlag));
oParameters.add(new DBObject(3, 1, 12, sScreenMode));
oParameters.add(new DBObject(4, 1, 12, sPageStatus));
oParameters.add(new DBObject(5, 1, 12, "D"));
oParameters.add(new DBObject(6, 2, -10));
oParameters.add(new DBObject(7, 2, 12));
oParameters.add(new DBObject(8, 2, 12));
oParameters.add(new DBObject(9, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "commonprocedures.proc_getfielddisableinfo(?,?,?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
ArrayList disableList = new ArrayList();
while (oIt.hasNext()) {
oRow = oIt.next();
disableList.add(oRow.get("disabled_field").getString());
}
oMap.put("D", disableList);
}
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sScreenName));
oParameters.add(new DBObject(2, 1, 12, sHdrDtlFlag));
oParameters.add(new DBObject(3, 1, 12, sScreenMode));
oParameters.add(new DBObject(4, 1, 12, sPageStatus));
oParameters.add(new DBObject(5, 1, 12, "E"));
oParameters.add(new DBObject(6, 2, -10));
oParameters.add(new DBObject(7, 2, 12));
oParameters.add(new DBObject(8, 2, 12));
oParameters.add(new DBObject(9, 2, 4));
oOutArray = oBean.callProc(oParameters, "commonprocedures.proc_getfielddisableinfo(?,?,?,?,?,?,?,?,?)");
oOutObject = oOutArray.get(0);
oList = (ArrayList)oOutObject.getObject();
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
ArrayList enableList = new ArrayList();
while (oIt.hasNext()) {
oRow = oIt.next();
enableList.add(oRow.get("disabled_field").getString());
}
oMap.put("E", enableList);
}
} else if (sHdrDtlFlag.equalsIgnoreCase("all")) {
oParameters.add(new DBObject(1, 1, 12, sScreenName));
oParameters.add(new DBObject(2, 1, 12, sHdrDtlFlag));
oParameters.add(new DBObject(3, 1, 12, sScreenMode));
oParameters.add(new DBObject(4, 1, 12, sPageStatus));
oParameters.add(new DBObject(5, 1, 12, "D"));
oParameters.add(new DBObject(6, 2, -10));
oParameters.add(new DBObject(7, 2, 12));
oParameters.add(new DBObject(8, 2, 12));
oParameters.add(new DBObject(9, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "commonprocedures.proc_getfielddisableinfo(?,?,?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
ArrayList arylstFields = new ArrayList();
while (oIt.hasNext()) {
oRow = oIt.next();
arylstFields.add(oRow.get("disabled_field").getString());
}
oMap.put("D", arylstFields);
}
}
return oMap;
}
private String getGroupIdForUser(String sUserId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
ArrayList oList = null;
String sGroupId = null;
DBUtilitiesBean oBean = new DBUtilitiesBean();
boolean returnFlag = true;
boolean tempFlag = true;
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sUserId));
oParameters.add(new DBObject(2, 2, 12));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "DYNAMIC_MENU.PROC_GetGroupId(?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
sGroupId = (String)oOutObject.getObject();
return sGroupId;
}
public ArrayList addMenuList(EmpInfoBean oEmpInfoBean) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList menuList = new ArrayList();
ArrayList finalList = new ArrayList();
MenuBean oMenuBean = new MenuBean();
oEmpInfoBean = getGroupId(oEmpInfoBean);
oMenuBean = getComponentIds(oEmpInfoBean, menuList);
Iterator oIt = menuList.iterator();
while (oIt.hasNext()) {
DynamicMenuBean dynamicMenuBean = oIt.next();
finalList.add(new DynamicMenuBean(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("MyMenu.makeMenu('").concat(String.valueOf(dynamicMenuBean.getCompId()))).concat(String.valueOf("','"))).concat(String.valueOf(dynamicMenuBean.getModuleId()))).concat(String.valueOf("','"))).concat(String.valueOf(dynamicMenuBean.getCompDesc()))).concat(String.valueOf("','"))).concat(String.valueOf(dynamicMenuBean.getActionName()))).concat(String.valueOf("?screenName="))).concat(String.valueOf(dynamicMenuBean.getScreenName()))).concat(String.valueOf("')"))));
}
if (oMenuBean.getModuleId() == null)
return null;
DynamicMenuBean oBean = new DynamicMenuBean();
do {
oMenuBean = getModuleIds(oMenuBean, oBean, menuList);
Iterator oIt1 = menuList.iterator();
while (oIt1.hasNext()) {
oBean = oIt1.next();
if (oBean.getModuleId() == oEmpInfoBean.getModuleId())
continue;
finalList.add(new DynamicMenuBean(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("MyMenu.makeMenu('").concat(String.valueOf(oBean.getModuleId()))).concat(String.valueOf("','"))).concat(String.valueOf(oBean.getParentModuleId()))).concat(String.valueOf("','"))).concat(String.valueOf(oBean.getModuleDesc()))).concat(String.valueOf("')"))));
}
} while (oMenuBean != null);
return finalList;
}
public EmpInfoBean getGroupId(EmpInfoBean oEmpInfoBean) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, oEmpInfoBean.getEmpId()));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "DYNAMIC_MENU.PROC_GetGroupId(?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
int count = 0;
QueryRow oRow = null;
HashMap oColumns = null;
Iterator oIt = oList.iterator();
StringBuffer concatList = new StringBuffer();
int c = 0;
while (oIt.hasNext()) {
if (count == 0)
oList = new ArrayList();
count++;
oRow = oIt.next();
oEmpInfoBean.setGrpId(oRow.get("GROUP_ID").getString());
if (c == 0) {
concatList = concatList.append(oEmpInfoBean.getGrpId());
c++;
continue;
}
concatList = concatList.append(String.valueOf(",").concat(String.valueOf(oEmpInfoBean.getGrpId())));
}
String sGrpIds = null;
if (c != 0)
sGrpIds = concatList.toString();
oEmpInfoBean.setGrpId(sGrpIds);
return oEmpInfoBean;
}
public MenuBean getModuleIds(MenuBean oBean, DynamicMenuBean oMenuBean, ArrayList oMenuList) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oDBBean = new DBUtilitiesBean();
oMenuList.clear();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, oBean.getModuleId()));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oDBBean.callProc(oParameters, "DYNAMIC_MENU.PROC_ModuleInfo(?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
if (oList.size() == 0)
return null;
int count = 0;
QueryRow oRow = null;
HashMap oColumns = null;
Iterator oIt = oList.iterator();
StringBuffer concatList = new StringBuffer();
int c = 0;
while (oIt.hasNext()) {
oMenuBean = new DynamicMenuBean();
if (count == 0)
oList = new ArrayList();
count++;
oRow = oIt.next();
oMenuBean.setModuleId(oRow.get("module_id").getString());
oMenuBean.setParentModuleId(oRow.get("parent_module_id").getString());
oMenuBean.setModuleCode(oRow.get("module_code").getString());
oMenuBean.setModuleDesc(oRow.get("module_description").getString());
oMenuBean.setHierchyLevel(oRow.get("hierarchy_lvl").getString());
oMenuList.add(oMenuBean);
if (c == 0) {
concatList = concatList.append(oMenuBean.getModuleId());
c++;
continue;
}
concatList = concatList.append(String.valueOf(",").concat(String.valueOf(oMenuBean.getModuleId())));
}
String sModuleId = null;
if (c != 0)
sModuleId = concatList.toString();
oBean.setModuleId(sModuleId);
return oBean;
}
public MenuBean getComponentIds(EmpInfoBean oEmpInfoBean, ArrayList oMenuList) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, oEmpInfoBean.getEmpId()));
oParameters.add(new DBObject(2, 1, 12, oEmpInfoBean.getGrpId()));
oParameters.add(new DBObject(3, 1, 12, oEmpInfoBean.getModuleId()));
oParameters.add(new DBObject(4, 2, -10));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 12));
oParameters.add(new DBObject(7, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "DYNAMIC_MENU.PROC_GetCompInfo(?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
int count = 0;
QueryRow oRow = null;
HashMap oColumns = null;
Iterator oIt = oList.iterator();
StringBuffer concatList = new StringBuffer();
int c = 0;
while (oIt.hasNext()) {
DynamicMenuBean oMenuBean = new DynamicMenuBean();
if (count == 0)
oList = new ArrayList();
count++;
oRow = oIt.next();
oMenuBean.setCompId(oRow.get("component_id").getString());
oMenuBean.setCompCode(oRow.get("component_code").getString());
oMenuBean.setCompDesc(oRow.get("description").getString());
oMenuBean.setActionName(oRow.get("action_name").getString());
oMenuBean.setScreenName(oRow.get("screen_name").getString());
oMenuBean.setModuleId(oRow.get("module_id").getString());
oMenuList.add(oMenuBean);
if (c == 0) {
concatList = concatList.append(oMenuBean.getCompId());
c++;
continue;
}
concatList = concatList.append(String.valueOf(",").concat(String.valueOf(oMenuBean.getCompId())));
}
String sCompId = null;
if (c != 0)
sCompId = concatList.toString();
MenuBean oBean1 = new MenuBean();
oBean1.setModuleId(sCompId);
return oBean1;
}
public HashMap getAccessInfo(EmpInfoBean oEmpInfoBean) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
HashMap mapInfo = new HashMap();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, oEmpInfoBean.getEmpId()));
oParameters.add(new DBObject(2, 1, 12, "null"));
oParameters.add(new DBObject(3, 1, 12, oEmpInfoBean.getModuleId()));
oParameters.add(new DBObject(4, 2, -10));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 12));
oParameters.add(new DBObject(7, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "DYNAMIC_MENU.PROC_GetCompInfo(?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
QueryRow oRow = null;
HashMap oColumns = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
String sComponentName = oRow.get("Component_Code").getString();
AccessBean oAccessBean = new AccessBean();
oAccessBean.setApproveFlag(oRow.get("APPROVFLAG").getString());
oAccessBean.setDeleteFlag(oRow.get("DELFLAG").getString());
oAccessBean.setInsertFlag(oRow.get("INSERTFLAG").getString());
oAccessBean.setQueryFlag(oRow.get("QRYFLAG").getString());
oAccessBean.setUpdateFlag(oRow.get("UPDATEFLAG").getString());
mapInfo.put(sComponentName.trim(), oAccessBean);
}
oEmpInfoBean = getGroupId(oEmpInfoBean);
HashMap oHshMap = getAccessInfoFromGroup(oEmpInfoBean, mapInfo);
return oHshMap;
}
private HashMap getAccessInfoFromGroup(EmpInfoBean oEmpInfoBean, HashMap oMap) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, null));
oParameters.add(new DBObject(2, 1, 12, oEmpInfoBean.getGrpId()));
oParameters.add(new DBObject(3, 1, 12, oEmpInfoBean.getModuleId()));
oParameters.add(new DBObject(4, 2, -10));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 12));
oParameters.add(new DBObject(7, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "DYNAMIC_MENU.PROC_GetCompInfo(?,?,?,?,?,?,?)");
DBObject oOutObject = oOutArray.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
QueryRow oRow = null;
HashMap oColumns = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
String sComponentName = oRow.get("Component_Code").getString();
AccessBean oAccessBean = new AccessBean();
oAccessBean.setApproveFlag(oRow.get("APPROVFLAG").getString());
oAccessBean.setDeleteFlag(oRow.get("DELFLAG").getString());
oAccessBean.setInsertFlag(oRow.get("INSERTFLAG").getString());
oAccessBean.setQueryFlag(oRow.get("QRYFLAG").getString());
oAccessBean.setUpdateFlag(oRow.get("UPDATEFLAG").getString());
oMap.put(sComponentName.trim(), oAccessBean);
}
return oMap;
}
}

View File

@@ -0,0 +1,5 @@
package wenrgise.ejb.common.facade;
import javax.ejb.EJBObject;
public interface CommonFacade extends EJBObject {}

View File

@@ -0,0 +1,16 @@
package wenrgise.ejb.common.facade;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class CommonFacadeBean implements SessionBean {
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext ctx) {}
}

View File

@@ -0,0 +1,9 @@
package wenrgise.ejb.common.facade;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface CommonFacadeHome extends EJBHome {
CommonFacade create() throws CreateException, RemoteException;
}

View File

@@ -0,0 +1,17 @@
package wenrgise.ejb.common.facade;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.ejb.EJBObject;
import wenrgise.common.bean.EmpInfoBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
public interface SecurityFacade extends EJBObject {
HashMap getDisabledFields(String paramString1, String paramString2, String paramString3, String paramString4) throws RemoteException, EnrgiseSystemException, EnrgiseApplicationException;
ArrayList addMenuList(EmpInfoBean paramEmpInfoBean) throws RemoteException, EnrgiseSystemException, EnrgiseApplicationException;
HashMap getAccessInfo(EmpInfoBean paramEmpInfoBean) throws RemoteException, EnrgiseSystemException, EnrgiseApplicationException;
}

View File

@@ -0,0 +1,41 @@
package wenrgise.ejb.common.facade;
import java.util.ArrayList;
import java.util.HashMap;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import wenrgise.common.bean.EmpInfoBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.business.SecurityBO;
public class SecurityFacadeBean implements SessionBean {
SessionContext ctx;
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
}
public HashMap getDisabledFields(String sScreenName, String sHdrDtlFlag, String sSreenMode, String sPageStatus) throws EnrgiseSystemException, EnrgiseApplicationException {
SecurityBO oSectBO = new SecurityBO();
return oSectBO.getDisabledFields(sScreenName, sHdrDtlFlag, sSreenMode, sPageStatus);
}
public ArrayList addMenuList(EmpInfoBean oEmpInfoBean) throws EnrgiseSystemException, EnrgiseApplicationException {
SecurityBO oSectBO = new SecurityBO();
return oSectBO.addMenuList(oEmpInfoBean);
}
public HashMap getAccessInfo(EmpInfoBean oEmpInfoBean) throws EnrgiseSystemException, EnrgiseApplicationException {
SecurityBO oSectBO = new SecurityBO();
return oSectBO.getAccessInfo(oEmpInfoBean);
}
}

View File

@@ -0,0 +1,9 @@
package wenrgise.ejb.common.facade;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface SecurityFacadeHome extends EJBHome {
SecurityFacade create() throws CreateException, RemoteException;
}

View File

@@ -0,0 +1,37 @@
package wenrgise.ejb.common.helper;
import java.io.Serializable;
public class DBObject extends InputDBObject implements Serializable {
private int iInputOutput;
public static final int IN = 1;
public static final int OUT = 2;
public static final int INOUT = 3;
public DBObject() {}
public DBObject(int iPosition, int iDataType) {
this.iPosition = iPosition;
this.iDataType = iDataType;
}
public DBObject(int iPosition, int iInputOutput, int iDataType) {
this.iPosition = iPosition;
this.iInputOutput = iInputOutput;
this.iDataType = iDataType;
}
public DBObject(int iPosition, int iInputOutput, int iDataType, Object oValue) {
this.iPosition = iPosition;
this.iInputOutput = iInputOutput;
this.iDataType = iDataType;
this.oValue = oValue;
}
public int getDirection() {
return this.iInputOutput;
}
}

View File

@@ -0,0 +1,43 @@
package wenrgise.ejb.common.helper;
import java.io.Serializable;
public class InputDBObject implements Serializable {
protected int iPosition;
protected int iDataType;
protected Object oValue;
public InputDBObject() {}
public InputDBObject(int iPosition, int iDataType, Object oValue) {
this.iPosition = iPosition;
this.iDataType = iDataType;
this.oValue = oValue;
}
public int getDataType() {
return this.iDataType;
}
public void setDataType(int newIDataType) {
this.iDataType = newIDataType;
}
public int getPosition() {
return this.iPosition;
}
public void setPosition(int newIPosition) {
this.iPosition = newIPosition;
}
public Object getObject() {
return this.oValue;
}
public void setObject(Object newOValue) {
this.oValue = newOValue;
}
}

View File

@@ -0,0 +1,7 @@
package wenrgise.ejb.common.helper;
import oracle.jdbc.driver.OracleTypes;
public class ParameterTypes extends OracleTypes {
int i = 3;
}

View File

@@ -0,0 +1,26 @@
package wenrgise.ejb.common.helper;
import java.io.Serializable;
import java.util.HashMap;
public class QueryRow implements Serializable {
private HashMap row = null;
public QueryRow(int iCapacity) {
this.row = new HashMap(iCapacity);
}
public HashMap getRow() {
return this.row;
}
public void setRow(HashMap newRow) {
this.row = newRow;
}
public QueryValue get(String sColumnName) {
if (this.row != null)
return (QueryValue)this.row.get(sColumnName.toUpperCase());
return null;
}
}

View File

@@ -0,0 +1,166 @@
package wenrgise.ejb.common.helper;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Date;
public class QueryValue implements Serializable {
private String stringValue = null;
private BigDecimal bigDecimalValue = BigDecimal.valueOf(0L);
private short shortValue = 0;
private int intValue = 0;
private long longValue = 0L;
private float floatValue = 0.0F;
private double doubleValue = 0.0D;
private Date dateValue = null;
private Blob blobValue = null;
private Clob clobValue = null;
public void setString(String value) {
this.stringValue = value;
}
public String getString() {
return this.stringValue;
}
public void setBigDecimal(BigDecimal value) {
this.bigDecimalValue = value;
this.stringValue = (null != value) ? value.toString() : null;
}
public BigDecimal getBigDecimal() {
return this.bigDecimalValue;
}
public void setShort(short value) {
this.shortValue = value;
Short shrt = new Short(value);
this.stringValue = (null != shrt) ? shrt.toString() : null;
}
public short getShort() {
return this.shortValue;
}
public void setInt(int value) {
this.intValue = value;
Integer iValue = new Integer(value);
this.stringValue = (null != iValue) ? iValue.toString() : null;
}
public int getInt() {
return this.intValue;
}
public void setLong(long value) {
this.longValue = value;
Long lValue = new Long(value);
this.stringValue = (null != lValue) ? lValue.toString() : null;
}
public long getLong() {
return this.longValue;
}
public void setFloat(float value) {
this.floatValue = value;
Float fValue = new Float(value);
this.stringValue = (null != fValue) ? fValue.toString() : null;
}
public float getFloat() {
return this.floatValue;
}
public void setDouble(double value) {
this.doubleValue = value;
Double dValue = new Double(value);
this.stringValue = (null != dValue) ? dValue.toString() : null;
}
public double getDouble() {
return this.doubleValue;
}
public void setDate(Date value) {
this.dateValue = value;
this.stringValue = (null != value) ? value.toString() : null;
}
public void setDate(Date value) {
if (null == value) {
this.stringValue = null;
this.dateValue = null;
return;
}
this.dateValue = new Date(value.getTime());
this.stringValue = this.dateValue.toString();
}
public Date getDate() {
return this.dateValue;
}
public void setTime(Date value) {
setDate(value);
}
public void setTime(Time value) {
if (null == value) {
this.stringValue = null;
this.dateValue = null;
return;
}
this.dateValue = new Date(value.getTime());
this.stringValue = this.dateValue.toString();
}
public Date getTime() {
return this.dateValue;
}
public void setTimestamp(Timestamp value) {
if (null == value) {
this.stringValue = null;
this.dateValue = null;
return;
}
this.dateValue = new Date(value.getTime() + (value.getNanos() / 1000000));
this.stringValue = this.dateValue.toString();
}
public Date getTimestamp() {
return this.dateValue;
}
public void setBlob(Blob value) {
this.blobValue = value;
}
public Blob getBlob() {
return this.blobValue;
}
public void setClob(Clob value) {
this.clobValue = value;
}
public Clob getClob() {
return this.clobValue;
}
}

View File

@@ -0,0 +1,51 @@
package wenrgise.ejb.common.helper;
import java.util.HashMap;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.common.vo.BaseQueryVO;
public class ScreenWrapper {
private BaseHeaderVO oBaseHeaderVO = null;
private BaseQueryVO oBaseQueryVO = null;
private HashMap oScreenMap = null;
private String forwardedPage = null;
public ScreenWrapper() {
this.oScreenMap = new HashMap();
}
public BaseHeaderVO getOBaseHeaderVO() {
return this.oBaseHeaderVO;
}
public void setOBaseHeaderVO(BaseHeaderVO newOBaseHeaderVO) {
this.oBaseHeaderVO = newOBaseHeaderVO;
}
public BaseQueryVO getOBaseQueryVO() {
return this.oBaseQueryVO;
}
public void setOBaseQueryVO(BaseQueryVO newOBaseQueryVO) {
this.oBaseQueryVO = newOBaseQueryVO;
}
public HashMap getOScreenMap() {
return this.oScreenMap;
}
public void setOScreenMap(HashMap newOScreenMap) {
this.oScreenMap = newOScreenMap;
}
public String getForwardedPage() {
return this.forwardedPage;
}
public void setForwardedPage(String newForwardedPage) {
this.forwardedPage = newForwardedPage;
}
}

View File

@@ -0,0 +1,17 @@
package wenrgise.ejb.common.helper;
public class SysadminSql {
public static final String GetDate = "SELECT sysdate FROM dual";
public static final String GlobalCodeHeader = "SELECT * FROM aaa_myself";
public static final String GlobalCodeHeaderCount = "SELECT count(*) as counter FROM aaa_myself";
public static final String GlobalCodeHeaderName = "SELECT * FROM aaa_myself WHERE name = ?";
public static final String GlobalCodeHeaderNameCount = "SELECT count(*) as counter FROM aaa_myself WHERE name = ?";
public static final String GlobalCodeHeaderSex = "SELECT * FROM aaa_myself WHERE sex = ?";
public static final String GlobalCodeHeaderNameSex = "SELECT * FROM aaa_myself WHERE name = ? AND sex = ?";
}

View File

@@ -0,0 +1,59 @@
package wenrgise.ejb.common.session;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.util.HashMap;
import java.util.Locale;
import javax.ejb.EJBObject;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.BaseDetailVO;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.common.vo.BaseQueryVO;
public interface UserSession extends EJBObject {
void putBaseHeaderVO(String paramString, BaseHeaderVO paramBaseHeaderVO) throws RemoteException;
void removeAllIfExists(String paramString1, String paramString2) throws RemoteException;
void putBaseQueryVO(String paramString, BaseQueryVO paramBaseQueryVO) throws RemoteException;
void putBaseDetailVO(String paramString1, String paramString2, BaseDetailVO paramBaseDetailVO) throws RemoteException;
BaseHeaderVO getBaseHeaderVO(String paramString) throws RemoteException;
BaseQueryVO getBaseQueryVO(String paramString) throws RemoteException;
BaseDetailVO getBaseDetailVO(String paramString1, String paramString2) throws RemoteException;
UserInfo getUserInfo() throws RemoteException;
void setUserInfo(UserInfo paramUserInfo) throws RemoteException;
Locale getUserLocale() throws RemoteException;
void setUserLocale(Locale paramLocale) throws RemoteException;
Locale getDefaultLocale() throws RemoteException;
DateFormat getUserDateFormat() throws RemoteException;
DateFormat getDefaultDateFormat() throws RemoteException;
HashMap getModuleFacade() throws RemoteException;
void removeAllDetailVO(String paramString) throws RemoteException;
void setModuleFacade(HashMap paramHashMap) throws RemoteException;
void setModuleName(String paramString) throws RemoteException;
EJBObject getModuleEJBObject() throws RemoteException;
void setForwardedPage(String paramString1, String paramString2) throws RemoteException;
String getForwardedPage(String paramString) throws RemoteException;
HashMap getAccessInfo() throws RemoteException;
void setAccessInfo(HashMap paramHashMap) throws RemoteException;
}

View File

@@ -0,0 +1,182 @@
package wenrgise.ejb.common.session;
import java.text.DateFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import javax.ejb.EJBObject;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.BaseDetailVO;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.common.vo.BaseQueryVO;
import wenrgise.ejb.common.helper.ScreenWrapper;
public class UserSessionBean implements SessionBean {
private SessionContext context;
private UserInfo userInfo;
private HashMap oFormMap = new HashMap();
private Locale oUserLocale;
private Locale oDefaultLocale = Locale.getDefault();
private HashMap moduleFacade = new HashMap();
private String moduleName = null;
private HashMap securityMap = new HashMap();
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext ctx) {
this.context = ctx;
}
public HashMap getAccessInfo() {
return this.securityMap;
}
public void setAccessInfo(HashMap oMap) {
this.securityMap = oMap;
}
public void removeAllIfExists(String sFormName, String sScreenName) {
ScreenWrapper oScreenMap = (ScreenWrapper)this.oFormMap.get(sFormName);
if (oScreenMap == null)
return;
this.oFormMap.remove(sFormName);
}
private ScreenWrapper getScreenWrapper(String sFormName) {
ScreenWrapper oScreenWrapper = (ScreenWrapper)this.oFormMap.get(sFormName);
if (oScreenWrapper == null) {
oScreenWrapper = new ScreenWrapper();
this.oFormMap.put(sFormName, oScreenWrapper);
}
return oScreenWrapper;
}
public void setForwardedPage(String sFormName, String sForwardedPage) {
ScreenWrapper screenWrapper = getScreenWrapper(sFormName);
if (null != screenWrapper)
screenWrapper.setForwardedPage(sForwardedPage);
}
public String getForwardedPage(String sFormName) {
ScreenWrapper screenWrapper = getScreenWrapper(sFormName);
if (null != screenWrapper)
return screenWrapper.getForwardedPage();
return null;
}
private HashMap getScreenMap(String sFormName) {
ScreenWrapper oScreenWrapper = getScreenWrapper(sFormName);
HashMap oScreenMap = oScreenWrapper.getOScreenMap();
if (oScreenMap == null) {
oScreenMap = new HashMap();
oScreenWrapper.setOScreenMap(oScreenMap);
}
return oScreenMap;
}
public void putBaseHeaderVO(String sFormName, BaseHeaderVO oBaseHeaderVO) {
getScreenWrapper(sFormName).setOBaseHeaderVO(oBaseHeaderVO);
}
public void putBaseQueryVO(String sFormName, BaseQueryVO oBaseQueryVO) {
getScreenWrapper(sFormName).setOBaseQueryVO(oBaseQueryVO);
}
public void putBaseDetailVO(String sFormName, String sScreenName, BaseDetailVO oBaseDetailVO) {
getScreenMap(sFormName).put(sScreenName, oBaseDetailVO);
}
public BaseHeaderVO getBaseHeaderVO(String sFormName) {
ScreenWrapper oScreenWrapper = (ScreenWrapper)this.oFormMap.get(sFormName);
if (oScreenWrapper == null)
return null;
return oScreenWrapper.getOBaseHeaderVO();
}
public BaseQueryVO getBaseQueryVO(String sFormName) {
ScreenWrapper oScreenWrapper = (ScreenWrapper)this.oFormMap.get(sFormName);
if (oScreenWrapper == null)
return null;
return oScreenWrapper.getOBaseQueryVO();
}
public BaseDetailVO getBaseDetailVO(String sFormName, String sScreenName) {
ScreenWrapper oScreenWrapper = (ScreenWrapper)this.oFormMap.get(sFormName);
if (oScreenWrapper == null)
return null;
return (BaseDetailVO)oScreenWrapper.getOScreenMap().get(sScreenName);
}
public UserInfo getUserInfo() {
return this.userInfo;
}
public void setUserInfo(UserInfo newUserInfo) {
this.userInfo = newUserInfo;
}
public Locale getUserLocale() {
return this.oUserLocale;
}
public void setUserLocale(Locale oUserLocale) {
if (oUserLocale == null)
oUserLocale = this.oDefaultLocale;
}
public Locale getDefaultLocale() {
return this.oDefaultLocale;
}
public DateFormat getUserDateFormat() {
if (this.oUserLocale != null)
return DateFormat.getDateInstance(2, this.oUserLocale);
return DateFormat.getDateInstance();
}
public DateFormat getDefaultDateFormat() {
if (this.oDefaultLocale != null)
return DateFormat.getDateInstance(2, this.oDefaultLocale);
return DateFormat.getDateInstance();
}
public HashMap getModuleFacade() {
return this.moduleFacade;
}
public void setModuleFacade(HashMap newModuleFacade) {
this.moduleFacade = newModuleFacade;
}
public void removeAllDetailVO(String sFormName) {
ScreenWrapper oScreenWrapper = (ScreenWrapper)this.oFormMap.get(sFormName);
HashMap oMap = oScreenWrapper.getOScreenMap();
Collection oCollection = oMap.values();
oCollection.clear();
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public EJBObject getModuleEJBObject() {
if (null != this.moduleFacade)
return (EJBObject)this.moduleFacade.get(this.moduleName);
return null;
}
}

View File

@@ -0,0 +1,9 @@
package wenrgise.ejb.common.session;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface UserSessionHome extends EJBHome {
UserSession create() throws CreateException, RemoteException;
}

View File

@@ -0,0 +1,144 @@
package wenrgise.ejb.common.utility;
import java.util.ArrayList;
import java.util.Iterator;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.helper.QueryRow;
public class CommonAdditionalUtility {
public String getUserGroup(String empId) throws EnrgiseApplicationException, EnrgiseSystemException {
String groupId = new String();
String sQuery = String.valueOf(" select group_id from sys_user_group_map m where m.user_system_id = ").concat(String.valueOf(empId));
DBUtilitiesBean oBean = new DBUtilitiesBean();
ArrayList oList = oBean.executeQuery(sQuery);
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
groupId = oRow.get("group_id").getString();
}
}
return groupId;
}
public String getHOD(String empId) throws EnrgiseApplicationException, EnrgiseSystemException {
String hodId = new String();
String sQuery = String.valueOf(String.valueOf(" select m.contact_person_id from gen_wrkgrp_mst m where m.id = (select dtl.wkgp_mst_id from hrm_emp_wrkgrp_dtl dtl where dtl.e_per_dtl_id =").concat(String.valueOf(empId))).concat(String.valueOf(")"));
DBUtilitiesBean oBean = new DBUtilitiesBean();
ArrayList oList = oBean.executeQuery(sQuery);
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
hodId = oRow.get("CONTACT_PERSON_ID").getString();
}
}
return hodId;
}
public boolean checkValidEmail(String email) throws EnrgiseApplicationException, EnrgiseSystemException {
int atCount = 0;
int dotCount = 0;
boolean flag = true;
int i;
for (i = 0; i < email.length(); i++) {
if (email.charAt(i) == '@')
atCount++;
if (email.charAt(i) == '.')
dotCount++;
}
if (atCount == 1 && dotCount > 0 && email.indexOf("@") != 0 && email.charAt(email.length() - 1) != '.' && email.charAt(email.length() - 1) != '@') {
dotCount = 0;
for (i = email.indexOf("@"); i < email.length(); i++) {
if (email.charAt(i) == '.')
dotCount++;
if (email.indexOf("@") - email.indexOf(".") == -1 || email.lastIndexOf(".") - email.indexOf(".") == 1) {
flag = false;
break;
}
}
} else {
flag = false;
}
if (dotCount == 0 || dotCount > 2)
flag = false;
return flag;
}
public boolean checkValidPan(String panNo) throws EnrgiseApplicationException, EnrgiseSystemException {
boolean flag = true;
panNo = panNo.toUpperCase();
if (panNo.length() != 10) {
flag = false;
} else {
String first = panNo.substring(0, 5);
String second = panNo.substring(5, 9);
int i;
for (i = 0; i < first.length(); i++) {
if (first.charAt(i) < 'A' || first.charAt(i) > 'Z') {
flag = false;
break;
}
}
for (i = 0; i < second.length(); i++) {
if (second.charAt(i) < '0' || second.charAt(i) > '9') {
flag = false;
break;
}
}
if (panNo.charAt(9) < 'A' || panNo.charAt(9) > 'Z')
flag = false;
}
return flag;
}
public ArrayList getDelegatedEmp_Level(String empId, String HdrPrKey, String docTypeId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList outArray = new ArrayList();
String sQuery = "select wt.level_no, wt.delegated_emp_id ";
sQuery = String.valueOf(sQuery).concat(String.valueOf(" from workflow_tasklist wt,workflow_dtl wd,wfl_doc_type_mst wm "));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" where status='P' "));
sQuery = String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and delegator_emp_id = "))).concat(String.valueOf(empId));
sQuery = String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and doc_dtl_id = "))).concat(String.valueOf(HdrPrKey));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" and wt.workflow_dtl_id=wd.id "));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" and wd.doc_type_mst_id=wm.id "));
sQuery = String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and wm.id = "))).concat(String.valueOf(docTypeId));
DBUtilitiesBean oBean = new DBUtilitiesBean();
ArrayList oList = oBean.executeQuery(sQuery);
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
outArray.add(oRow.get("level_no").getString());
outArray.add(oRow.get("delegated_emp_id").getString());
}
}
return outArray;
}
public ArrayList getEmp_Level(String HdrPrKey, String docTypeId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList outArray = new ArrayList();
String sQuery = "select wt.level_no, wt.delegated_emp_id ";
sQuery = String.valueOf(sQuery).concat(String.valueOf(" from workflow_tasklist wt,workflow_dtl wd,wfl_doc_type_mst wm "));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" where status='P' "));
sQuery = String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and doc_dtl_id = "))).concat(String.valueOf(HdrPrKey));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" and wt.workflow_dtl_id=wd.id "));
sQuery = String.valueOf(sQuery).concat(String.valueOf(" and wd.doc_type_mst_id=wm.id "));
sQuery = String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and wm.id = "))).concat(String.valueOf(docTypeId));
DBUtilitiesBean oBean = new DBUtilitiesBean();
ArrayList oList = oBean.executeQuery(sQuery);
if (oList.size() != 0) {
QueryRow oRow = null;
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
oRow = oIt.next();
outArray.add(oRow.get("level_no").getString());
outArray.add(oRow.get("delegated_emp_id").getString());
}
}
return outArray;
}
}

View File

@@ -0,0 +1,611 @@
package wenrgise.ejb.common.utility;
import java.sql.BatchUpdateException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.InputDBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
public class DBUtilitiesBean {
private String sDbName = "jdbc/conDS";
private ArrayList oOutParameters = null;
private Connection oCon;
private ResultSet oRs;
private Connection oConn = null;
private DataSource oDataSource = null;
private PreparedStatement oDynamicBatchCall = null;
private CallableStatement oBatchCall = null;
private Connection oBatchCon = null;
private Connection oPreParameterCon = null;
private PreparedStatement oPreParameter = null;
private Connection oPreUpsertCon = null;
private PreparedStatement oPreUpsert = null;
private boolean bDynamic = false;
public DBUtilitiesBean() {}
public DBUtilitiesBean(boolean bDynamic) {
this.bDynamic = bDynamic;
}
public void createBatch(String sProcName) throws EnrgiseSystemException {
InitialContext oInitCont = null;
String sParam = String.valueOf(String.valueOf("{ call ").concat(String.valueOf(sProcName))).concat(String.valueOf("}"));
boolean bCreateCoonectionError = false;
try {
Object dataSourceObj = ServiceLocator.getLocator().getLocalService(this.sDbName);
this.oDataSource = (DataSource)dataSourceObj;
this.oBatchCon = this.oDataSource.getConnection();
bCreateCoonectionError = true;
if (!this.bDynamic) {
if (this.oBatchCall != null) {
this.oBatchCall.close();
this.oBatchCall = null;
}
this.oBatchCall = this.oBatchCon.prepareCall(sParam);
bCreateCoonectionError = false;
} else {
if (this.oDynamicBatchCall != null) {
this.oDynamicBatchCall.close();
this.oDynamicBatchCall = null;
}
this.oDynamicBatchCall = this.oBatchCon.prepareStatement(sParam);
bCreateCoonectionError = false;
}
} catch (SQLException oExc) {
System.out.println(oExc.getMessage());
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (this.oBatchCon != null && bCreateCoonectionError) {
if (!this.oBatchCon.isClosed())
this.oBatchCon.close();
this.oBatchCon = null;
}
} catch (SQLException sQLException) {}
}
}
public void addToBatch(ArrayList oParameters) throws EnrgiseSystemException {
if (!this.bDynamic) {
addToProcBatch(oParameters);
} else {
addToDynamicBatch(oParameters);
}
}
private void addToDynamicBatch(ArrayList oParameters) throws EnrgiseSystemException {
try {
Iterator oIter = oParameters.iterator();
while (oIter.hasNext()) {
InputDBObject oObject = oIter.next();
inspectExecuteParameter(oObject, this.oDynamicBatchCall);
}
this.oBatchCall.addBatch();
} catch (SQLException oSqlEx) {
System.out.println(oSqlEx.getMessage());
throw new EnrgiseSystemException(oSqlEx);
} finally {
try {
if (this.oBatchCon != null) {
if (!this.oBatchCon.isClosed())
this.oBatchCon.close();
this.oBatchCon = null;
}
} catch (SQLException sQLException) {}
}
}
private void addToProcBatch(ArrayList oParameters) throws EnrgiseSystemException {
try {
Iterator oIter = oParameters.iterator();
while (oIter.hasNext()) {
DBObject oObject = oIter.next();
inspectParameter(oObject, this.oBatchCall);
}
this.oBatchCall.addBatch();
} catch (SQLException oSqlEx) {
oSqlEx.printStackTrace();
System.out.println(oSqlEx.getMessage());
try {
if (this.oBatchCon != null)
if (!this.oBatchCon.isClosed())
this.oBatchCon.close();
this.oBatchCon = null;
} catch (SQLException sQLException) {}
throw new EnrgiseSystemException(oSqlEx);
}
}
public void executeBatch() throws EnrgiseSystemException {
try {
if (!this.bDynamic) {
this.oBatchCall.executeBatch();
} else {
this.oDynamicBatchCall.executeBatch();
}
} catch (BatchUpdateException oBatchEx) {
System.out.println("Batch Update Failed");
System.out.println(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("Casue ").concat(String.valueOf(oBatchEx.getCause()))).concat(String.valueOf(" Message "))).concat(String.valueOf(oBatchEx.getMessage()))).concat(String.valueOf(" SQL State "))).concat(String.valueOf(oBatchEx.getSQLState()))).concat(String.valueOf(" Update Count "))).concat(String.valueOf(oBatchEx.getUpdateCounts()))).concat(String.valueOf(" SQL Trace "))).concat(String.valueOf(oBatchEx.getStackTrace())));
throw new EnrgiseSystemException(oBatchEx);
} catch (SQLException oSqlEx) {
System.out.println(String.valueOf("dbutilities").concat(String.valueOf(oSqlEx.getMessage())));
oSqlEx.printStackTrace();
throw new EnrgiseSystemException(oSqlEx);
} finally {
try {
if (this.oBatchCon != null)
if (!this.oBatchCon.isClosed())
this.oBatchCon.close();
} catch (SQLException sQLException) {}
}
}
public int executeUpsert(ArrayList oParameters, String sQuery) throws EnrgiseSystemException {
int iCount = 0;
try {
this.oDataSource = (DataSource)ServiceLocator.getLocator().getLocalService(this.sDbName);
if (this.oPreUpsert != null)
this.oPreUpsert.close();
if (this.oPreUpsertCon != null) {
this.oPreUpsertCon.close();
this.oPreUpsertCon = null;
}
this.oPreUpsertCon = this.oDataSource.getConnection();
this.oPreUpsert = this.oPreUpsertCon.prepareStatement(sQuery);
Iterator oIter = oParameters.iterator();
while (oIter.hasNext()) {
InputDBObject oObject = oIter.next();
inspectExecuteParameter(oObject, this.oPreUpsert);
}
iCount = this.oPreUpsert.executeUpdate();
while (true);
} catch (Exception oExc) {
System.out.println(oExc.getMessage());
oExc.printStackTrace();
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (this.oPreUpsertCon != null) {
if (!this.oPreUpsertCon.isClosed())
this.oPreUpsertCon.close();
this.oPreUpsertCon = null;
}
} catch (SQLException oSqlEx) {
System.out.println(oSqlEx.getMessage());
throw new EnrgiseSystemException(oSqlEx);
}
return iCount;
}
}
public ArrayList executeQuery(ArrayList oParameters, String sQuery) throws EnrgiseSystemException {
ResultSet oRs = null;
ArrayList oResult = null;
try {
this.oDataSource = (DataSource)ServiceLocator.getLocator().getLocalService(this.sDbName);
if (oRs != null) {
oRs.close();
oRs = null;
}
if (this.oPreParameter != null)
this.oPreParameter.close();
if (this.oPreParameterCon != null) {
this.oPreParameterCon.close();
this.oPreParameterCon = null;
}
this.oPreParameterCon = this.oDataSource.getConnection();
this.oPreParameter = this.oPreParameterCon.prepareStatement(sQuery);
Iterator oIter = oParameters.iterator();
while (oIter.hasNext()) {
InputDBObject oObject = oIter.next();
inspectExecuteParameter(oObject, this.oPreParameter);
}
oRs = this.oPreParameter.executeQuery();
if (oRs == null)
throw new EnrgiseSystemException();
oResult = convertToList(oRs);
while (true);
} catch (Exception oExc) {
System.out.println(oExc.getMessage());
oExc.printStackTrace();
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (this.oPreParameterCon != null)
if (this.oPreParameterCon.isClosed())
this.oPreParameterCon.close();
} catch (SQLException oSqlEx) {
System.out.println(oSqlEx.getMessage());
throw new EnrgiseSystemException(oSqlEx);
}
return oResult;
}
}
public ArrayList callProc(ArrayList oParameters, String sProcName) throws EnrgiseSystemException {
CallableStatement oCall = null;
if (this.oOutParameters == null) {
this.oOutParameters = new ArrayList();
} else {
this.oOutParameters.clear();
}
try {
Object datasourceObj = null;
datasourceObj = ServiceLocator.getLocator().getLocalService(this.sDbName);
this.oDataSource = (DataSource)datasourceObj;
Object conObj = this.oDataSource.getConnection();
this.oCon = (Connection)conObj;
if (oCall != null)
oCall.close();
String sParam = String.valueOf(String.valueOf("{ call ").concat(String.valueOf(sProcName))).concat(String.valueOf("}"));
Object callObj = this.oCon.prepareCall(sParam);
oCall = (CallableStatement)callObj;
Iterator oIter = oParameters.iterator();
while (oIter.hasNext()) {
DBObject oObject = oIter.next();
inspectParameter(oObject, oCall);
}
oCall.execute();
Iterator oOutIter = this.oOutParameters.iterator();
while (oOutIter.hasNext())
getOutParameters(oOutIter.next(), oCall);
if (this.oOutParameters.size() >= 3) {
DBObject oErrLog = this.oOutParameters.get(this.oOutParameters.size() - 3);
String sErrorLog = (String)oErrLog.getObject();
DBObject oErrMessage = this.oOutParameters.get(this.oOutParameters.size() - 2);
String sErrorMessage = (String)oErrLog.getObject();
DBObject oErr = this.oOutParameters.get(this.oOutParameters.size() - 1);
Integer oErrorCode = (Integer)oErr.getObject();
if (null != oErrorCode && !oErrorCode.equals(new Integer(0))) {
System.out.println(String.valueOf("Error calling procedure ").concat(String.valueOf(sProcName)));
if (null != sErrorLog)
System.out.println(String.valueOf("Error Log ").concat(String.valueOf(sErrorLog)));
if (null != sErrorMessage)
System.out.println(String.valueOf("Error Message ").concat(String.valueOf(sErrorMessage)));
throw new EnrgiseSystemException();
}
}
return this.oOutParameters;
} catch (Exception oExc) {
System.out.println(oExc.getMessage());
oExc.printStackTrace();
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (this.oCon != null) {
if (!this.oCon.isClosed())
this.oCon.close();
this.oCon = null;
}
} catch (Exception exception) {}
}
}
public ArrayList executeQuery(String sQuery) throws EnrgiseSystemException {
PreparedStatement oPre = null;
ArrayList oResult = null;
try {
this.oDataSource = (DataSource)ServiceLocator.getLocator().getLocalService(this.sDbName);
if (this.oRs != null) {
this.oRs.close();
this.oRs = null;
}
if (oPre != null)
oPre.close();
if (this.oConn != null) {
this.oConn.close();
this.oConn = null;
}
this.oConn = this.oDataSource.getConnection();
oPre = this.oConn.prepareStatement(sQuery);
this.oRs = oPre.executeQuery();
oResult = convertToList(this.oRs);
while (true);
} catch (SQLException oExc) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("From DBUtility ").concat(String.valueOf(oExc.getClass().getName()))).concat(String.valueOf(" "))).concat(String.valueOf(oExc.getMessage())));
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (this.oConn != null)
if (!this.oConn.isClosed())
this.oConn.close();
} catch (SQLException oSqEx) {
throw new EnrgiseSystemException(oSqEx);
}
return oResult;
}
}
public int executeUpsert(String sQuery) throws EnrgiseSystemException {
PreparedStatement oPre = null;
Connection oPreCon = null;
int iCount = 0;
try {
this.oDataSource = (DataSource)ServiceLocator.getLocator().getLocalService(this.sDbName);
if (oPre != null)
oPre.close();
oPreCon = this.oDataSource.getConnection();
oPre = oPreCon.prepareStatement(sQuery);
iCount = oPre.executeUpdate();
while (true);
} catch (SQLException oExc) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("From DBUtility ").concat(String.valueOf(oExc.getClass().getName()))).concat(String.valueOf(" "))).concat(String.valueOf(oExc.getMessage())));
throw new EnrgiseSystemException(oExc);
} finally {
try {
if (oPreCon != null)
if (!oPreCon.isClosed())
oPreCon.close();
} catch (SQLException oSqEx) {
throw new EnrgiseSystemException(oSqEx);
}
return iCount;
}
}
private void inspectParameter(DBObject oDBObject, CallableStatement oCall) throws SQLException {
int iPosition = oDBObject.getPosition();
int iDirection = oDBObject.getDirection();
int iDataType = oDBObject.getDataType();
if (iDirection == 1 || iDirection == 3) {
Object oObject = oDBObject.getObject();
switch (iDataType) {
case 12:
if (oObject != null) {
oCall.setString(iPosition, oObject.toString());
break;
}
oCall.setString(iPosition, (String)null);
break;
case 4:
if (oObject != null) {
oCall.setInt(iPosition, Integer.parseInt(oObject.toString()));
break;
}
oCall.setInt(iPosition, 0);
break;
case 8:
if (oObject != null) {
oCall.setDouble(iPosition, Double.parseDouble(oObject.toString()));
break;
}
oCall.setDouble(iPosition, 0.0D);
break;
case -5:
if (oObject != null) {
oCall.setLong(iPosition, ((Long)oObject).longValue());
break;
}
oCall.setLong(iPosition, 0L);
break;
case 91:
if (oObject != null) {
oCall.setDate(iPosition, (Date)oObject);
break;
}
oCall.setDate(iPosition, (Date)null);
break;
case 93:
if (oObject != null) {
oCall.setTimestamp(iPosition, (Timestamp)oObject);
break;
}
oCall.setTimestamp(iPosition, (Timestamp)null);
break;
case 2000:
if (oObject != null) {
oCall.setObject(iPosition, oObject);
break;
}
oCall.setObject(iPosition, (Object)null);
break;
}
}
if (iDirection == 2 || iDirection == 3) {
oCall.registerOutParameter(iPosition, iDataType);
this.oOutParameters.add(new DBObject(iPosition, iDataType));
}
}
private void inspectExecuteParameter(InputDBObject oDBObject, PreparedStatement oCall) throws SQLException {
int iPosition = oDBObject.getPosition();
int iDataType = oDBObject.getDataType();
Object oObject = oDBObject.getObject();
switch (iDataType) {
case 12:
if (oObject != null) {
oCall.setString(iPosition, oObject.toString());
break;
}
oCall.setString(iPosition, (String)null);
break;
case 1:
if (oObject != null) {
oCall.setString(iPosition, oObject.toString());
break;
}
oCall.setString(iPosition, (String)null);
break;
case 4:
if (oObject != null) {
oCall.setInt(iPosition, Integer.parseInt(oObject.toString()));
break;
}
oCall.setInt(iPosition, 0);
break;
case 8:
if (oObject != null) {
oCall.setDouble(iPosition, Double.parseDouble(oObject.toString()));
break;
}
oCall.setDouble(iPosition, 0.0D);
break;
case -5:
if (oObject != null) {
oCall.setLong(iPosition, ((Long)oObject).longValue());
break;
}
oCall.setLong(iPosition, 0L);
break;
case 91:
if (oObject != null) {
oCall.setDate(iPosition, (Date)oObject);
break;
}
oCall.setDate(iPosition, (Date)null);
break;
case 93:
if (oObject != null) {
oCall.setTimestamp(iPosition, (Timestamp)oObject);
break;
}
oCall.setTimestamp(iPosition, (Timestamp)null);
break;
case 2000:
oCall.setObject(iPosition, oObject);
break;
}
}
private void getOutParameters(DBObject oOutDBObject, CallableStatement oCall) throws SQLException {
int iPosition = oOutDBObject.getPosition();
int iDataType = oOutDBObject.getDataType();
switch (iDataType) {
case 12:
oOutDBObject.setObject(oCall.getString(iPosition));
break;
case 1:
oOutDBObject.setObject(oCall.getString(iPosition));
break;
case 4:
oOutDBObject.setObject(new Integer(oCall.getInt(iPosition)));
break;
case -5:
oOutDBObject.setObject(new Long(oCall.getLong(iPosition)));
break;
case 8:
oOutDBObject.setObject(new Double(oCall.getDouble(iPosition)));
break;
case 91:
oOutDBObject.setObject(oCall.getDate(iPosition));
break;
case 93:
oOutDBObject.setObject(oCall.getTimestamp(iPosition));
break;
case 2000:
oOutDBObject.setObject(oCall.getObject(iPosition));
break;
case -10:
oOutDBObject.setObject(convertToList((ResultSet)oCall.getObject(iPosition)));
break;
}
}
private ArrayList convertToList(ResultSet oRs2) throws SQLException {
if (null == oRs2)
return null;
ResultSetMetaData oRsMt = oRs2.getMetaData();
int iColumnCount = oRsMt.getColumnCount();
int iIndex = 0;
ArrayList oList = new ArrayList();
String[] sColumnName = new String[iColumnCount];
int[] iColumnType = new int[iColumnCount];
for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
sColumnName[iIndex] = oRsMt.getColumnName(iIndex + 1);
iColumnType[iIndex] = oRsMt.getColumnType(iIndex + 1);
}
while (oRs2.next()) {
QueryRow oRow = new QueryRow(iColumnCount);
for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
QueryValue oValue = new QueryValue();
setValue(sColumnName[iIndex], iColumnType[iIndex], oValue, oRs2);
oRow.getRow().put(sColumnName[iIndex].toUpperCase(), oValue);
}
oList.add(oRow);
}
oRs2.close();
oRs2 = null;
return oList;
}
private void setValue(String sColumnName, int iColumnType, QueryValue oValue, ResultSet oRs2) throws SQLException {
switch (iColumnType) {
case 2:
oValue.setString(oRs2.getString(sColumnName));
break;
case 12:
oValue.setString(oRs2.getString(sColumnName));
break;
case 1:
oValue.setString(oRs2.getString(sColumnName));
break;
case 4:
oValue.setInt(oRs2.getInt(sColumnName));
break;
case -5:
oValue.setLong(oRs2.getLong(sColumnName));
break;
case 8:
oValue.setDouble(oRs2.getDouble(sColumnName));
break;
case 91:
oValue.setDate(oRs2.getDate(sColumnName));
break;
case 93:
oValue.setTimestamp(oRs2.getTimestamp(sColumnName));
break;
case 2004:
oValue.setBlob(oRs2.getBlob(sColumnName));
break;
case 2005:
oValue.setClob(oRs2.getClob(sColumnName));
break;
}
}
protected void finalize() {
try {
close();
} catch (SQLException sQLException) {}
}
private void close() throws SQLException {
if (this.oCon != null) {
if (!this.oCon.isClosed())
this.oCon.close();
this.oCon = null;
}
if (this.oConn != null) {
if (!this.oConn.isClosed())
this.oConn.close();
this.oConn = null;
}
}
}

View File

@@ -0,0 +1,38 @@
package wenrgise.ejb.common.utility;
import java.util.logging.Logger;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import wenrgise.common.utility.UserInfo;
public class EnrgiseDisplayUserTag extends BodyTagSupport {
public static Logger log = Logger.getLogger("wenrgise.common.taglib.enrgise.EnrgiseDisplayUserTag");
public int doStartTag() throws JspException {
try {
String sessionBeanName = ParamUtil.getSessionBeanName();
UserInfo oUserInfo = (UserInfo)RequestUtils.lookup(this.pageContext, sessionBeanName, "userInfo", "session");
if (null != oUserInfo) {
String sEmp = RequestUtils.message(this.pageContext, null, "org.apache.struts.action.LOCALE", "wenrgise.common.user.name", null);
StringBuffer sbOutString = new StringBuffer(sEmp);
sbOutString.append(oUserInfo.getUserName());
sbOutString.append("(");
sbOutString.append(oUserInfo.getUserId());
sbOutString.append(")");
sbOutString.append(" ");
String sSite = RequestUtils.message(this.pageContext, null, "org.apache.struts.action.LOCALE", "wenrgise.common.site.name", null);
sbOutString.append(sSite);
sbOutString.append(oUserInfo.getSiteName());
sbOutString.append("(");
sbOutString.append(oUserInfo.getSiteCode());
sbOutString.append(")");
ResponseUtils.write(this.pageContext, sbOutString.toString());
}
} catch (Exception oEx) {
log.info(oEx.getMessage());
}
return 2;
}
}

View File

@@ -0,0 +1,52 @@
package wenrgise.ejb.common.utility;
import java.rmi.RemoteException;
import java.util.Locale;
import java.util.logging.Logger;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import wenrgise.common.utility.UserInfo;
import wenrgise.ejb.common.session.UserSession;
import wenrgise.ejb.common.session.UserSessionHome;
public class EnrgiseListener implements HttpSessionListener {
static final Logger log = Logger.getLogger("wenrgise.common.utility.EnrgiseListener");
public void sessionCreated(HttpSessionEvent sEvent) {
try {
System.out.println("Creating Session---->");
HttpSession session = sEvent.getSession();
UserSession oUser = (UserSession)session.getAttribute(ParamUtil.getSessionBeanName());
if (oUser == null) {
UserSessionHome oUserHome = (UserSessionHome)ServiceLocator.getLocator().getService("UserSession");
oUser = oUserHome.create();
UserInfo oUserInfo = new UserInfo();
oUser.setUserInfo(oUserInfo);
Locale oLocale = (Locale)session.getAttribute("locale");
oUser.setUserLocale((Locale)session.getAttribute("locale"));
session.setAttribute(ParamUtil.getSessionBeanName(), oUser);
}
} catch (RemoteException oRmt) {
log.severe(oRmt.getMessage());
} catch (CreateException oCrt) {
log.severe(oCrt.getMessage());
} catch (Exception oExCc) {
log.severe(oExCc.getMessage());
}
}
public void sessionDestroyed(HttpSessionEvent sEvent) {
try {
HttpSession session = sEvent.getSession();
if (session != null) {
UserSession oUser = (UserSession)session.getAttribute(ParamUtil.getSessionBeanName());
oUser.remove();
}
} catch (RemoveException removeException) {
} catch (RemoteException remoteException) {}
}
}

View File

@@ -0,0 +1,66 @@
package wenrgise.ejb.common.utility;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.xml.vo.DetailScreen;
import wenrgise.common.xml.vo.DetailScreens;
import wenrgise.common.xml.vo.EnrgiseApp;
import wenrgise.common.xml.vo.EnrgiseForms;
import wenrgise.common.xml.vo.HashedEnrgiseForms;
import wenrgise.common.xml.vo.SingleForm;
public class EnrgiseManager {
private static EnrgiseManager me;
private HashMap oEnrgiseMap = new HashMap();
private HashMap appMap = new HashMap();
public static EnrgiseManager getInstance() {
if (me == null)
me = new EnrgiseManager();
return me;
}
public HashedEnrgiseForms getCachedObject(String name_) {
if (name_ == null || name_.trim().length() <= 0)
return null;
return (HashedEnrgiseForms)this.oEnrgiseMap.get(name_);
}
public void init(EnrgiseForms oEnrgiseForms) {
if (oEnrgiseForms == null)
return;
ArrayList oFormsList = oEnrgiseForms.get_SingleForm();
Iterator oIt = oFormsList.iterator();
while (oIt.hasNext()) {
SingleForm oSingleForm = oIt.next();
String sFormName = oSingleForm.get_FormName();
HashedEnrgiseForms oHashedEnrgiseForms = new HashedEnrgiseForms();
oHashedEnrgiseForms.setSingleForm(oSingleForm);
DetailScreens oDetailScreens = oSingleForm.get_DetailScreens();
ArrayList oDetailList = oDetailScreens.get_DetailScreen();
Iterator oDetailIt = oDetailList.iterator();
while (oDetailIt.hasNext()) {
DetailScreen oDetailScreen = oDetailIt.next();
String sDetailName = oDetailScreen.get_DetailScreenName();
if (!oHashedEnrgiseForms.getDetailMap().containsKey(sDetailName))
oHashedEnrgiseForms.getDetailMap().put(sDetailName, oDetailScreen);
}
if (!this.oEnrgiseMap.containsKey(sFormName))
this.oEnrgiseMap.put(sFormName, oHashedEnrgiseForms);
}
}
public void setEnrApp(EnrgiseApp oEnrApp) {
System.out.println(String.valueOf("DBname---->").concat(String.valueOf(oEnrApp.get_DBName())));
System.out.println(String.valueOf("Module---->").concat(String.valueOf(oEnrApp.get_Module())));
this.appMap.put("DBName", oEnrApp.get_DBName());
this.appMap.put("Module", oEnrApp.get_Module());
}
public HashMap getAppMap() {
return this.appMap;
}
}

View File

@@ -0,0 +1,56 @@
package wenrgise.ejb.common.utility;
import com.tcs.wenrgise.util.common.FWXMLUtility;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
import wenrgise.common.xml.vo.EnrgiseApp;
import wenrgise.common.xml.vo.EnrgiseForms;
import wenrgise.common.xml.vo.LOVClass;
public class EnrgisePlugIn implements PlugIn {
static final Logger log = Logger.getLogger("wenrgise.ejb.common.utility.EnrgisePlugIn");
private String formPathName = "/WEB-INF/EnrgiseConfig.xml";
private String pathName = "/WEB-INF/EnrgiseLOV.xml";
private String appPath = "/WEB-INF/EnrgiseApp.xml";
private String reportPathName = "/WEB-INF/EnrgiseReport.xml";
private String wflImplPathName = "/WEB-INF/WflDocParameters.xml";
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {
try {
System.out.println("I am in enrgise plugIn for HRMS--->");
String appPathTest = calculatePath(servlet, this.appPath);
String configPathTest = calculatePath(servlet, this.formPathName);
String lovPathTest = calculatePath(servlet, this.pathName);
EnrgiseForms oEnrgiseForms = (EnrgiseForms)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.EnrgiseForms", configPathTest);
EnrgiseManager.getInstance().init(oEnrgiseForms);
LOVClass oLOVClass = (LOVClass)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.LOVClass", lovPathTest);
LOVManager.getInstance().init(oLOVClass);
EnrgiseApp oEnrgiseApp = (EnrgiseApp)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.EnrgiseApp", appPathTest);
EnrgiseManager.getInstance().setEnrApp(oEnrgiseApp);
} catch (Exception oEx) {
log.severe(oEx.getMessage());
}
}
public void destroy() {}
private String calculatePath(ActionServlet servlet, String sPath) {
return servlet.getServletContext().getRealPath(sPath);
}
public String getFormPathName() {
return this.formPathName;
}
public void setFormPathName(String newFormPathName) {
this.formPathName = newFormPathName;
}
}

View File

@@ -0,0 +1,28 @@
package wenrgise.ejb.common.utility;
import java.rmi.RemoteException;
import java.util.logging.Logger;
import javax.ejb.RemoveException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
import wenrgise.ejb.common.session.UserSession;
public class EnrgiseSessionListener implements HttpSessionActivationListener {
static final Logger log = Logger.getLogger("wenrgise.common.Utility.EnrgiseSessionListener");
public void sessionDidActivate(HttpSessionEvent sessionEvent) {}
public void sessionWillPassivate(HttpSessionEvent sessionEvent) {
try {
HttpSession oS = sessionEvent.getSession();
UserSession oUser = (UserSession)oS.getAttribute(ParamUtil.getSessionBeanName());
if (oUser != null)
oUser.remove();
} catch (RemoteException oExc) {
log.severe(String.valueOf("The reason ").concat(String.valueOf(oExc.getMessage())));
} catch (RemoveException oEx) {
log.severe(String.valueOf("The reason ").concat(String.valueOf(oEx.getMessage())));
}
}
}

View File

@@ -0,0 +1,65 @@
package wenrgise.ejb.common.utility;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.xml.vo.LOV;
import wenrgise.common.xml.vo.LOVClass;
import wenrgise.common.xml.vo.LOVInfo;
import wenrgise.common.xml.vo.Screen;
import wenrgise.common.xml.vo.ScreenMode;
import wenrgise.common.xml.vo.ScreenModes;
import wenrgise.common.xml.vo.Screens;
public class LOVManager {
private static LOVManager me;
private HashMap oMap = new HashMap();
public static LOVManager getInstance() {
if (me == null)
me = new LOVManager();
return me;
}
public LOVInfo getCachedObject(String name_) {
if (name_ == null || name_.trim().length() <= 0)
return null;
return (LOVInfo)this.oMap.get(name_);
}
public void init(LOVClass oLOVClass) {
if (oLOVClass == null)
return;
ArrayList oList = oLOVClass.get_LOV();
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
LOV oLOV = oIt.next();
String sLOVName = oLOV.get_LovKey();
Screens oScreens = oLOV.get_Screens();
Iterator oScreenIt = oScreens.get_Screen().iterator();
while (oScreenIt.hasNext()) {
Screen oScreen = oScreenIt.next();
String sScreenName = oScreen.get_ScreenName();
ScreenModes oScreenModes = oScreen.get_ScreenModes();
Iterator oScreenModeIt = oScreenModes.get_ScreenMode().iterator();
while (oScreenModeIt.hasNext()) {
ScreenMode oScreenMode = oScreenModeIt.next();
String sMode = oScreenMode.get_ModeName();
LOVInfo oLOVInfo = new LOVInfo();
oLOVInfo.setFacadeName(oScreenMode.get_FacadeName());
oLOVInfo.setFunctionName(oScreenMode.get_FunctionName());
oLOVInfo.setInsertFlag(oScreenMode.get_InsertFlag());
oLOVInfo.setRecursiveFlag(oScreenMode.get_RecursiveFlag());
String sCombinedKey = String.valueOf(String.valueOf(sLOVName).concat(String.valueOf(sScreenName))).concat(String.valueOf(sMode));
if (!this.oMap.containsKey(sCombinedKey))
this.oMap.put(sCombinedKey, oLOVInfo);
}
}
}
}
public static void main(String[] argv) {
LOVManager oLov = new LOVManager();
}
}

View File

@@ -0,0 +1,95 @@
package wenrgise.ejb.common.utility;
import java.util.ArrayList;
import wenrgise.common.xml.vo.DetailScreen;
import wenrgise.common.xml.vo.DetailScreens;
import wenrgise.common.xml.vo.HashedEnrgiseForms;
import wenrgise.common.xml.vo.SingleForm;
public class ParamUtil {
public static String getDBName() {
return (String)EnrgiseManager.getInstance().getAppMap().get("DBName");
}
public static String getModuleName() {
return (String)EnrgiseManager.getInstance().getAppMap().get("Module");
}
public static String getQueryVO(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_EnrgiseQueryVO();
}
public static String getHeaderBD(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_HeaderBD();
}
public static String getHeaderSaveRequired(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_HeaderSave();
}
public static String getPseudoHeaderFlag(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_PseudoHeader();
}
public static String getDetailBD(String sFormName, String sScreenName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
DetailScreen oDetailScreen = (DetailScreen)oHashedEnrgiseForms.getDetailMap().get(sScreenName);
return oDetailScreen.get_DetailBD();
}
public static String getDetailArrayName(String sFormName, String sScreenName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
DetailScreen oDetailScreen = (DetailScreen)oHashedEnrgiseForms.getDetailMap().get(sScreenName);
return oDetailScreen.get_DetailArrayName();
}
public static String getDetailBeanName(String sFormName, String sScreenName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
DetailScreen oDetailScreen = (DetailScreen)oHashedEnrgiseForms.getDetailMap().get(sScreenName);
return oDetailScreen.get_DetailBean();
}
public static String getSessionBeanName() {
String s = String.valueOf(getModuleName()).concat(String.valueOf("_UserSession"));
return String.valueOf(getModuleName()).concat(String.valueOf("_UserSession"));
}
public static String getHeaderBean(String sFormName) {
try {
System.out.println(String.valueOf("I am in paramUtil-->").concat(String.valueOf(sFormName)));
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_HeaderBean();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public static int getHeaderSize(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return Integer.parseInt(oHashedEnrgiseForms.getSingleForm().get_HeaderSize());
}
public static int getDetailRecordPerPage(String sFormName, String sScreenName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
DetailScreen oDetailScreen = (DetailScreen)oHashedEnrgiseForms.getDetailMap().get(sScreenName);
return Integer.parseInt(oDetailScreen.get_DetailRecordPerPage());
}
public static int getMaxDetailPages(String sFormName, String sScreenName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
DetailScreen oDetailScreen = (DetailScreen)oHashedEnrgiseForms.getDetailMap().get(sScreenName);
return Integer.parseInt(oDetailScreen.get_DetailPagesPerSlot());
}
public static ArrayList getDetailList(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
SingleForm oSingleForm = oHashedEnrgiseForms.getSingleForm();
DetailScreens oDetailScreens = oSingleForm.get_DetailScreens();
return oDetailScreens.get_DetailScreen();
}
}

View File

@@ -0,0 +1,50 @@
package wenrgise.ejb.common.utility;
import wenrgise.common.vo.BaseQueryVO;
import wenrgise.common.vo.DetailSizeValues;
public class PositionResolver {
public static long getStartPosition(BaseQueryVO oBaseQueryVO, long lTotalCount) {
int iMaxHeaderSize = oBaseQueryVO.getMaxHeaderSize();
long lPositionRequested = oBaseQueryVO.getPositionRequested();
if (lPositionRequested != 0L) {
long l;
return l = lPositionRequested;
}
int iStep = (int)(lTotalCount / iMaxHeaderSize);
long lStartPosition;
return lStartPosition = (iStep * iMaxHeaderSize + 1);
}
public static long getLastPosition(BaseQueryVO oBaseQueryVO, long lTotalCount) {
long lLastPosition;
int iMaxHeaderSize = oBaseQueryVO.getMaxHeaderSize();
long lPositionRequested = oBaseQueryVO.getPositionRequested();
if (lPositionRequested != 0L) {
if (lPositionRequested + iMaxHeaderSize - 1L < lTotalCount) {
lLastPosition = lPositionRequested + iMaxHeaderSize - 1L;
} else {
lLastPosition = lTotalCount;
}
} else {
lLastPosition = lTotalCount;
}
return lLastPosition;
}
public static long getDetailFirstPosition(int iStartPage, long lTotalDetailRecord, DetailSizeValues oDetailSizeValues) {
int iDetailRecordPerPage = oDetailSizeValues.getDetailRecordPerPage();
int iMaxPage = oDetailSizeValues.getMaxPages();
if (lTotalDetailRecord > ((iStartPage - 1) * iDetailRecordPerPage))
return ((iStartPage - 1) * iDetailRecordPerPage + 1);
return 1L;
}
public static long getDetailLastPosition(int iStartPage, long lTotalDetailRecord, DetailSizeValues oDetailSizeValues) {
int iDetailRecordPerPage = oDetailSizeValues.getDetailRecordPerPage();
int iMaxPage = oDetailSizeValues.getMaxPages();
if (lTotalDetailRecord > ((iStartPage + iMaxPage - 1) * iDetailRecordPerPage))
return ((iStartPage + iMaxPage - 1) * iDetailRecordPerPage);
return lTotalDetailRecord;
}
}

View File

@@ -0,0 +1,91 @@
package wenrgise.ejb.common.utility;
import java.util.HashMap;
import javax.ejb.EJBLocalHome;
import javax.naming.Context;
import javax.naming.NamingException;
import wenrgise.common.exception.EnrgiseSystemException;
public class ServiceLocator {
private HashMap homeCache;
private final HashMap cacheMap = new HashMap();
private static ServiceLocator serviceLocator = new ServiceLocator();
private ServiceLocator() {
try {
this.homeCache = new HashMap();
} catch (Throwable e) {
e.printStackTrace();
}
}
public static ServiceLocator getLocator() {
return serviceLocator;
}
public Object getService(String jndiName) throws EnrgiseSystemException {
try {
if (!this.homeCache.containsKey(jndiName.trim())) {
System.out.println("Test For Service Locator ---->");
System.out.println(String.valueOf("JNDI Name ---->").concat(String.valueOf(jndiName)));
Context context = myContextProvider.getContext();
System.out.println(String.valueOf("Context Name ---->").concat(String.valueOf(context.getNameInNamespace())));
System.out.println(String.valueOf("Context").concat(String.valueOf(context.getEnvironment())));
System.out.println("Context security java.naming.security.credentials");
System.out.println("Context url is java.naming.provider.url");
System.out.println(String.valueOf("jndiName : ").concat(String.valueOf(context.lookup(jndiName))));
this.homeCache.put(jndiName.trim(), context.lookup(jndiName.trim()));
System.out.println(String.valueOf("After JNDI Name ---->").concat(String.valueOf(jndiName)));
}
} catch (NamingException oNa) {
oNa.printStackTrace();
System.out.println(oNa.getExplanation());
throw new EnrgiseSystemException(oNa);
} catch (Exception oEx) {
oEx.printStackTrace();
throw new EnrgiseSystemException(oEx);
}
return this.homeCache.get(jndiName.trim());
}
public Object getLocalService(String jndiHomeName) throws EnrgiseSystemException {
Object obj = null;
try {
Context context = myContextProvider.getLocalContext();
if (this.cacheMap.containsKey(jndiHomeName)) {
obj = this.cacheMap.get(jndiHomeName);
} else {
obj = context.lookup(jndiHomeName);
this.cacheMap.put(jndiHomeName, obj);
}
} catch (NamingException ne) {
ne.printStackTrace();
throw new EnrgiseSystemException(ne);
}
return obj;
}
public EJBLocalHome getLocalHome(String jndiHomeName) throws EnrgiseSystemException {
System.out.println(String.valueOf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").concat(String.valueOf(jndiHomeName)));
EJBLocalHome home = null;
try {
Context context = myContextProvider.getLocalContext();
if (this.cacheMap.containsKey(jndiHomeName)) {
home = (EJBLocalHome)this.cacheMap.get(jndiHomeName);
} else {
home = (EJBLocalHome)context.lookup(String.valueOf("java:comp/env/").concat(String.valueOf(jndiHomeName)));
this.cacheMap.put(jndiHomeName, home);
}
} catch (NamingException ne) {
System.out.println(ne);
ne.printStackTrace();
throw new EnrgiseSystemException(ne);
} catch (Exception oEx) {
oEx.printStackTrace();
throw new EnrgiseSystemException(oEx);
}
return home;
}
}

View File

@@ -0,0 +1,44 @@
package wenrgise.ejb.common.utility;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class myContextProvider {
private Context ctx = null;
public static InitialContext localContext;
static {
try {
localContext = new InitialContext();
} catch (NamingException oNx) {
oNx.printStackTrace();
}
}
private static myContextProvider objContextProvider = new myContextProvider();
private myContextProvider() {
try {
Hashtable env = new Hashtable();
System.out.println("Test for ContextProvider -->");
env.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
env.put("java.naming.provider.url", "t3://weblogicServer:7001");
env.put("java.naming.security.principal", "weblogic");
env.put("java.naming.security.credentials", "weblogic");
this.ctx = new InitialContext();
} catch (Throwable e) {
e.printStackTrace();
}
}
public static Context getContext() {
return objContextProvider.ctx;
}
public static InitialContext getLocalContext() {
return localContext;
}
}

View File

@@ -0,0 +1,262 @@
package wenrgise.ejb.help.business;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Logger;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.help.bean.HelpChapterBean;
import wenrgise.help.bean.HelpComponentBean;
import wenrgise.help.bean.HelpContentBean;
import wenrgise.help.bean.HelpPartBean;
public class HelpBO {
public static Logger log = Logger.getLogger("wenrgise.ejb.common.business.HelpBO");
public ArrayList getComponentCodes(String sModuleName) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oComponents = null;
String sComp = null;
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sModuleName));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "HLPCONTENTDETAIL.proc_GetComponents(?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0)
oList = new ArrayList();
count = 0;
oIt = oList.iterator();
while (oIt.hasNext()) {
if (count == 0)
oComponents = new ArrayList();
count++;
oRow = oIt.next();
sComp = new String();
sComp = oRow.get("component_id").getString();
oComponents.add(sComp);
}
return oComponents;
}
public ArrayList getChapter(String sCompId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
HelpChapterBean oHelpChapterBean = null;
int count = 0;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oChapter = null;
String sChap = null;
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sCompId));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "HLPCONTENTDETAIL.proc_GetChapter(?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0) {
oList = new ArrayList();
oChapter = new ArrayList();
}
count = 0;
oIt = oList.iterator();
while (oIt.hasNext()) {
if (count == 0)
oChapter = new ArrayList();
count++;
oRow = oIt.next();
oHelpChapterBean = new HelpChapterBean();
oHelpChapterBean.setTxtChapId(oRow.get("id").getString());
oHelpChapterBean.setTxtHeading(oRow.get("heading").getString());
oHelpChapterBean.setTxtKeyword(oRow.get("keyword").getString());
oChapter.add(oHelpChapterBean);
}
return oChapter;
}
public ArrayList getPart(String sChapId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oParts = null;
String sPart = null;
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sChapId));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "HLPCONTENTDETAIL.proc_GetPart(?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0) {
oList = new ArrayList();
oParts = new ArrayList();
}
count = 0;
oIt = oList.iterator();
while (oIt.hasNext()) {
if (count == 0)
oParts = new ArrayList();
count++;
oRow = oIt.next();
sPart = new String();
sPart = oRow.get("id").getString();
oParts.add(sPart);
}
return oParts;
}
public ArrayList getModule(String sModName) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oCompList = null;
ArrayList oModule = null;
ArrayList oChapList = null;
ArrayList oPartList = null;
ArrayList oCompListDtl = null;
ArrayList oModuleDtl = null;
ArrayList oChapListDtl = null;
ArrayList oPartListDtl = null;
ArrayList oSubPartListDtl = null;
HelpChapterBean oHelpChapterBean = new HelpChapterBean();
HelpChapterBean oChapterBean = new HelpChapterBean();
HelpComponentBean oHelpComponentBean = new HelpComponentBean();
HelpPartBean oHelpPartBean = new HelpPartBean();
String sCompId = "";
String sChapId = "";
String sPartId = "";
String sPart = "";
String sPartHeading = "";
oCompList = getComponentCodes(sModName);
oCompListDtl = new ArrayList();
for (int i = 0; i < oCompList.size(); i++) {
sCompId = oCompList.get(i);
oHelpComponentBean = new HelpComponentBean();
oHelpComponentBean.setTxtComponentCode(sCompId);
oChapList = getChapter(sCompId);
oChapListDtl = new ArrayList();
for (int j = 0; j < oChapList.size(); j++) {
oChapterBean = oChapList.get(j);
sChapId = oChapterBean.getTxtChapId();
oHelpChapterBean = new HelpChapterBean();
oHelpChapterBean.setTxtHeading(oChapterBean.getTxtHeading());
oHelpChapterBean.setTxtChapId(oChapterBean.getTxtChapId());
oPartList = getPart(sChapId);
oPartListDtl = new ArrayList();
for (int k = 0; k < oPartList.size(); k++) {
sPartId = oPartList.get(k);
oHelpPartBean = new HelpPartBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sPartId));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 12));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "HLPCONTENTDETAIL.proc_GetPartDtl(?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0)
oSubPartListDtl = new ArrayList();
count = 0;
oIt = oList.iterator();
while (oIt.hasNext()) {
if (count == 0)
oSubPartListDtl = new ArrayList();
count++;
oRow = oIt.next();
sPart = new String();
sPartHeading = oRow.get("HEADING").getString();
sPart = oRow.get("CONTENT").getString();
oSubPartListDtl.add(sPart);
}
oHelpPartBean.setTxtHeading(sPartHeading);
oHelpPartBean.setArylstContent(oSubPartListDtl);
oPartListDtl.add(oHelpPartBean);
}
oHelpChapterBean.setArylstPart(oPartListDtl);
oChapListDtl.add(oHelpChapterBean);
}
oHelpComponentBean.setArylstChapter(oChapListDtl);
oCompListDtl.add(oHelpComponentBean);
}
return oCompListDtl;
}
public ArrayList getOneChapter(String sChapId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oPartList = null;
ArrayList oPartListDtl = null;
ArrayList oSubPartListDtl = null;
HelpPartBean oHelpPartBean = new HelpPartBean();
HelpContentBean oHelpContentBean = new HelpContentBean();
String sPartId = "";
String sPart = "";
String sPartHeading = "";
oPartList = getPart(sChapId);
oPartListDtl = new ArrayList();
for (int k = 0; k < oPartList.size(); k++) {
sPartId = oPartList.get(k);
oHelpPartBean = new HelpPartBean();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sPartId));
oParameters.add(new DBObject(2, 1, 12, sChapId));
oParameters.add(new DBObject(3, 2, -10));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "HLPCONTENTDETAIL.proc_GetPartDtl(?,?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0) {
oSubPartListDtl = new ArrayList();
} else {
count = 0;
oIt = oList.iterator();
while (oIt.hasNext()) {
if (count == 0)
oSubPartListDtl = new ArrayList();
count++;
oRow = oIt.next();
oHelpContentBean = new HelpContentBean();
sPartHeading = oRow.get("HEADING").getString();
oHelpContentBean.setTxtContents(oRow.get("CONTENT").getString());
oHelpContentBean.setTxtSecHeading(oRow.get("SECTION_NAME").getString());
oSubPartListDtl.add(oHelpContentBean);
}
oHelpPartBean.setTxtHeading(sPartHeading);
oHelpPartBean.setArylstContent(oSubPartListDtl);
oPartListDtl.add(oHelpPartBean);
}
}
return oPartListDtl;
}
}

View File

@@ -0,0 +1,65 @@
package wenrgise.ejb.help.business;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.business.BaseBO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.help.bean.SearchBean;
public class SearchBO extends BaseBO {
public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String sScreenMode) throws EnrgiseApplicationException, EnrgiseSystemException {
return null;
}
public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {}
public void saveDetailImpl(BaseHeaderBean oBaseHeaderBean, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {}
public void initializeBOImpl() {}
public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
public void additionalTimestampValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
public ArrayList getChapterDetails(String sText, String sModuleId) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
SearchBean oSearchBean = null;
QueryRow oRow = null;
QueryValue oValue = null;
ArrayList oList = null;
Iterator oIt = null;
ArrayList oChapterDetail = new ArrayList();
oParameters = new ArrayList();
oParameters.add(new DBObject(1, 1, 12, sModuleId));
oParameters.add(new DBObject(2, 1, 12, sText));
oParameters.add(new DBObject(3, 2, -10));
oParameters.add(new DBObject(4, 2, 12));
oParameters.add(new DBObject(5, 2, 12));
oParameters.add(new DBObject(6, 2, 4));
ArrayList oOutArray = oBean.callProc(oParameters, "ENRGISEHELP.PROC_GetChapters(?,?,?,?,?,?)");
oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
if (oList.size() == 0)
return new ArrayList();
oIt = oList.iterator();
while (oIt.hasNext()) {
oSearchBean = new SearchBean();
oRow = oIt.next();
oSearchBean.setChapterId(oRow.get("ID").getString());
oSearchBean.setChapterName(oRow.get("HEADING").getString());
oSearchBean.setTxtScreenName(oRow.get("KEYWORD").getString());
oChapterDetail.add(oSearchBean);
}
return oChapterDetail;
}
}

View File

@@ -0,0 +1,11 @@
package wenrgise.ejb.help.facade;
import java.rmi.RemoteException;
import java.util.ArrayList;
import javax.ejb.EJBObject;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
public interface HelpFacade extends EJBObject {
ArrayList getChapterList(String paramString1, String paramString2) throws RemoteException, EnrgiseSystemException, EnrgiseApplicationException;
}

View File

@@ -0,0 +1,25 @@
package wenrgise.ejb.help.facade;
import java.util.ArrayList;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.help.business.SearchBO;
public class HelpFacadeBean implements SessionBean {
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext ctx) {}
public ArrayList getChapterList(String sText, String sModuleId) throws EnrgiseSystemException, EnrgiseApplicationException {
SearchBO oSearchBO = new SearchBO();
return oSearchBO.getChapterDetails(sText, sModuleId);
}
}

View File

@@ -0,0 +1,9 @@
package wenrgise.ejb.help.facade;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelpFacadeHome extends EJBHome {
HelpFacade create() throws CreateException, RemoteException;
}