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,3 @@
package wenrgise.common.utility;
public class ArrayListUtil {}

View File

@@ -0,0 +1,39 @@
package wenrgise.common.utility;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ContextProvider {
private Context ctx = null;
public static InitialContext localContext;
static {
try {
localContext = new InitialContext();
} catch (NamingException oNx) {
oNx.printStackTrace();
}
}
private static ContextProvider objContextProvider = new ContextProvider();
private ContextProvider() {
try {
Hashtable env = new Hashtable();
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,151 @@
package wenrgise.common.utility;
import java.sql.Date;
import java.util.Calendar;
import java.util.StringTokenizer;
public class DateUtility {
public final int DATE = 1;
public final int MONTH = 2;
public final int YEAR = 3;
public String getSysDate() {
Calendar cal = Calendar.getInstance();
String sysDate = String.valueOf(String.valueOf(String.valueOf(String.valueOf(lPad(String.valueOf(cal.get(5)), 2)).concat(String.valueOf("/"))).concat(String.valueOf(lPad(String.valueOf(cal.get(2) + 1), 2)))).concat(String.valueOf("/"))).concat(String.valueOf(lPad(String.valueOf(cal.get(1)), 4)));
cal = null;
return sysDate;
}
public int dateDiff(String fromDate, String toDate) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(get(fromDate, 3)), Integer.parseInt(get(fromDate, 2)) - 1, Integer.parseInt(get(fromDate, 1)));
long fromDateInMilliSec = cal.getTime().getTime();
cal.set(Integer.parseInt(get(toDate, 3)), Integer.parseInt(get(toDate, 2)) - 1, Integer.parseInt(get(toDate, 1)));
long toDateInMilliSec = cal.getTime().getTime();
cal = null;
if (fromDateInMilliSec == toDateInMilliSec)
return 1;
int noOfDays = Math.abs((int)((toDateInMilliSec - fromDateInMilliSec) / 86400000L));
return noOfDays;
}
public int dateDiff1(String fromDate, String toDate) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(get(fromDate, 3)), Integer.parseInt(get(fromDate, 2)) - 1, Integer.parseInt(get(fromDate, 1)));
long fromDateInMilliSec = cal.getTime().getTime();
cal.set(Integer.parseInt(get(toDate, 3)), Integer.parseInt(get(toDate, 2)) - 1, Integer.parseInt(get(toDate, 1)));
long toDateInMilliSec = cal.getTime().getTime();
cal = null;
int noOfDays = Math.abs((int)((toDateInMilliSec - fromDateInMilliSec) / 86400000L));
return noOfDays;
}
public long dateDiffLong(String fromDate, String toDate) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(get(fromDate, 3)), Integer.parseInt(get(fromDate, 2)) - 1, Integer.parseInt(get(fromDate, 1)));
long fromDateInMilliSec = cal.getTime().getTime();
cal.set(Integer.parseInt(get(toDate, 3)), Integer.parseInt(get(toDate, 2)) - 1, Integer.parseInt(get(toDate, 1)));
long toDateInMilliSec = cal.getTime().getTime();
cal = null;
long noOfDaysInSec = (toDateInMilliSec - fromDateInMilliSec) / 1000L;
return noOfDaysInSec;
}
public int dateGTcurrent(String fromDate, String toDate) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(get(fromDate, 3)), Integer.parseInt(get(fromDate, 2)) - 1, Integer.parseInt(get(fromDate, 1)));
long fromDateInMilliSec = cal.getTime().getTime();
cal.set(Integer.parseInt(get(toDate, 3)), Integer.parseInt(get(toDate, 2)) - 1, Integer.parseInt(get(toDate, 1)));
long toDateInMilliSec = cal.getTime().getTime();
cal = null;
int noOfDays = (int)((toDateInMilliSec - fromDateInMilliSec) / 86400000L);
return noOfDays;
}
public String get(String inDate, int Type) {
String[] strArr = new String[4];
String retVal = "";
strArr = getDateArray(inDate);
switch (Type) {
case 3:
retVal = lPad(strArr[2], 4);
break;
case 2:
retVal = lPad(strArr[1], 2);
break;
case 1:
retVal = lPad(strArr[0], 2);
break;
}
return retVal;
}
public String reverseFormat(String tDate) {
String[] strArr = new String[4];
strArr = getDateArray(tDate);
return String.valueOf(String.valueOf(String.valueOf(String.valueOf(lPad(strArr[1], 2)).concat(String.valueOf("/"))).concat(String.valueOf(lPad(strArr[0], 2)))).concat(String.valueOf("/"))).concat(String.valueOf(lPad(strArr[2], 4)));
}
private String lPad(String inStr, int len) {
int count = len - inStr.length();
for (int i = 0; i < count; i++)
inStr = String.valueOf("0").concat(String.valueOf(inStr));
return inStr;
}
private String[] getDateArray(String tDate) {
int j = 0;
StringTokenizer strTok = new StringTokenizer(tDate, "/");
String[] strArr = new String[4];
if (strTok.countTokens() <= 0)
strTok = new StringTokenizer(tDate, "-");
while (strTok.hasMoreTokens()) {
strArr[j] = strTok.nextToken();
j++;
}
return strArr;
}
public long getDateLong(String tDate) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(get(tDate, 3)), Integer.parseInt(get(tDate, 2)) - 1, Integer.parseInt(get(tDate, 1)));
return cal.getTime().getTime();
}
public long[] months_between(String fromDate, String toDate) {
long[] retArr = new long[2];
retArr[0] = -1L;
retArr[1] = -1L;
long noOfDaysInSecs = dateDiffLong(fromDate, toDate);
double totNoOfDays = (noOfDaysInSecs / 86400L);
retArr[0] = (long)Math.floor(totNoOfDays / 30);
retArr[1] = Math.round(totNoOfDays % 30);
return retArr;
}
public long[] months_between1(String fromDate, String toDate) {
long[] retArr = new long[2];
retArr[0] = -1L;
retArr[1] = -1L;
long noOfDaysInSecs = dateDiffLong(fromDate, toDate);
double totNoOfDays = (noOfDaysInSecs / 86400L);
retArr[0] = (long)Math.floor(totNoOfDays / 30.4D);
retArr[1] = Math.round(totNoOfDays % 30);
return retArr;
}
public static void main(String[] args) {
DateUtility d = new DateUtility();
System.out.println(d.reverseFormat(d.getSysDate()));
System.out.println(d.dateDiff1("29/11/2003", "2/12/2003"));
System.out.println(d.dateDiff1("29/10/2003", "2/11/2003"));
d.getSysDate();
long[] retIntArr = d.months_between("12/12/2003", "28/12/2003");
System.out.println(String.valueOf(String.valueOf(retIntArr[0]).concat(String.valueOf("*****"))).concat(String.valueOf(retIntArr[1])));
Date d1 = new Date(d.getDateLong("29/11/2003"));
Date d2 = new Date(d.getDateLong("2/12/2003"));
System.out.println(d1.compareTo(d2));
}
}

View File

@@ -0,0 +1,44 @@
package wenrgise.common.utility;
import java.rmi.RemoteException;
import java.util.HashMap;
import javax.ejb.CreateException;
import javax.servlet.http.HttpSession;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.session.UserSession;
import wenrgise.ejb.common.session.UserSessionHome;
import wenrgise.ejb.common.utility.ServiceLocator;
import wenrgise.hrms.ejb.facade.HrmFacade;
import wenrgise.hrms.ejb.facade.HrmFacadeHome;
public class DebugHelper {
public static void createUserEjb(HttpSession session) throws EnrgiseSystemException {
try {
UserSession oUser = (UserSession)session.getAttribute(ParamUtil.getSessionBeanName());
if (oUser == null) {
UserSessionHome oUserHome = (UserSessionHome)ServiceLocator.getLocator().getService("HrmUserSession");
oUser = oUserHome.create();
UserInfo oUserInfo = new UserInfo();
oUserInfo.setSiteId("1");
oUserInfo.setModuleId("4");
oUserInfo.setUserId("8501000");
oUserInfo.setCurrentYear("2011");
oUserInfo.setUserName("HANS RAJ SHARMA");
oUser.setUserInfo(oUserInfo);
HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade");
HrmFacade oHrmFacade = oHome.create();
HashMap oMap = new HashMap();
oMap.put(ParamUtil.getModuleName(), oHrmFacade);
oUser.setModuleFacade(oMap);
session.setAttribute(ParamUtil.getSessionBeanName(), oUser);
}
} catch (RemoteException oRmt) {
throw new EnrgiseSystemException();
} catch (CreateException oCrt) {
throw new EnrgiseSystemException();
} catch (Exception oExCc) {
oExCc.printStackTrace();
throw new EnrgiseSystemException();
}
}
}

View File

@@ -0,0 +1,141 @@
package wenrgise.common.utility;
public final class EnrgiseConstants {
public static final String DATABASE_NAME = ParamUtil.getDBName();
public static final int INFINITE = -999;
public static final int GET_HEADER = 1;
public static final int GET_NEXT_ACTION = 2;
public static final int GET_PREVIOUS_ACTION = 3;
public static final int GET_FIRST_ACTION = 4;
public static final int GET_LAST_ACTION = 5;
public static final int GET_DETAIL_ACTION = 6;
public static final int GET_NEXT_DETAIL_ACTION = 7;
public static final int SAVE_ACTION = 8;
public static final int EXIT_APP = 9;
public static final int NEW_ACTION = 10;
public static final int QUERY_ACTION = 10;
public static final int GET_DETAIL_PAGE_ACTION = 11;
public static final int CLOSE_WINDOW = 12;
public static final int ON_LOAD_ACTION = 13;
public static final int ADD_ROW_ACTION = 14;
public static final int DELETE_ROW_ACTION = 15;
public static final int DECR_ACTION = 16;
public static final int DELETE_ACTION = 17;
public static final int GET_BUTTON_ACTION = 18;
public static final int REFRESH_ACTION = 19;
public static final int LOV_ACTION = 20;
public static final int VALIDATE_ACTION = 21;
public static final int GET_TAB_ACTION = 22;
public static final int GET_INSERT_ACTION = 23;
public static final String SUCCESS = "success";
public static final String ERROR = "E";
public static final String MESSAGE = "M";
public static final String BASE_HEADER_VO = "BaseHeaderVO";
public static final String BASE_QUERY_VO = "BaseQueryVO";
public static final String BASE_DETAIL_VO = "BaseDetailVO";
public static final String COMPONENTS_MAP = "Components";
public static final int HEADER_SIZE = 10;
public static final String NEW_MODE = "N";
public static final String UPDATE_MODE = "U";
public static final String DELETE_MODE = "D";
public static final String QUERY_MODE = "Q";
public static final String FIRST_LOAD = "LoadingFirst";
public static final String SEARCH_RECORD = "SearchRecords";
public static final String HIDDEN = "H";
public static final String VISIBLE = "V";
public static final String ENABLE = "E";
public static final String DISABLE = "D";
public static final String HEADER = "HEADER";
public static final String DETAIL = "DETAIL";
public static final String ALL = "ALL";
public static final String STATUS = "status";
public static final String NEW = "N";
public static final String APPROVED = "A";
public static final String REVISED = "V";
public static final String REJECTED = "R";
public static final String DRAFT = "D";
public static final String CLOSED = "C";
public static final String CANCELLED = "L";
public static final String FINALLY_APPROVED = "FinallyApproved";
public static final String NOTPRICED = "N";
public static final String PRICED = "P";
public static final String ACCOUNTED = "Y";
public static final int AFTER_DATE = 1;
public static final int DATE_ERROR = -2;
public static final int EQUAL_DATE = 0;
public static final int BEFORE_DATE = -1;
public static final String POSITIVE = "P";
public static final String NEGATIVE = "N";
public static final String NOTPOSITIVE = "NP";
public static final String NOTNEGATIVE = "NN";
public static final String USER_NAME = "wenrgise.common.user.name";
public static final String SITE_NAME = "wenrgise.common.site.name";
}

View File

@@ -0,0 +1,24 @@
package wenrgise.common.utility;
import java.rmi.RemoteException;
import javax.ejb.RemoveException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import wenrgise.ejb.common.session.UserSession;
public class EnrgiseListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent sEvent) {}
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,64 @@
package wenrgise.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) {
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,60 @@
package wenrgise.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.INFOClass;
import wenrgise.common.xml.vo.LOVClass;
import wenrgise.workflow.utility.WflDocParamsManager;
import wenrgise.workflow.xml.vo.WflDocParams;
public class EnrgisePlugIn implements PlugIn {
static final Logger log = Logger.getLogger("wenrgise.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 {
EnrgiseForms oEnrgiseForms = (EnrgiseForms)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.EnrgiseForms", calculatePath(servlet, this.formPathName));
EnrgiseManager.getInstance().init(oEnrgiseForms);
LOVClass oLOVClass = (LOVClass)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.LOVClass", calculatePath(servlet, this.pathName));
LOVManager.getInstance().init(oLOVClass);
EnrgiseApp oEnrgiseApp = (EnrgiseApp)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.EnrgiseApp", calculatePath(servlet, this.appPath));
EnrgiseManager.getInstance().setEnrApp(oEnrgiseApp);
WflDocParams oWflDocParams = (WflDocParams)FWXMLUtility.xmlToObject("wenrgise.workflow.xml.vo.WflDocParams", calculatePath(servlet, this.wflImplPathName));
WflDocParamsManager.getInstance().init(oWflDocParams);
INFOClass oINFOClass = (INFOClass)FWXMLUtility.xmlToObject("wenrgise.common.xml.vo.INFOClass", calculatePath(servlet, this.reportPathName));
StringBuffer woStringBuffer = new StringBuffer();
woStringBuffer.append(" rwserver server=peerless");
} 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,342 @@
package wenrgise.common.utility;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
public class EnrgiseUtil {
public static void pageArrayCopier(ArrayList oSource, ArrayList oDest, int iSourcePos, int iLength) throws EnrgiseSystemException {
if (oSource == null) {
System.out.println("Source array is null");
throw new EnrgiseSystemException();
}
if (oDest == null) {
System.out.println("Destination array is null");
throw new EnrgiseSystemException();
}
if (iLength < 0) {
System.out.println("Length should be positive");
return;
}
if (oSource.size() < iSourcePos + iLength) {
System.out.println("The source array is out of range");
return;
}
oDest.clear();
for (int iIndex = iSourcePos; iIndex < iSourcePos + iLength; iIndex++)
oDest.add(oSource.get(iIndex));
}
public static ArrayList addToList(ArrayList oList, Object[] obj) {
for (int i = 0; i < obj.length; i++)
oList.add(obj[i]);
return oList;
}
public static boolean checkString(String oInputString) {
if (oInputString == null)
return false;
String oString = new String(oInputString);
oString = oString.trim();
if (oString.equals(""))
return false;
return true;
}
public static int compareDates(DateFormat dateFormat, String sOrigDate, String sRefDate) throws EnrgiseSystemException {
if (!checkString(sOrigDate) || !checkString(sRefDate))
return -2;
if (null == dateFormat) {
dateFormat = DateFormat.getDateInstance(2);
dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
}
try {
Date origDate = dateFormat.parse(sOrigDate);
Date refDate = dateFormat.parse(sRefDate);
return compareDates(origDate, refDate);
} catch (ParseException oParEx) {
System.out.println(String.valueOf("Date comparison problem ").concat(String.valueOf(oParEx.getMessage())));
throw new EnrgiseSystemException();
}
}
public static int compareDates(Date origDate, Date refDate) {
if (null == origDate || null == refDate)
return -2;
if (origDate.equals(refDate))
return 0;
if (origDate.before(refDate))
return -1;
return 1;
}
public static int compareWithSysdate(Date origDate) throws EnrgiseSystemException {
return compareDates(origDate, getSysDate());
}
public static int compareWithSysdate(DateFormat dateFormat, String sOrigDate) throws EnrgiseSystemException {
if (!checkString(sOrigDate))
return -2;
if (null == dateFormat)
dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
try {
Date origDate = dateFormat.parse(sOrigDate);
return compareDates(origDate, getSysDate());
} catch (ParseException oParEx) {
System.out.println(String.valueOf("Date comparison problem ").concat(String.valueOf(oParEx.getMessage())));
throw new EnrgiseSystemException();
}
}
public static Date getSysDate() throws EnrgiseSystemException {
Date sysDate = null;
DBUtilitiesBean oBean = new DBUtilitiesBean();
ArrayList oList = oBean.executeQuery("SELECT sysdate FROM dual");
if (null != oList) {
QueryRow oRow = oList.get(0);
QueryValue oValue = oRow.get("sysDate");
return oValue.getDate();
}
return null;
}
public static Object setFieldValue(Object obj, String sItem, String sItemValue) throws EnrgiseSystemException {
try {
Class oClass = obj.getClass();
String sSetterMethod = getSetterMethodName(sItem);
String oStr = new String();
Class[] oCls = { oStr.getClass() };
Method oMethod = oClass.getMethod(sSetterMethod, oCls);
Object[] oParams = { sItemValue };
return oMethod.invoke(obj, oParams);
} catch (NoSuchMethodException oNsEx) {
throw new EnrgiseSystemException(oNsEx);
} catch (IllegalAccessException oIlEx) {
throw new EnrgiseSystemException(oIlEx);
} catch (InvocationTargetException oInEx) {
throw new EnrgiseSystemException(oInEx);
}
}
public static Object getFieldValue(Object obj, String sItem) throws EnrgiseSystemException {
try {
Class oClass = obj.getClass();
String sGetterMethod = getGetterMethodName(sItem);
Method oMethod = oClass.getMethod(sGetterMethod, null);
return oMethod.invoke(obj, null);
} catch (NoSuchMethodException oNsEx) {
throw new EnrgiseSystemException(oNsEx);
} catch (IllegalAccessException oIlEx) {
throw new EnrgiseSystemException(oIlEx);
} catch (InvocationTargetException oInEx) {
throw new EnrgiseSystemException(oInEx);
}
}
public static String getGetterMethodName(String sItem) {
String sFirstString = sItem.substring(0, 1);
String sRestString = sItem.substring(1);
String sFirst = sFirstString.toUpperCase();
return String.valueOf(String.valueOf("get").concat(String.valueOf(sFirst))).concat(String.valueOf(sRestString));
}
public static String getSetterMethodName(String sItem) {
String sFirstString = sItem.substring(0, 1);
String sRestString = sItem.substring(1);
String sFirst = sFirstString.toUpperCase();
return String.valueOf(String.valueOf("set").concat(String.valueOf(sFirst))).concat(String.valueOf(sRestString));
}
public static void checkDuplicate(ArrayList oList, String[] sItems, String sFieldKey, ArrayList oExceptionList) throws EnrgiseSystemException {
int index = 0;
Object[] oItemArray = null;
String[] oStatusArray = null;
ArrayList oRowList = new ArrayList();
int iSize = oList.size();
if (sItems != null) {
oItemArray = (Object[])Array.newInstance(Class.forName("java.lang.String"), iSize);
oStatusArray = (String[])Array.newInstance(Class.forName("java.lang.String"), iSize);
} else {
return;
}
if (null != sItems) {
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
Object obj = oIt.next();
oItemArray[index] = getAllFieldsValue(obj, sItems);
oStatusArray[index++] = (String)getFieldValue(obj, "status");
}
}
for (int iSource = 0; iSource < iSize; iSource++) {
if (null != oItemArray[iSource])
if (null == oStatusArray[iSource] || !oStatusArray[iSource].equals("D"))
for (int iTarget = iSource + 1; iTarget < iSize; iTarget++) {
if (null != oItemArray[iTarget])
if (null == oStatusArray || !oStatusArray[iTarget].equals("D"))
if (compareObject(oItemArray[iSource], oItemArray[iTarget])) {
ArrayList oArgList = new ArrayList();
Integer oRow = new Integer(iSource + 1);
if (null != sFieldKey) {
MessageKey oMessageKey = new MessageKey(sFieldKey);
oArgList.add(oMessageKey);
oArgList.add(oRow);
oExceptionList.add(new EnrgiseMessageKeyException("wenrgise.common.field.combinatonNotUnique", oArgList, "E"));
} else {
oArgList.add(oRow);
oExceptionList.add(new EnrgiseApplicationException("wenrgise.common.duplicatefound", oArgList, "E"));
}
}
}
}
}
public static void checkDuplicate(ArrayList oList, String sItem, String sFieldKey, ArrayList oExceptionList, boolean bCheckStatus) throws EnrgiseSystemException {
int index = 0;
Object[] oItemArray = null;
String[] oStatusArray = null;
if (null == oList)
return;
int iSize = oList.size();
if (null != sItem) {
oItemArray = (Object[])Array.newInstance(sItem.getClass(), iSize);
if (bCheckStatus)
oStatusArray = (String[])Array.newInstance(sItem.getClass(), iSize);
} else {
oItemArray = (Object[])Array.newInstance(oList.get(0).getClass(), iSize);
}
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
Object obj = oIt.next();
if (null != sItem) {
oItemArray[index] = getFieldValue(obj, sItem);
oStatusArray[index++] = (String)getFieldValue(obj, "status");
continue;
}
oItemArray[index++] = obj;
}
for (int iSource = 0; iSource < iSize; iSource++) {
if (null != oItemArray[iSource])
if (null == oStatusArray[iSource] || !oStatusArray[iSource].equals("D"))
for (int iTarget = iSource + 1; iTarget < iSize; iTarget++) {
if (null != oItemArray[iTarget])
if (null == oStatusArray || !oStatusArray[iTarget].equals("D"))
if (compareObject(oItemArray[iSource], oItemArray[iTarget])) {
ArrayList oArgList = new ArrayList();
Integer oRow = new Integer(iSource + 1);
if (null != sFieldKey) {
MessageKey oMessageKey = new MessageKey(sFieldKey);
oArgList.add(oMessageKey);
oArgList.add(oRow);
oExceptionList.add(new EnrgiseMessageKeyException("wenrgise.common.field.duplicatefound", oArgList, "E"));
} else {
oArgList.add(oRow);
oExceptionList.add(new EnrgiseApplicationException("wenrgise.common.duplicatefound", oArgList, "E"));
}
}
}
}
}
private static String getAllFieldsValue(Object obj, String[] sItems) throws EnrgiseSystemException {
String sValues = " ";
for (int i = 0; i < sItems.length; i++) {
String sValue = (String)getFieldValue(obj, sItems[i]);
if (null != sValue)
sValues = String.valueOf(sValues).concat(String.valueOf(sValue.trim()));
}
return sValues.trim();
}
private static boolean compareObject(Object oSource, Object oTarget) {
if (oSource.getClass().getName().equals("java.lang.String")) {
String sSource = ((String)oSource).trim();
String sTarget = ((String)oTarget).trim();
if (sSource.equalsIgnoreCase(sTarget))
return true;
} else if (oSource.equals(oTarget)) {
return true;
}
return false;
}
public static Timestamp convertToSqlDate(String sDate) throws EnrgiseSystemException {
if (!checkString(sDate))
return null;
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
try {
Date oDate = dateFormat.parse(sDate);
return new Timestamp(oDate.getTime());
} catch (ParseException oParEx) {
System.out.println(String.valueOf("Date comparison problem ").concat(String.valueOf(oParEx.getMessage())));
throw new EnrgiseSystemException();
}
}
public static String convertToString(Date oDate) {
return (null != oDate) ? (new SimpleDateFormat("dd-MMM-yyyy")).format(oDate) : null;
}
public static boolean checkNumber(String sInputValue, int iScale, int iPrecision, String sSign) {
String sLeft = null;
String sRight = null;
boolean bDecimal = false;
if (checkString(sInputValue)) {
String sVal = sInputValue.trim();
int iDecimalIndex = sVal.indexOf(".");
if (iDecimalIndex != -1) {
sLeft = sVal.substring(0, iDecimalIndex);
sRight = sVal.substring(iDecimalIndex + 1);
} else {
sLeft = sVal;
}
if (!sLeft.startsWith("+") && !sLeft.startsWith("-"))
sLeft = String.valueOf("+").concat(String.valueOf(sLeft));
if (iPrecision == 0 && iScale == 0)
return false;
try {
if (iPrecision == 0) {
long lVal = Long.parseLong(sVal);
if (sLeft.length() <= iScale + 1) {
if (Double.parseDouble(sLeft) == false && (sSign.equals("N") || sSign.equals("P")))
return false;
} else {
return false;
}
} else {
double d = Double.parseDouble(sVal);
}
} catch (NumberFormatException oNumEx) {
return false;
}
if (sLeft.length() > iScale + 1)
return false;
if (null != sRight)
if (sRight.length() > iPrecision)
return false;
if (null != sSign) {
if (sSign.equals("N") && !sLeft.startsWith("-"))
return false;
if (sSign.equals("P") && !sLeft.startsWith("+"))
return false;
if (sSign.equals("NN") && sLeft.startsWith("-"))
return false;
if (sSign.equals("NP") && sLeft.startsWith("+"))
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,111 @@
package wenrgise.common.utility;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.exception.EnrgiseSystemException;
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;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
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();
oLov.myFunc2();
}
private void myFunc() {
try {
String sDate = "12-JAN-1980";
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters.add(new DBObject(1, 1, 4, new Integer(2)));
oParameters.add(new DBObject(2, 1, 93, EnrgiseUtil.convertToSqlDate(sDate)));
oParameters.add(new DBObject(3, 2, 4));
oBean.callProc(oParameters, "BASU_AREA.proc_DateTester(?,?,?)");
System.out.println("Insert successfull");
} catch (EnrgiseSystemException oEx) {
System.out.println(String.valueOf("The problem is ").concat(String.valueOf(oEx.getMessage())));
}
}
private void myFunc2() {
try {
ArrayList oParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
oParameters.add(new DBObject(1, 1, 93, EnrgiseUtil.convertToSqlDate("12-JAN-1980")));
oParameters.add(new DBObject(2, 2, -10));
oParameters.add(new DBObject(3, 2, 4));
ArrayList oList2 = oBean.callProc(oParameters, "BASU_AREA.proc_DateTester2(?,?,?)");
DBObject oOutObject = oList2.get(0);
ArrayList oList = (ArrayList)oOutObject.getObject();
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
QueryRow oRow = oIt.next();
QueryValue oVal = oRow.get("ID");
String sId = oVal.getString();
QueryValue oVal2 = oRow.get("purchase_date");
String sDate = EnrgiseUtil.convertToString(oVal2.getDate());
System.out.println(String.valueOf(String.valueOf(String.valueOf(String.valueOf("ID is ").concat(String.valueOf(sId))).concat(String.valueOf(" "))).concat(String.valueOf("Purchase Date is "))).concat(String.valueOf(sDate)));
}
System.out.println("Fetch successfull");
} catch (EnrgiseSystemException oEx) {
System.out.println(String.valueOf("The problem is ").concat(String.valueOf(oEx.getMessage())));
}
}
}

View File

@@ -0,0 +1,21 @@
package wenrgise.common.utility;
import java.io.Serializable;
public class MessageKey implements Serializable {
private String key;
public MessageKey() {}
public MessageKey(String key) {
this.key = key;
}
public String getKey() {
return this.key;
}
public void setKey(String newKey) {
this.key = newKey;
}
}

View File

@@ -0,0 +1,94 @@
package wenrgise.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.ReportInfo;
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() {
return String.valueOf(getModuleName()).concat(String.valueOf("_UserSession"));
}
public static String getHeaderBean(String sFormName) {
HashedEnrgiseForms oHashedEnrgiseForms = EnrgiseManager.getInstance().getCachedObject(sFormName);
return oHashedEnrgiseForms.getSingleForm().get_HeaderBean();
}
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();
}
public static String getKeyinfo(String sMODULEname, String sJSPname, String sReportkey) {
ReportInfo oReportInfo = ReportManager.getInstance().getCachedObject(String.valueOf(String.valueOf(sMODULEname).concat(String.valueOf(sJSPname))).concat(String.valueOf(sReportkey)));
return oReportInfo.getReportKey();
}
}

View File

@@ -0,0 +1,26 @@
package wenrgise.common.utility;
import java.io.Serializable;
import java.sql.Timestamp;
public class RecordMetaInfo implements Serializable {
private Timestamp oWhenPicked = null;
private long recordCount = 0L;
public long getRecordCount() {
return this.recordCount;
}
public void setRecordCount(long newRecordCount) {
this.recordCount = newRecordCount;
}
public Timestamp getOWhenPicked() {
return this.oWhenPicked;
}
public void setOWhenPicked(Timestamp newOWhenPicked) {
this.oWhenPicked = newOWhenPicked;
}
}

View File

@@ -0,0 +1,58 @@
package wenrgise.common.utility;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.xml.vo.INFOClass;
import wenrgise.common.xml.vo.Module;
import wenrgise.common.xml.vo.Report;
import wenrgise.common.xml.vo.ReportInfo;
import wenrgise.common.xml.vo.Reports;
import wenrgise.common.xml.vo.ScreenInfo;
public class ReportManager {
private static ReportManager me;
private HashMap oMap = new HashMap();
public static ReportManager getInstance() {
if (me == null)
me = new ReportManager();
return me;
}
public ReportInfo getCachedObject(String name_) {
if (name_ == null || name_.trim().length() <= 0)
return null;
return (ReportInfo)this.oMap.get(name_);
}
public void init(INFOClass oINFOClass) {
if (oINFOClass == null)
return;
ArrayList oList = oINFOClass.get_Module();
Iterator oIt = oList.iterator();
while (oIt.hasNext()) {
Module oModule = oIt.next();
String sModuleName = oModule.get_ModuleName();
ArrayList oScreenInfoList = oModule.get_ScreenInfo();
Iterator oScreenInfoIt = oScreenInfoList.iterator();
while (oScreenInfoIt.hasNext()) {
ScreenInfo oScreenInfo = oScreenInfoIt.next();
String sScreenName = oScreenInfo.get_ScreenName();
Reports oReports = oScreenInfo.get_Reports();
ArrayList oReportList = oReports.get_Report();
Iterator oReportIt = oReportList.iterator();
while (oReportIt.hasNext()) {
Report oReport = oReportIt.next();
ReportInfo oReportInfo = new ReportInfo();
oReportInfo.setReportKey(oReport.get_ReportKey());
String sCombinedKey = String.valueOf(String.valueOf(sModuleName).concat(String.valueOf(sScreenName))).concat(String.valueOf(oReport.get_KeyInfo()));
System.out.println(String.valueOf("The key is ").concat(String.valueOf(sCombinedKey)));
if (!this.oMap.containsKey(sCombinedKey))
this.oMap.put(sCombinedKey, oReportInfo);
}
}
}
}
}

View File

@@ -0,0 +1,18 @@
package wenrgise.common.utility;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
public class ReportPlugin implements PlugIn {
private String reportPathName = "/WEB-INF/EnrgiseReport.xml";
public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {}
public void destroy() {}
private String calculatePath(ActionServlet servlet, String sPath) {
return servlet.getServletContext().getRealPath(sPath);
}
}

View File

@@ -0,0 +1,39 @@
package wenrgise.common.utility;
public class ReportReader {
String parameter;
String parameterValue;
public String getAppServerName() {
return "reportserver";
}
public String getAppServerPortNumber() {
return "8888";
}
public String getAppServerReportPathAlias() {
return "reports";
}
public String getStatsRep() {
return "statusKey";
}
public String getParameter() {
return this.parameter;
}
public void setParameter(String newParameter) {
this.parameter = newParameter;
}
public String getParameterValue() {
return this.parameterValue;
}
public void setParameterValue(String newParameterValue) {
this.parameterValue = newParameterValue;
}
}

View File

@@ -0,0 +1,83 @@
package wenrgise.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())) {
Context context = ContextProvider.getContext();
this.homeCache.put(jndiName.trim(), context.lookup(jndiName.trim()));
}
} 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 = ContextProvider.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 = ContextProvider.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,175 @@
package wenrgise.common.utility;
import java.io.Serializable;
public class UserInfo implements Serializable {
private String userSystemId;
private String userId;
private String siteId;
private String userType;
private String userTypeId;
private String userLocked;
private String userActiveFlag;
private String userName;
private String siteName;
private String currentYear;
private boolean superUser = false;
private String moduleId;
private String gradeId;
private String grade;
private String desigId;
private String designation;
private String siteCode;
public String getUserName() {
return this.userName;
}
public void setUserName(String newUserName) {
this.userName = newUserName;
}
public String getSiteName() {
return this.siteName;
}
public void setSiteName(String newSiteName) {
this.siteName = newSiteName;
}
public String getSiteId() {
return this.siteId;
}
public void setSiteId(String newSiteId) {
this.siteId = newSiteId;
}
public String getUserActiveFlag() {
return this.userActiveFlag;
}
public void setUserActiveFlag(String newUserActiveFlag) {
this.userActiveFlag = newUserActiveFlag;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String newUserId) {
this.userId = newUserId;
}
public String getUserLocked() {
return this.userLocked;
}
public void setUserLocked(String newUserLocked) {
this.userLocked = newUserLocked;
}
public String getUserSystemId() {
return this.userSystemId;
}
public void setUserSystemId(String newUserSystemId) {
this.userSystemId = newUserSystemId;
}
public String getUserType() {
return this.userType;
}
public void setUserType(String newUserType) {
this.userType = newUserType;
}
public String getUserTypeId() {
return this.userTypeId;
}
public void setUserTypeId(String newUserTypeId) {
this.userTypeId = newUserTypeId;
}
public String getCurrentYear() {
return this.currentYear;
}
public void setCurrentYear(String newCurrentYear) {
this.currentYear = newCurrentYear;
}
public boolean isSuperUser() {
return this.superUser;
}
public void setSuperUser(boolean newSuperUser) {
this.superUser = newSuperUser;
}
public String getModuleId() {
return this.moduleId;
}
public void setModuleId(String newModuleId) {
this.moduleId = newModuleId;
}
public String getGradeId() {
return this.gradeId;
}
public void setGradeId(String newGradeId) {
this.gradeId = newGradeId;
}
public String getGrade() {
return this.grade;
}
public void setGrade(String newGrade) {
this.grade = newGrade;
}
public String getDesigId() {
return this.desigId;
}
public void setDesigId(String newDesigId) {
this.desigId = newDesigId;
}
public String getDesignation() {
return this.designation;
}
public void setDesignation(String newDesignation) {
this.designation = newDesignation;
}
public String getSiteCode() {
return this.siteCode;
}
public void setSiteCode(String newSiteCode) {
this.siteCode = newSiteCode;
}
}

View File

@@ -0,0 +1,32 @@
package wenrgise.common.utility;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
public class WorkFlowContextProvider {
private Context ctx = null;
public static InitialContext localContext;
private static WorkFlowContextProvider objContextProvider = new WorkFlowContextProvider();
private WorkFlowContextProvider() {
try {
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put("java.naming.provider.url", "iiop://tcs093390:2811");
this.ctx = new InitialContext(env);
} catch (Throwable e) {
e.printStackTrace();
}
}
public static Context getContext() {
return objContextProvider.ctx;
}
public static InitialContext getLocalContext() {
return localContext;
}
}

View File

@@ -0,0 +1,35 @@
package wenrgise.common.utility;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
public class WorkFlowContextProvider2 {
private Context ctx = null;
public static InitialContext localContext;
private static WorkFlowContextProvider2 objContextProvider = new WorkFlowContextProvider2();
private WorkFlowContextProvider2() {
try {
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.evermind.server.rmi.RMIInitialContextFactory");
env.put("java.naming.security.principal", "admin");
env.put("dedicated.rmicontext", "true");
env.put("java.naming.security.credentials", "welcome");
env.put("java.naming.provider.url", "ormi://tcs041981:23892/current-workspace-app");
this.ctx = new InitialContext(env);
} catch (Throwable e) {
e.printStackTrace();
}
}
public static Context getContext() {
return objContextProvider.ctx;
}
public static InitialContext getLocalContext() {
return localContext;
}
}

View File

@@ -0,0 +1,61 @@
package wenrgise.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 WorkFlowServiceLocator {
private HashMap homeCache;
private final HashMap cacheMap = new HashMap();
private static WorkFlowServiceLocator serviceLocator = new WorkFlowServiceLocator();
private WorkFlowServiceLocator() {
try {
this.homeCache = new HashMap();
} catch (Throwable e) {
e.printStackTrace();
}
}
public static WorkFlowServiceLocator getLocator() {
return serviceLocator;
}
public Object getService(String jndiName) throws EnrgiseSystemException {
try {
if (!this.homeCache.containsKey(jndiName)) {
Context context = WorkFlowContextProvider.getContext();
this.homeCache.put(jndiName, context.lookup(jndiName));
}
} catch (NamingException oNa) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oNa.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oNa.getClass().getName())));
throw new EnrgiseSystemException(oNa);
} catch (Exception oEx) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oEx.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oEx.getClass().getName())));
throw new EnrgiseSystemException(oEx);
}
return this.homeCache.get(jndiName);
}
public EJBLocalHome getLocalHome(String jndiHomeName) throws EnrgiseSystemException {
EJBLocalHome home = null;
try {
jndiHomeName = jndiHomeName.trim();
Context context = WorkFlowContextProvider.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) {
ne.printStackTrace();
throw new EnrgiseSystemException(ne);
}
return home;
}
}

View File

@@ -0,0 +1,61 @@
package wenrgise.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 WorkFlowServiceLocator2 {
private HashMap homeCache;
private final HashMap cacheMap = new HashMap();
private static WorkFlowServiceLocator2 serviceLocator = new WorkFlowServiceLocator2();
private WorkFlowServiceLocator2() {
try {
this.homeCache = new HashMap();
} catch (Throwable e) {
e.printStackTrace();
}
}
public static WorkFlowServiceLocator2 getLocator() {
return serviceLocator;
}
public Object getService(String jndiName) throws EnrgiseSystemException {
try {
if (!this.homeCache.containsKey(jndiName)) {
Context context = WorkFlowContextProvider2.getContext();
this.homeCache.put(jndiName, context.lookup(jndiName));
}
} catch (NamingException oNa) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oNa.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oNa.getClass().getName())));
throw new EnrgiseSystemException(oNa);
} catch (Exception oEx) {
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oEx.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oEx.getClass().getName())));
throw new EnrgiseSystemException(oEx);
}
return this.homeCache.get(jndiName);
}
public EJBLocalHome getLocalHome(String jndiHomeName) throws EnrgiseSystemException {
EJBLocalHome home = null;
try {
jndiHomeName = jndiHomeName.trim();
Context context = WorkFlowContextProvider2.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) {
ne.printStackTrace();
throw new EnrgiseSystemException(ne);
}
return home;
}
}