90 lines
4.4 KiB
Java
90 lines
4.4 KiB
Java
package wenrgise.common.webtier.action;
|
|
|
|
import java.io.IOException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.util.ArrayList;
|
|
import java.util.Map;
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
import org.apache.struts.action.ActionForm;
|
|
import org.apache.struts.action.ActionForward;
|
|
import org.apache.struts.action.ActionMapping;
|
|
import wenrgise.common.bean.BaseHeaderBean;
|
|
import wenrgise.common.businessdelegate.BaseBD;
|
|
import wenrgise.common.businessdelegate.SecurityBD;
|
|
import wenrgise.common.exception.EnrgiseApplicationException;
|
|
import wenrgise.common.exception.EnrgiseSystemException;
|
|
import wenrgise.common.vo.BaseDetailVO;
|
|
import wenrgise.common.vo.ThisPageVO;
|
|
import wenrgise.common.webtier.form.BaseForm;
|
|
import wenrgise.ejb.common.session.UserSession;
|
|
import wenrgise.ejb.common.utility.ParamUtil;
|
|
|
|
public class GetDetailAction extends BaseAction {
|
|
public ActionForward executeImpl(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws EnrgiseApplicationException, EnrgiseSystemException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException, ServletException, IOException {
|
|
BaseForm oBaseForm = (BaseForm)form;
|
|
if (oBaseForm.getScreenMode().equals("N"))
|
|
throw new EnrgiseApplicationException("wenrgise.common.saveheaderrecord", "M");
|
|
if (oBaseForm.isHeaderDataChanged() || oBaseForm.isDetailDataChanged())
|
|
throw new EnrgiseApplicationException("wenrgise.common.datashouldbesaved", "M");
|
|
String sFormName = form.getClass().getName();
|
|
UserSession oUser = getUserSessionBean(request);
|
|
BaseBD oBaseBD = getDetailBusinessDelegate(form, request);
|
|
String sScreenName = oBaseForm.getScreenName();
|
|
BaseDetailVO oBaseDetailVO = getDetailData(oBaseForm, sFormName, sScreenName, 1L, request, oBaseBD, true, oUser);
|
|
if (oBaseDetailVO.getOThisPageData() != null)
|
|
oBaseForm.setScreenMode("U");
|
|
long totDetRecord = oBaseDetailVO.getTotalDetailRecord();
|
|
oBaseForm.setTotalPageCount(calculateTotalDetailPage(sFormName, sScreenName, totDetRecord));
|
|
ArrayList oClicked = getDetailClicked();
|
|
ArrayList oEnableList = new ArrayList();
|
|
oEnableList.add("butAddRow");
|
|
if (totDetRecord == 0L) {
|
|
oBaseForm.setPageRequested(0L);
|
|
oClicked.add("butDelRow");
|
|
} else {
|
|
oEnableList.add("butDelRow");
|
|
oEnableList.add("butSave");
|
|
}
|
|
enableDisable(oBaseForm, oClicked, "D");
|
|
enableDisable(oBaseForm, oEnableList, "E");
|
|
controlDetailNavigation(oBaseForm);
|
|
SecurityBD oSecBD = new SecurityBD();
|
|
Map oSecMap = oSecBD.getDisabledFields(String.valueOf(oBaseForm.getScreenName()).concat(String.valueOf(".jsp")), "DETAIL", oBaseForm.getScreenMode(), oBaseForm.getHeaderStatus());
|
|
if (null != oSecMap) {
|
|
if (null != oSecMap.get("D"))
|
|
enableDisable(oBaseForm, (ArrayList)oSecMap.get("D"), "D");
|
|
if (null != oSecMap.get("E"))
|
|
enableDisable(oBaseForm, (ArrayList)oSecMap.get("E"), "E");
|
|
}
|
|
BaseHeaderBean oBaseHeaderBean = getBaseHeaderBean(sFormName);
|
|
BeanUtils.copyProperties(oBaseHeaderBean, form);
|
|
ThisPageVO oThisPageVO = new ThisPageVO();
|
|
oThisPageVO.setOHeaderBean(oBaseHeaderBean);
|
|
oThisPageVO.setScreenMode(oBaseForm.getScreenMode());
|
|
oThisPageVO.setScreenName(oBaseForm.getScreenName());
|
|
oThisPageVO.setActionName(6);
|
|
oBaseDetailVO = oUser.getBaseDetailVO(sFormName, oBaseForm.getScreenName());
|
|
if (null != oBaseDetailVO) {
|
|
ArrayList oDetailList = (oBaseDetailVO.getOThisPageData() != null) ? oBaseDetailVO.getOThisPageData() : new ArrayList();
|
|
oThisPageVO.setODetailList(oDetailList);
|
|
}
|
|
Map oMap = oBaseBD.getDisabledFields(oThisPageVO);
|
|
if (oMap != null) {
|
|
if (oMap.containsKey("D"))
|
|
enableDisable(oBaseForm, (ArrayList)oMap.get("D"), "D");
|
|
if (oMap.containsKey("E"))
|
|
enableDisable(oBaseForm, (ArrayList)oMap.get("E"), "E");
|
|
}
|
|
if (oThisPageVO.getODetailList() != null) {
|
|
oBaseForm.setThisPageDetailCount(oThisPageVO.getODetailList().size());
|
|
BeanUtils.setProperty(oBaseForm, ParamUtil.getDetailArrayName(sFormName, sScreenName), oThisPageVO.getODetailList());
|
|
}
|
|
onLoad(form, request, 6);
|
|
oUser.setForwardedPage(sFormName, "success");
|
|
return mapping.findForward("success");
|
|
}
|
|
}
|