first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package WEB-INF.classes.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 wenrgise.common.utility.ContextProvider objContextProvider = new wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package WEB-INF.classes.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.common.utility.ParamUtil;
|
||||
import wenrgise.common.utility.UserInfo;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package WEB-INF.classes.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 wenrgise.common.utility.EnrgiseManager me;
|
||||
|
||||
private HashMap oEnrgiseMap = new HashMap();
|
||||
|
||||
private HashMap appMap = new HashMap();
|
||||
|
||||
public static wenrgise.common.utility.EnrgiseManager getInstance() {
|
||||
if (me == null)
|
||||
me = new wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package WEB-INF.classes.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.utility.EnrgiseManager;
|
||||
import wenrgise.common.utility.LOVManager;
|
||||
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;
|
||||
}
|
||||
}
|
343
hrmsWeb/WEB-INF/classes/wenrgise/common/utility/EnrgiseUtil.java
Normal file
343
hrmsWeb/WEB-INF/classes/wenrgise/common/utility/EnrgiseUtil.java
Normal file
@@ -0,0 +1,343 @@
|
||||
package WEB-INF.classes.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.common.utility.MessageKey;
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package WEB-INF.classes.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package WEB-INF.classes.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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package WEB-INF.classes.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
package WEB-INF.classes.wenrgise.common.utility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.ejb.EJBLocalHome;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import wenrgise.common.exception.EnrgiseSystemException;
|
||||
import wenrgise.common.utility.ContextProvider;
|
||||
|
||||
public class ServiceLocator {
|
||||
private HashMap homeCache;
|
||||
|
||||
private final HashMap cacheMap = new HashMap();
|
||||
|
||||
private static wenrgise.common.utility.ServiceLocator serviceLocator = new wenrgise.common.utility.ServiceLocator();
|
||||
|
||||
private ServiceLocator() {
|
||||
try {
|
||||
this.homeCache = new HashMap();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
175
hrmsWeb/WEB-INF/classes/wenrgise/common/utility/UserInfo.java
Normal file
175
hrmsWeb/WEB-INF/classes/wenrgise/common/utility/UserInfo.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package WEB-INF.classes.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package WEB-INF.classes.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 wenrgise.common.utility.WorkFlowContextProvider objContextProvider = new wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package WEB-INF.classes.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 wenrgise.common.utility.WorkFlowContextProvider2 objContextProvider = new wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package WEB-INF.classes.wenrgise.common.utility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.ejb.EJBLocalHome;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import wenrgise.common.exception.EnrgiseSystemException;
|
||||
import wenrgise.common.utility.WorkFlowContextProvider;
|
||||
|
||||
public class WorkFlowServiceLocator {
|
||||
private HashMap homeCache;
|
||||
|
||||
private final HashMap cacheMap = new HashMap();
|
||||
|
||||
private static wenrgise.common.utility.WorkFlowServiceLocator serviceLocator = new wenrgise.common.utility.WorkFlowServiceLocator();
|
||||
|
||||
private WorkFlowServiceLocator() {
|
||||
try {
|
||||
this.homeCache = new HashMap();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package WEB-INF.classes.wenrgise.common.utility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.ejb.EJBLocalHome;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import wenrgise.common.exception.EnrgiseSystemException;
|
||||
import wenrgise.common.utility.WorkFlowContextProvider2;
|
||||
|
||||
public class WorkFlowServiceLocator2 {
|
||||
private HashMap homeCache;
|
||||
|
||||
private final HashMap cacheMap = new HashMap();
|
||||
|
||||
private static wenrgise.common.utility.WorkFlowServiceLocator2 serviceLocator = new wenrgise.common.utility.WorkFlowServiceLocator2();
|
||||
|
||||
private WorkFlowServiceLocator2() {
|
||||
try {
|
||||
this.homeCache = new HashMap();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static wenrgise.common.utility.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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user