com.wabacus.system.ReportRequest.java Source code

Java tutorial

Introduction

Here is the source code for com.wabacus.system.ReportRequest.java

Source

/* 
 * Copyright (C) 2010---2014 (wuweixing)<349446658@qq.com>
 * 
 * This file is part of Wabacus 
 * 
 * Wabacus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.wabacus.system;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wabacus.config.Config;
import com.wabacus.config.component.IComponentConfigBean;
import com.wabacus.config.component.application.IApplicationConfigBean;
import com.wabacus.config.component.application.report.AbsReportDataPojo;
import com.wabacus.config.component.application.report.ColBean;
import com.wabacus.config.component.application.report.ReportBean;
import com.wabacus.config.component.container.page.PageBean;
import com.wabacus.config.database.type.AbsDatabaseType;
import com.wabacus.config.dataexport.AbsDataExportBean;
import com.wabacus.config.dataexport.DataExportLocalStroageBean;
import com.wabacus.config.dataexport.PDFExportBean;
import com.wabacus.config.print.DefaultPrintProviderConfigBean;
import com.wabacus.exception.WabacusRuntimeException;
import com.wabacus.system.assistant.AuthorizationAssistant;
import com.wabacus.system.assistant.FilePathAssistant;
import com.wabacus.system.assistant.WabacusAssistant;
import com.wabacus.system.component.IComponentType;
import com.wabacus.system.component.application.report.abstractreport.AbsListReportType;
import com.wabacus.system.component.application.report.abstractreport.AbsReportType;
import com.wabacus.system.component.application.report.abstractreport.IEditableReportType;
import com.wabacus.system.component.application.report.abstractreport.configbean.AbsListReportBean;
import com.wabacus.system.component.application.report.abstractreport.configbean.AbsListReportDisplayBean;
import com.wabacus.system.component.application.report.abstractreport.configbean.AbsListReportFilterBean;
import com.wabacus.system.component.application.report.configbean.editablereport.EditableReportSqlBean;
import com.wabacus.system.component.container.AbsContainerType;
import com.wabacus.system.component.container.page.PageType;
import com.wabacus.system.dataset.update.transaction.ITransactionType;
import com.wabacus.system.dataset.update.transaction.TransactionTypeWrapper;
import com.wabacus.system.inputbox.AbsInputBox;
import com.wabacus.system.intercept.AbsPageInterceptor;
import com.wabacus.system.permission.ComponentPermissionBean;
import com.wabacus.system.serveraction.UpdateComponentDataServerActionBean;
import com.wabacus.util.Consts;
import com.wabacus.util.Consts_Private;
import com.wabacus.util.Tools;
import com.wabacus.util.UniqueArrayList;

public class ReportRequest {
    private final static Log log = LogFactory.getLog(ReportRequest.class);

    private HttpServletRequest request;

    private PageBean pagebean;

    private List<IComponentConfigBean> lstComponentBeans;

    private String pageskin;

    private List<ReportBean> lstAllReportBeans;

    private List<String> lstApplicationIds;

    private Map<String, String> mReportidsInPdfTemplate;//PDFPDF????PDF??

    private Map<String, CacheDataBean> mCacheDataBeans = new HashMap<String, CacheDataBean>();

    private Map attributes = new HashMap();

    private Map<String, IComponentType> mComponentTypeObjs;

    private WabacusResponse wresponse;

    private Map<String, Connection> connections = new HashMap<String, Connection>();

    private Map<String, AbsDatabaseType> mDbTypes = new HashMap<String, AbsDatabaseType>();

    private int showtype;

    private PageType pageObj;

    private String url;

    private List<String> lstAncestorUrls;//URL??0URL???1URL??

    private String actiontype = Consts.SHOWREPORT_ACTION;

    private String locallanguage;

    private List<Statement> lstAllUsedStatement = new ArrayList<Statement>();

    private ReportBean slaveReportBean;

    private AbsReportType slaveReportTypeObj;

    private IComponentConfigBean refreshComponentBean;

    private IComponentType refreshComponentTypeObj;//

    private Map<String, ComponentPermissionBean> mComponentsPermissions;

    private List<AbsPageInterceptor> lstPageInterceptors;

    private List<String> lstSearchReportIds;

    private UpdateComponentDataServerActionBean serverActionBean;

    private Map<String, Set<String>> mShouldAddToUrlAttriuteNames = null;//rrequest.setAttribute(name,value)??URL????KEYID?URL???

    private TransactionTypeWrapper transactionWrapper = null;

    private Map<String, String> mTransactionLevels;

    private List<String> lstReportWithDefaultSelectedRows;

    private Map<String, String> mServerValidateDatas;

    public ReportRequest(HttpServletRequest request, int _showtype) {
        this.locallanguage = request.getLocale().getLanguage();
        if (this.locallanguage == null || this.locallanguage.trim().toLowerCase().equals("en")) {
            this.locallanguage = "";
        } else {
            this.locallanguage = this.locallanguage.trim().toLowerCase();
        }
        Enumeration enume = request.getAttributeNames();
        while (enume.hasMoreElements()) {
            String name = (String) enume.nextElement();
            Object value = request.getAttribute(name);
            if (value != null) {
                if (this.attributes.containsKey(name)) {
                    log.warn("request attribute????" + name + "?");
                }
                this.attributes.put(name, value);
            }
        }

        Enumeration enumer = request.getParameterNames();
        while (enumer.hasMoreElements()) {
            String name = (String) enumer.nextElement();
            if (name != null && !name.trim().equals("")) {
                if (this.attributes.containsKey(name)) {
                    log.warn("request????" + name + "?");
                }
                String[] values = request.getParameterValues(name);
                if (values == null) {
                    this.attributes.put(name, null);
                } else if (values.length == 1) {
                    this.attributes.put(name, values[0]);
                } else {
                    this.attributes.put(name, values);
                }

            }
        }
        this.showtype = _showtype;
        this.request = request;
        request.setAttribute("WX_REPORTREQUEST", this);
        this.actiontype = Tools.getRequestValue(request, "ACTIONTYPE", Consts.SHOWREPORT_ACTION);
    }

    public ReportRequest(String pageid, int _showtype, Locale locale) {
        if (locale == null) {
            this.locallanguage = "";
        } else {
            this.locallanguage = locale.getLanguage();
            if (this.locallanguage == null || this.locallanguage.trim().toLowerCase().equals("en")) {
                this.locallanguage = "";
            } else {
                this.locallanguage = this.locallanguage.trim().toLowerCase();
            }
        }
        this.showtype = _showtype;
        //init(pageid,null);
    }

    public void initGetFilterDataList() {
        initReportCommon();
        ReportBean rbean = this.lstAllReportBeans.get(0);
        rbean.getSbean().initConditionValues(this);
        setFilterCondition(rbean);
    }

    private AbsInputBox autoCompleteSourceInputBoxObj;

    public AbsInputBox getAutoCompleteSourceInputBoxObj() {
        return autoCompleteSourceInputBoxObj;
    }

    public void initGetAutoCompleteColValues() {
        initReportCommon();
        String inputboxid = this.getStringAttribute("INPUTBOXID", "");
        if (inputboxid.equals("")) {
            throw new WabacusRuntimeException(
                    "??ID??");
        }
        if (inputboxid.indexOf("__") > 0)
            inputboxid = inputboxid.substring(0, inputboxid.lastIndexOf("__"));
        autoCompleteSourceInputBoxObj = this.lstAllReportBeans.get(0).getInputboxWithAutoComplete(inputboxid);
        if (autoCompleteSourceInputBoxObj == null) {
            throw new WabacusRuntimeException("??ID" + inputboxid
                    + "??");
        }
    }

    public void initGetChartDataString() {
        initReportCommon();
        this.lstAllReportBeans.get(0).getSbean().initConditionValues(this);
    }

    public void initReportCommon() {
        String pageid = getStringAttribute("PAGEID", "");
        String reportid = getStringAttribute("REPORTID", "");
        pageid = pageid == null ? "" : pageid.trim();
        reportid = reportid == null ? "" : reportid.trim();
        if (pageid.equals("")) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?ID?", null, true);
        }
        this.pagebean = Config.getInstance().getPageBean(pageid);
        if (pagebean == null) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("??ID" + pageid + "", null,
                    true);
        }
        if (reportid == null || reportid.equals("")) {
            this.wresponse.getMessageCollector().warn("?ID", null, true);
        }
        lstAllReportBeans = new ArrayList<ReportBean>();
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector()
                    .warn("?" + pageid + "?ID" + reportid + "", null, true);
        }
        lstAllReportBeans.add(rbean);
        this.url = "";
    }

    public void initGetSelectBoxDataList() {
        String pageid = getStringAttribute("PAGEID", "");
        pageid = pageid == null ? "" : pageid.trim();
        if (pageid.equals("")) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?ID?", null, true);
        }
        this.pagebean = Config.getInstance().getPageBean(pageid);
        if (pagebean == null) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("??ID" + pageid + "", null,
                    true);
        }
        this.url = "";
    }

    public void init(String pageid) {
        pageid = pageid == null ? "" : pageid.trim();
        if (pageid.equals("")) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?ID?", null, true);
        }
        this.pagebean = Config.getInstance().getPageBean(pageid);
        if (pagebean == null) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("??ID" + pageid + "", null,
                    true);
        }
        if (this.showtype == Consts.DISPLAY_ON_PAGE) {
            if (Config.showreport_onpage_url.indexOf("?") > 0) {
                url = Config.showreport_onpage_url + "&";
            } else {
                url = Config.showreport_onpage_url + "?";
            }
            url = url + "PAGEID=" + pageid;
        }
        this.pageObj = (PageType) pagebean.createComponentTypeObj(this, null);
        lstPageInterceptors = new ArrayList<AbsPageInterceptor>();
        lstPageInterceptors.addAll(Config.getInstance().getLstGlobalPageInterceptors(pageid));
        lstPageInterceptors.addAll(pagebean.getLstInterceptors());
        for (AbsPageInterceptor interceptorTmp : lstPageInterceptors) {
            interceptorTmp.doStart(this);
        }
        this.pageskin = Config.getInstance().getSkin(this.request, this.pagebean);//?doStart()???doStart()?
        if (this.showtype == Consts.DISPLAY_ON_PAGE) {
            initDisplayOnPage(pageid);
        } else {
            initNonDisplayOnPage();
        }
    }

    private void initDisplayOnPage(String pageid) {
        UpdateComponentDataServerActionBean.initServerActionBean(this);
        String ancestorUrls = getStringAttribute("ancestorPageUrls", "");
        if (!ancestorUrls.equals("")) {
            this.lstAncestorUrls = Tools.parseStringToList(ancestorUrls, "||", false);
        }
        String slaveid = this.getStringAttribute("SLAVE_REPORTID", "");
        if (!slaveid.equals("")) {
            initSlaveReport(slaveid);
        } else {
            String refreshComponentGuid = this.getStringAttribute("refreshComponentGuid", "");
            if (!this.isLoadedByAjax() || refreshComponentGuid.equals("")
                    || this.pagebean.getId().equals(refreshComponentGuid)) {
                this.refreshComponentBean = this.pagebean;
                refreshComponentTypeObj = pageObj;
            } else {
                if (refreshComponentGuid.startsWith("[DYNAMIC]")) {//???guid?ID??ID??????
                    String refreshId = getDynamicRefreshIdOfAllComponents(refreshComponentGuid);
                    String refreshSlaveReportid = null;
                    if (!refreshId.equals(pagebean.getId())) {
                        IComponentConfigBean refreshCcbTmp = pagebean.getChildComponentBean(refreshId, true);
                        if (refreshCcbTmp instanceof ReportBean) {
                            if (((ReportBean) refreshCcbTmp).isSlaveReportDependsonListReport()) {
                                refreshSlaveReportid = refreshCcbTmp.getId();
                            }
                        }
                    }
                    if (refreshSlaveReportid == null || refreshSlaveReportid.trim().equals("")) {
                        initCommonComponent(refreshId);
                        this.wresponse.setDynamicRefreshComponentGuid(refreshComponentBean.getGuid(), null);
                    } else {
                        initSlaveReport(refreshSlaveReportid);
                        this.wresponse.setDynamicRefreshComponentGuid(refreshComponentBean.getGuid(),
                                refreshSlaveReportid);
                        return;
                    }
                } else {
                    if (!refreshComponentGuid.startsWith(pagebean.getId() + Consts_Private.GUID_SEPERATOR)) {
                        this.wresponse.setStatecode(Consts.STATECODE_FAILED);
                        log.warn("GUID" + refreshComponentGuid + "??");
                        this.wresponse.getMessageCollector().warn("?", null, true);
                    }
                    initCommonComponent(refreshComponentGuid
                            .substring((pagebean.getId() + Consts_Private.GUID_SEPERATOR).length()).trim());
                }
            }
            pageObj.initUrl(pagebean, this);
            if (refreshComponentTypeObj instanceof AbsReportType) {//???
                lstAllReportBeans = new ArrayList<ReportBean>();
                lstAllReportBeans.add((ReportBean) refreshComponentBean);
                ((AbsReportType) refreshComponentTypeObj).init();
                ((AbsReportType) refreshComponentTypeObj).loadReportData(true);
            } else if (refreshComponentTypeObj instanceof AbsContainerType) {
                this.lstAllReportBeans = ((AbsContainerType) refreshComponentTypeObj).initDisplayOnPage();
            } else {

            }
        }
    }

    private String getDynamicRefreshIdOfAllComponents(String refreshComponentGuid) {
        String componentIds = refreshComponentGuid.substring("[DYNAMIC]".length()).trim();
        if (componentIds.equals("")) {
            log.warn("?refreshComponentGuid" + refreshComponentGuid);
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?", null, true);
        }
        List<String> lstComponentids = Tools.parseStringToList(componentIds, ";", false);
        String refreshId = null;
        IComponentConfigBean ccbTmp;
        for (String cidTmp : lstComponentids) {
            if (cidTmp == null || cidTmp.trim().equals(""))
                continue;
            if (cidTmp.equals(pagebean.getId())) {
                refreshId = pagebean.getId();
                break;
            }
            ccbTmp = pagebean.getChildComponentBean(cidTmp, true);
            if (ccbTmp == null) {
                log.warn("?" + pagebean.getId() + "?ID" + cidTmp + "");
                this.wresponse.setStatecode(Consts.STATECODE_FAILED);
                this.wresponse.getMessageCollector().warn("?", null, true);
            }
            if (refreshId == null || refreshId.equals("")) {//?
                refreshId = ccbTmp.getRefreshid();
            } else {
                refreshId = pagebean.getCommonRefreshIdOfComponents(refreshId, ccbTmp.getRefreshid());
                if (refreshId.equals(pagebean.getId()))
                    break;
            }
        }
        if (refreshId == null || refreshId.trim().equals("")) {
            log.warn("??" + refreshComponentGuid + "??ID");
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?", null, true);
        }
        return refreshId;
    }

    private void initCommonComponent(String refreshComponentid) {
        if (refreshComponentid.equals("") || refreshComponentid.equals(pagebean.getId())) {
            this.refreshComponentBean = this.pagebean;
            refreshComponentTypeObj = pageObj;
        } else {
            this.refreshComponentBean = this.pagebean.getChildComponentBean(refreshComponentid, true);
            if (refreshComponentBean == null) {
                log.warn("?ID" + refreshComponentid + "");
                this.wresponse.setStatecode(Consts.STATECODE_FAILED);
                wresponse.getMessageCollector().warn("?", null, true);
            }
            refreshComponentTypeObj = getComponentTypeObj(refreshComponentBean, null, true);
        }
    }

    private void initSlaveReport(String slaveid) {
        this.slaveReportBean = this.pagebean.getReportChild(slaveid, true);
        if (slaveReportBean == null) {
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            wresponse.getMessageCollector().warn("?ID" + slaveid + "", null, true);
        }
        slaveReportTypeObj = (AbsReportType) getComponentTypeObj(slaveReportBean, null, true);
        slaveReportTypeObj.initUrl(slaveReportBean, this);
        slaveReportTypeObj.init();
        slaveReportTypeObj.loadReportData(true);
        lstAllReportBeans = new ArrayList<ReportBean>();
        lstAllReportBeans.add(slaveReportBean);
        this.refreshComponentBean = slaveReportBean;
    }

    private boolean dataexport_localstroageautodelete;

    private String dataexport_localstroagedirectorydateformat;

    private boolean dataexport_localstroagedownload;

    private boolean dataexport_localstroagezip;

    private String dataExportFilepath;

    private String dataExportFileurl;

    private boolean isExportToLocalFile;

    public boolean isDataexport_localstroagedownload() {
        return dataexport_localstroagedownload;
    }

    public boolean isDataexport_localstroagezip() {
        return dataexport_localstroagezip;
    }

    public boolean isExportToLocalFile() {
        return isExportToLocalFile;
    }

    public String getDataExportFilepath() {
        return dataExportFilepath;
    }

    public String getDataExportFileurl() {
        return dataExportFileurl;
    }

    public void setDataExportFilepath(String dataExportFilepath) {
        this.dataExportFilepath = dataExportFilepath;
    }

    public void setDataExportFileurl(String dataExportFileurl) {
        this.dataExportFileurl = dataExportFileurl;
    }

    private void initNonDisplayOnPage() {
        String comids = this.getStringAttribute("COMPONENTIDS", "");
        String applicationids = this.getStringAttribute("INCLUDE_APPLICATIONIDS", "");
        if (comids.equals("")) {
            log.warn("?" + this.pagebean.getId()
                    + "?/??ID");
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("??", null, true);
        }
        if (applicationids.trim().equals("")) {
            log.warn("??" + this.pagebean.getId() + "??");
            this.wresponse.setStatecode(Consts.STATECODE_FAILED);
            this.wresponse.getMessageCollector().warn("?", null, true);
        }
        this.lstComponentBeans = new ArrayList<IComponentConfigBean>();
        List<String> lstComids = new UniqueArrayList<String>();
        lstComids.addAll(Tools.parseStringToList(comids, ";", false));
        for (String comidTmp : lstComids) {
            if (comidTmp.equals(pagebean.getId())) {
                this.lstComponentBeans.add(pagebean);
            } else {
                this.lstComponentBeans.add(pagebean.getChildComponentBean(comidTmp, true));
            }
        }
        this.lstApplicationIds = new UniqueArrayList<String>();
        this.lstApplicationIds.addAll(Tools.parseStringToList(applicationids, ";", false));
        this.lstAllReportBeans = new UniqueArrayList<ReportBean>();
        IApplicationConfigBean appbeanTmp;
        for (String appidTmp : this.lstApplicationIds) {
            if (appidTmp == null || appidTmp.trim().equals(""))
                continue;
            appbeanTmp = pagebean.getApplicationChild(appidTmp, true);
            if (appbeanTmp == null) {
                log.warn("?" + this.pagebean.getId() + "?ID" + appidTmp + "");
                this.wresponse.setStatecode(Consts.STATECODE_FAILED);
                this.wresponse.getMessageCollector().warn("/??", null, true);
            }
            if (appbeanTmp instanceof ReportBean)
                lstAllReportBeans.add((ReportBean) appbeanTmp);
        }
        if (this.showtype == Consts.DISPLAY_ON_PDF) {//PDFPDF??pdf?PDF???
            this.mReportidsInPdfTemplate = new HashMap<String, String>();
            boolean ispdfprint = this.isPdfPrintAction();
            for (IComponentConfigBean ccbeanTmp : this.lstComponentBeans) {
                PDFExportBean pdfbeanTmp = null;
                if (ispdfprint) {
                    pdfbeanTmp = ccbeanTmp.getPdfPrintBean();
                } else if (ccbeanTmp.getDataExportsBean() != null) {
                    pdfbeanTmp = (PDFExportBean) ccbeanTmp.getDataExportsBean()
                            .getDataExportBean(Consts.DATAEXPORT_PDF);
                }
                if (pdfbeanTmp != null && pdfbeanTmp.getPdftemplate() != null
                        && !pdfbeanTmp.getPdftemplate().trim().equals("")) {
                    for (String appidTmp : pdfbeanTmp.getLstIncludeApplicationids()) {
                        this.mReportidsInPdfTemplate.put(appidTmp, "true");
                    }
                }
            }
        }
        if (this.showtype != Consts.DISPLAY_ON_PRINT
                && (this.showtype != Consts.DISPLAY_ON_PDF || !this.isPdfPrintAction())) {//???
            this.isExportToLocalFile = "true".equalsIgnoreCase(this.getStringAttribute("dataexport_localstroage"));
            if (this.isExportToLocalFile) {
                try {
                    this.dataexport_localstroagedirectorydateformat = URLDecoder
                            .decode(this.getStringAttribute("dataexport_localstroagedirectorydateformat"), "utf-8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                    this.dataexport_localstroagedirectorydateformat = this
                            .getStringAttribute("dataexport_localstroagedirectorydateformat");
                }
                this.dataexport_localstroageautodelete = !"false"
                        .equalsIgnoreCase(this.getStringAttribute("dataexport_localstroageautodelete"));
                this.dataexport_localstroagedownload = !"false"
                        .equalsIgnoreCase(this.getStringAttribute("dataexport_localstroagedownload"));
                this.dataexport_localstroagezip = "true"
                        .equalsIgnoreCase(this.getStringAttribute("dataexport_localstroagezip"));
            }
            if (!this.isExportToLocalFile && this.lstComponentBeans.size() == 1
                    && lstComponentBeans.get(0).getDataExportsBean() != null) {
                AbsDataExportBean exportBean = lstComponentBeans.get(0).getDataExportsBean()
                        .getDataExportBean(showtype);
                if (exportBean != null && exportBean.getLocalStroageBean() != null) {
                    this.isExportToLocalFile = true;
                    this.dataexport_localstroageautodelete = exportBean.getLocalStroageBean().isAutodelete();
                    this.dataexport_localstroagedirectorydateformat = exportBean.getLocalStroageBean()
                            .getRealDirectorydateformat();
                    this.dataexport_localstroagedownload = exportBean.getLocalStroageBean().isDownload();
                    this.dataexport_localstroagezip = exportBean.getLocalStroageBean().isZip();
                }
            }
        }
        if (this.showtype != Consts.DISPLAY_ON_PRINT && !this.isExportToLocalFile
                && this.wresponse.getResponse() != null) {
            this.wresponse.getResponse().reset();
            if (this.showtype == Consts.DISPLAY_ON_PLAINEXCEL) {
                this.wresponse.getResponse().setContentType("application/vnd.ms-excel;charset=" + Config.encode);
            } else if (this.showtype == Consts.DISPLAY_ON_RICHEXCEL) {
                this.wresponse.getResponse().setContentType("application/vnd.ms-excel;charset=" + Config.encode);
            } else if (this.showtype == Consts.DISPLAY_ON_WORD) {
                this.wresponse.getResponse().setContentType("application/vnd.ms-word;charset=" + Config.encode);
            } else if (this.showtype == Consts.DISPLAY_ON_PDF) {
                this.wresponse.getResponse().setContentType("application/pdf;charset=" + Config.encode);
            }
        }
        if (lstAllReportBeans != null) {
            AbsReportType reportObjTmp;
            for (ReportBean rbeanTmp : lstAllReportBeans) {
                reportObjTmp = (AbsReportType) getComponentTypeObj(rbeanTmp, null, true);
                reportObjTmp.init();
                reportObjTmp.loadReportData(true);
            }
        }
        if (this.isExportToLocalFile) {//??????????????
            createDataExportFileObj();
        }
    }

    private void createDataExportFileObj() {
        this.dataExportFilepath = DataExportLocalStroageBean.dataExportFileRootPath;
        this.dataExportFileurl = DataExportLocalStroageBean.dataExportFileRootUrl;
        if (this.dataexport_localstroageautodelete) {//?dataexport/temp/?
            this.dataExportFilepath += "temp" + File.separator;
            this.dataExportFileurl += "temp/";
        }
        if (!Tools.isEmpty(this.dataexport_localstroagedirectorydateformat)
                && !DataExportLocalStroageBean.ROOTDIRECTORY
                        .equals(this.dataexport_localstroagedirectorydateformat)) {
            String datename = Tools.removeNonNumberFromDatetime(
                    Tools.getStrDatetime(this.dataexport_localstroagedirectorydateformat, new Date()));
            this.dataExportFilepath += datename + File.separator;
            this.dataExportFileurl += datename + "/";
        }
        FilePathAssistant.getInstance().checkAndCreateDirIfNotExist(this.dataExportFilepath);
        String tmp = Long.toHexString(System.currentTimeMillis()) + Tools.getRandomString(2);
        String filename = this.getDataExportFilename();
        filename = Tools.isEmpty(filename) ? tmp : (filename + "_" + tmp);
        String filesuffix;
        if (this.showtype == Consts.DISPLAY_ON_PDF) {
            filesuffix = ".pdf";
        } else if (this.showtype == Consts.DISPLAY_ON_PLAINEXCEL || this.showtype == Consts.DISPLAY_ON_RICHEXCEL) {
            filesuffix = ".xls";
        } else if (this.showtype == Consts.DISPLAY_ON_WORD) {
            filesuffix = ".doc";
        } else {
            filesuffix = ".tmp";
        }
        this.dataExportFilepath += filename + filesuffix;
        this.dataExportFileurl += WabacusAssistant.getInstance().encodeAttachFilename(this.request, filename)
                + filesuffix;
        File fResult = new File(this.dataExportFilepath);
        try {
            if (!fResult.exists() || !fResult.isFile())
                fResult.createNewFile();
        } catch (IOException e) {
            throw new WabacusRuntimeException("" + this.dataExportFilepath + "",
                    e);
        }
    }

    public boolean isReportInPdfTemplate(String reportid) {
        if (this.showtype != Consts.DISPLAY_ON_PDF)
            return false;
        if (this.mReportidsInPdfTemplate == null)
            return false;
        return "true".equals(this.mReportidsInPdfTemplate.get(reportid));
    }

    public boolean isPdfPrintAction() {
        if (this.showtype != Consts.DISPLAY_ON_PDF)
            return false;
        return this.getStringAttribute("WX_IS_PDFPRINT_ACTION", "").equals("true");
    }

    public void setFilterCondition(ReportBean rbean) {
        String colFilterId = getStringAttribute(rbean.getId() + "_COL_FILTERID", "");
        if (!colFilterId.equals("")) {
            AbsListReportDisplayBean alrdbean = (AbsListReportDisplayBean) rbean.getDbean()
                    .getExtendConfigDataForReportType(AbsListReportType.KEY);
            AbsListReportFilterBean filterbean = alrdbean.getFilterBeanById(colFilterId);
            if (filterbean != null && !filterbean.isConditionRelate()) {
                String filterVal = getStringAttribute(colFilterId, "");
                if (!filterVal.trim().equals("")) {
                    getCdb(rbean.getId()).setFilteredBean(filterbean);//????
                }
            }
        }
    }

    public String getDataExportFilename() {
        StringBuffer filenameBuf = new StringBuffer();
        if (this.lstComponentBeans == null || this.lstComponentBeans.size() == 0)
            return "NoData";
        String filenameTmp;
        for (IComponentConfigBean ccbeanTmp : this.lstComponentBeans) {
            filenameTmp = null;
            if (ccbeanTmp.getDataExportsBean() != null) {
                filenameTmp = ccbeanTmp.getDataExportsBean().getFilename(this);
            }
            if (filenameTmp == null || filenameTmp.trim().equals("")) {//<dataexports/>?filename???
                filenameTmp = ccbeanTmp.getTitle(this);
            }
            if (filenameTmp == null || filenameTmp.trim().equals(""))
                continue;
            filenameBuf.append(filenameTmp).append(",");
        }
        if (filenameBuf.length() == 0)
            return "DataExport";
        if (filenameBuf.charAt(filenameBuf.length() - 1) == ',')
            filenameBuf.deleteCharAt(filenameBuf.length() - 1);
        return filenameBuf.toString();
    }

    private List<String> lstProcessedTargetPageIds;

    public String forwardPageWithBack(String url) {
        return forwardPageWithBack(url, null);
    }

    public String forwardPageWithBack(String url, String beforeCallbackMethodName) {
        if (this.getShowtype() != Consts.DISPLAY_ON_PAGE)
            return "";
        this.pagebean.setShouldProvideEncodePageUrl(true);
        String targetpageid = Tools.getParamvalueFromUrl(url, "PAGEID");
        targetpageid = targetpageid == null ? "" : targetpageid.trim();
        if (!this.isLoadedByAjax() && !targetpageid.equals("")
                && !(lstProcessedTargetPageIds != null && lstProcessedTargetPageIds.contains(targetpageid))) {
            PageBean pbeanTarget = Config.getInstance().getPageBean(targetpageid);
            if (pbeanTarget != null) {
                if (lstProcessedTargetPageIds == null)
                    lstProcessedTargetPageIds = new ArrayList<String>();
                lstProcessedTargetPageIds.add(targetpageid);
                this.pageObj.addDynJsFileBeans(pbeanTarget.getLstMyJavascriptFiles());
                this.pageObj.addDynCsses(pbeanTarget.getUlstMyCss());
            }
        }
        StringBuffer resultBuf = new StringBuffer();
        resultBuf.append("forwardPageWithBack('").append(this.pagebean.getId()).append("','");
        resultBuf.append(Tools.jsParamEncode(url)).append("',");
        if (beforeCallbackMethodName != null && !beforeCallbackMethodName.trim().equals("")) {
            resultBuf.append(beforeCallbackMethodName);
        } else {
            resultBuf.append("null");
        }
        resultBuf.append(")");
        return resultBuf.toString();
    }

    public Object getAttribute(String name) {
        return attributes.get(name);
    }

    public String getStringAttribute(String name) {
        Object val = attributes.get(name);
        if (val == null)
            return null;
        String value = null;
        if (val instanceof String[]) {
            String[] temp = (String[]) val;
            StringBuffer tempBuf = new StringBuffer();
            if (temp.length > 0) {
                for (int i = 0; i < temp.length; i++) {
                    tempBuf.append("[" + temp[i] + "]");
                }
            }
            log.warn("????" + name + "??"
                    + tempBuf.toString() + "" + temp[0] + "??");
            value = temp[0];
        } else if (val instanceof String) {
            value = (String) val;
        } else {
            value = val.toString();
        }
        return value;
    }

    public String getStringAttribute(String name, String defaultvalue) {
        String value = getStringAttribute(name);
        if (value == null || value.trim().equals("")) {
            value = defaultvalue;
        } else {
            value = value.trim();
        }
        return value;
    }

    public int getIntAttribute(String name, int defaultvalue) {
        String value = getStringAttribute(name);
        if (value == null || value.trim().equals("")) {
            return defaultvalue;
        } else {
            try {
                return Integer.parseInt(value.trim());
            } catch (NumberFormatException e) {
                return defaultvalue;
            }
        }
    }

    public Object getAttribute(String reportid, String name) {
        CacheDataBean cdb = this.getCdb(reportid);
        if (cdb == null) {
            return null;
        }
        return cdb.getAttributes().get(name);
    }

    public Object getAttribute(String reportid, String name, Object defaultvalue) {
        Object o = getAttribute(reportid, name);
        if (o == null) {
            o = defaultvalue;
        }
        return o;
    }

    public String getStringAttribute(String reportid, String name, String defaultvalue) {
        Object obj = getAttribute(reportid, name);
        if (obj == null || !(obj instanceof String))
            return defaultvalue;
        return ((String) obj).trim();
    }

    public int getIntAttribute(String reportid, String name, int defaultvalue) {
        String val = getStringAttribute(reportid, name, "");
        if (val == null || val.equals(""))
            return defaultvalue;
        try {
            return Integer.parseInt(val);
        } catch (Exception e) {
            log.error("", e);
        }
        return defaultvalue;
    }

    public boolean getBolAttribute(String reportid, String name, boolean defaultvalue) {
        String val = getStringAttribute(reportid, name, "");
        if (val == null || val.equals(""))
            return defaultvalue;
        try {
            return Boolean.parseBoolean(val);
        } catch (Exception e) {
            log.error("", e);
        }
        return defaultvalue;
    }

    public void setObjKeyAttribute(Object key, Object value) {
        this.attributes.put(key, value);
    }

    public Object getObjKeyAttribute(Object key) {
        if (this.attributes == null)
            return null;
        return this.attributes.get(key);
    }

    public void setAttribute(String name, Object value) {
        if (this.isShouldAddToUrlAttributeName(name)) {
            if (value == null) {
                this.addParamToUrl(name, null, true);
            } else {
                this.addParamToUrl(name, value.toString(), true);
            }
        }
        this.attributes.put(name, value);
    }

    public void setAttribute(String reportid, String name, Object value) {
        if (this.isShouldAddToUrlAttributeName(reportid, name)) {
            if (value == null) {
                this.addParamToUrl(name, null, true);
            } else {
                this.addParamToUrl(name, value.toString(), true);
            }
        }
        this.getCdb(reportid).getAttributes().put(name, value);
    }

    private void setAttribute(HttpServletRequest request, String name, String defaultvalue) {
        String value = Tools.getRequestValue(request, name, defaultvalue);
        this.attributes.put(name, value);
    }

    public void removeAttribute(String name) {
        this.attributes.remove(name);

    }

    //    private void updateConditionValue(String reportid,String name,Object value)
    //        //        CacheDataBean cdb = this.getCdb(reportid);
    //        //        if (cdb == null || !(value instanceof String)) return;
    //        if(rbean==null||rbean.getSbean()==null||rbean.getSbean().getLstConditionFromRequestNames()==null) return;
    //        {//name??name?
    //    }

    public TransactionTypeWrapper getTransactionWrapper() {
        return transactionWrapper;
    }

    public void setTransactionObj(ITransactionType transactionObj) {
        this.transactionWrapper = new TransactionTypeWrapper(transactionObj);
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public boolean isDisplayOnPage() {
        if (this.showtype == Consts.DISPLAY_ON_PAGE)
            return true;
        if (this.showtype == Consts.DISPLAY_ON_PRINT
                && this.lstComponentBeans.get(0).getPrintBean() instanceof DefaultPrintProviderConfigBean) {
            return true;
        }
        return false;
    }

    public IComponentType getComponentTypeObj(String componentId, AbsContainerType parentContainer,
            boolean createNew) {
        if (mComponentTypeObjs != null && mComponentTypeObjs.containsKey(componentId)) {
            return mComponentTypeObjs.get(componentId);
        }
        if (!createNew)
            return null;
        IComponentConfigBean ccbean = null;
        if (this.pagebean.getId().equals(componentId)) {
            ccbean = this.pagebean;
        } else {
            ccbean = this.pagebean.getChildComponentBean(componentId, true);
        }
        if (ccbean == null)
            return null;
        return getComponentTypeObj(ccbean, parentContainer, createNew);
    }

    public IComponentType getComponentTypeObj(IComponentConfigBean componentConfigBean,
            AbsContainerType parentContainer, boolean createNew) {
        if (this.mComponentTypeObjs == null)
            mComponentTypeObjs = new HashMap<String, IComponentType>();
        IComponentType typeObj = mComponentTypeObjs.get(componentConfigBean.getId());
        if (parentContainer != null && typeObj != null && typeObj.getParentContainerType() == null) {
            typeObj.setParentContainerType(parentContainer);
        }
        if (!createNew || typeObj != null)
            return typeObj;
        typeObj = componentConfigBean.createComponentTypeObj(this, parentContainer);
        mComponentTypeObjs.put(componentConfigBean.getId(), typeObj);
        return typeObj;
    }

    public AbsReportType getDisplayReportTypeObj(String reportid) {
        if (reportid == null || reportid.trim().equals(""))
            return null;
        IComponentType reportObj = getComponentTypeObj(reportid, null, false);
        if (reportObj == null || !(reportObj instanceof AbsReportType)) {
            throw new WabacusRuntimeException(
                    "?" + this.pagebean.getPath() + "id" + reportid + "");
        }
        return (AbsReportType) reportObj;
    }

    public AbsReportType getDisplayReportTypeObj(ReportBean rbean) {
        IComponentType reportObj = getComponentTypeObj(rbean, null, false);
        if (reportObj == null || !(reportObj instanceof AbsReportType)) {
            throw new WabacusRuntimeException(
                    "?" + this.pagebean.getPath() + "?" + rbean.getPath() + "");
        }
        return (AbsReportType) reportObj;
    }

    public List<String> getLstApplicationIds() {
        return lstApplicationIds;
    }

    public String getCurrentStatus() {
        StringBuffer sbuffer = new StringBuffer();
        if (this.attributes != null) {
            Iterator itKeys = this.attributes.keySet().iterator();
            while (itKeys.hasNext()) {
                String key = (String) itKeys.next();
                Object value = attributes.get(key);
                if (value != null && value instanceof String) {
                    sbuffer.append(key + "=" + value + ";");
                }
            }
            return sbuffer.toString();
        }
        return "";
    }

    public PageBean getPagebean() {
        return pagebean;
    }

    public CacheDataBean getCdb(String reportid) {
        if (this.mCacheDataBeans == null || this.mCacheDataBeans.size() == 0
                || !mCacheDataBeans.containsKey(reportid)) {
            ReportBean rbtemp = this.pagebean.getReportChild(reportid, true);
            if (rbtemp == null) {
                throw new WabacusRuntimeException("?" + this.pagebean.getPath() + "?id"
                        + reportid
                        + "?idReportRequestgetCdb(String reportid)");
            }
            CacheDataBean cdb = new CacheDataBean(this);
            cdb.setReportBean(rbtemp);
            this.mCacheDataBeans.put(rbtemp.getId(), cdb);
        }
        return (CacheDataBean) mCacheDataBeans.get(reportid);
    }

    public Connection getConnection() {
        return getConnection(Config.getInstance().getDefault_datasourcename());
    }

    public Connection getConnection(String datasource) {
        if (Tools.isDefineKey("i18n", datasource)) {
            datasource = Tools.getRealKeyByDefine("i18n", datasource);
            if (this.locallanguage != null && !this.locallanguage.trim().equals("")) {
                String dsTemp = datasource + "_" + this.locallanguage;
                Connection conn = connections.get(dsTemp);
                if (conn == null) {
                    conn = Config.getInstance().getDataSource(dsTemp).getConnection();
                    connections.put(dsTemp, conn);
                }
                if (conn != null) {
                    log.debug("??" + dsTemp + "??");
                    return conn;
                } else {
                    log.warn("????" + datasource
                            + "?????" + this.locallanguage + "");
                }
            }
        }
        if (datasource == null || datasource.trim().equals("") || datasource.trim().equals(Consts.DEFAULT_KEY))
            datasource = Config.getInstance().getDefault_datasourcename();
        if (connections.get(datasource) == null) {
            connections.put(datasource, Config.getInstance().getDataSource(datasource).getConnection());
        }
        return connections.get(datasource);
    }

    public AbsDatabaseType getDbType(String datasource_name) {
        if (Tools.isDefineKey("i18n", datasource_name)) {
            datasource_name = Tools.getRealKeyByDefine("i18n", datasource_name);
            if (this.locallanguage != null && !this.locallanguage.trim().equals("")) {
                String dsTemp = datasource_name + "_" + this.locallanguage;
                AbsDatabaseType dbtype = mDbTypes.get(dsTemp);
                if (dbtype == null) {
                    dbtype = Config.getInstance().getDataSource(dsTemp).getDbType();
                    mDbTypes.put(dsTemp, dbtype);
                }
                if (dbtype != null) {
                    return dbtype;
                } else {
                    log.warn("????" + datasource_name
                            + "?????" + this.locallanguage + "");
                }
            }
        }
        if (datasource_name == null || datasource_name.trim().equals("")
                || datasource_name.trim().equals(Consts.DEFAULT_KEY))
            datasource_name = Config.getInstance().getDefault_datasourcename();
        if (mDbTypes.get(datasource_name) == null) {
            mDbTypes.put(datasource_name, Config.getInstance().getDataSource(datasource_name).getDbType());
        }
        return mDbTypes.get(datasource_name);
    }

    public void setTransactionLevel(String ds_name, String translevel) {
        if (translevel == null || translevel.trim().equals(""))
            return;
        if (ds_name == null || ds_name.trim().equals("") || ds_name.trim().equals(Consts.DEFAULT_KEY))
            ds_name = Config.getInstance().getDefault_datasourcename();
        if (mTransactionLevels == null)
            mTransactionLevels = new HashMap<String, String>();
        if (!Consts_Private.M_ALL_TRANSACTION_LEVELS.containsKey(translevel)) {
            throw new WabacusRuntimeException(
                    "" + translevel + "????");
        }
        mTransactionLevels.put(ds_name, translevel);
    }

    public String getTransactionLevel(String ds_name) {
        if (mTransactionLevels == null)
            return null;
        if (ds_name == null || ds_name.trim().equals("") || ds_name.trim().equals(Consts.DEFAULT_KEY))
            ds_name = Config.getInstance().getDefault_datasourcename();
        return mTransactionLevels.get(ds_name);
    }

    public boolean isLoadedByAjax() {
        return getStringAttribute("WX_ISAJAXLOAD", "").equalsIgnoreCase("true");
    }

    public boolean isSearchReportAction(String reportid) {
        if (lstSearchReportIds == null) {
            lstSearchReportIds = new ArrayList<String>();
            String searchreportid = this.getStringAttribute("SEARCHREPORT_ID", "");
            if (searchreportid.equals(""))
                return false;
            ReportBean rbean = this.pagebean.getReportChild(searchreportid, true);
            if (rbean == null)
                return false;
            lstSearchReportIds.add(reportid);
            if (rbean.getSRelateConditionReportids() != null)
                lstSearchReportIds.addAll(rbean.getSRelateConditionReportids());
        }
        return lstSearchReportIds.contains(reportid);
    }

    public String addParamToUrl(String paramname, String paramvalue, boolean overwrite) {
        if (!overwrite && (url.indexOf("&" + paramname + "=") >= 0 || url.indexOf("?" + paramname + "=") >= 0)) {
            return url;
        }
        if (Tools.isDefineKey("rrequest", paramvalue)) {//??paramvaluerrequest?????
            paramvalue = Tools.getRealKeyByDefine("rrequest", paramvalue);
            paramvalue = this.getStringAttribute(paramvalue);
        }
        try {
            if (paramvalue != null) {
                paramvalue = Tools.replaceAll(paramvalue, " ", "WX_BLANK_BLANK_BLANK_BLANK_BLANK_BLANK_BLANK");
                paramvalue = URLEncoder.encode(paramvalue, "utf-8");
                paramvalue = Tools.replaceAll(paramvalue, "WX_BLANK_BLANK_BLANK_BLANK_BLANK_BLANK_BLANK", "%20");
            }
        } catch (UnsupportedEncodingException e) {
            log.warn("URL?" + paramvalue + "", e);
        }
        url = Tools.replaceUrlParamValue(url, paramname, paramvalue);
        return url;
    }

    public void authorize(String componentId, String parttype, String partid, String permissiontype,
            String permissionvalue) {
        if (mComponentsPermissions == null)
            mComponentsPermissions = new HashMap<String, ComponentPermissionBean>();
        ComponentPermissionBean cabean = this.mComponentsPermissions.get(componentId);
        if (cabean == null) {
            if (this.pagebean.getId().equals(componentId)) {
                cabean = new ComponentPermissionBean(this.pagebean);
            } else {
                IComponentConfigBean ccbean = this.pagebean.getChildComponentBean(componentId, true);
                if (ccbean == null) {
                    throw new WabacusRuntimeException("?" + this.pagebean.getId() + "?ID"
                            + componentId + "?");
                }
                if (Consts.DATA_PART.equals(parttype) && Consts.PERMISSION_TYPE_DISPLAY.equals(permissiontype)
                        && "false".equalsIgnoreCase(permissionvalue) && partid != null && !partid.trim().equals("")
                        && ccbean instanceof ReportBean) {//???????
                    this.setAttribute(componentId, "authroize_col_display", "false");
                }
                cabean = new ComponentPermissionBean(ccbean);
            }
            cabean.setRRequest(this);
            this.mComponentsPermissions.put(componentId, cabean);
        }
        cabean.authorize(parttype, partid, permissiontype, permissionvalue);
    }

    public boolean checkPermission(String componentId, String parttype, String partid, String permissiontype) {
        return checkPermission(componentId, parttype, partid, permissiontype, "true");
    }

    public boolean checkPermission(String componentId, String parttype, String partid, String permissiontype,
            String permissionvalue) {
        if (componentId == null || componentId.trim().equals(""))
            return false;
        if (!this.pagebean.isCheckPermission()) {
            return AuthorizationAssistant.getInstance().checkDefaultPermissionTypeValue(permissiontype,
                    permissionvalue);
        }
        if (!AuthorizationAssistant.getInstance().isExistPermissiontype(permissiontype))
            return false;
        if (!AuthorizationAssistant.getInstance().isExistValueOfPermissiontype(permissiontype, permissionvalue))
            return false;
        //log.debug(componentId+"|||"+parttype+"|||"+partid+"|||"+permissiontype);
        String myPermissionKey = componentId;
        if (parttype != null && !parttype.trim().equals(""))
            myPermissionKey = myPermissionKey + "_" + parttype.trim();
        if (partid != null && !partid.trim().equals(""))
            myPermissionKey = myPermissionKey + "_" + partid.trim();
        myPermissionKey = myPermissionKey + "_" + permissiontype;
        if (permissionvalue != null && !permissionvalue.trim().equals(""))
            myPermissionKey = myPermissionKey + "_" + permissionvalue.trim();
        myPermissionKey = myPermissionKey + "_permission";
        Boolean bolHasPermission = (Boolean) this.getAttribute(myPermissionKey);
        if (bolHasPermission != null) {
            return bolHasPermission.booleanValue();
        }
        if (!this.pagebean.getId().equals(componentId) || (parttype != null && !parttype.trim().equals(""))) {//??<page/>?????
            boolean parentPermisson = checkParentPermission(componentId, parttype, partid, permissiontype,
                    permissionvalue);
            if (AuthorizationAssistant.getInstance().isConsistentWithParentPermission(permissiontype,
                    permissionvalue, parentPermisson)) {//???????/????readonlytrue??displaytrue
                this.setAttribute(myPermissionKey, parentPermisson);
                return parentPermisson;
            }
        }
        ///????/?????
        int permission = checkRuntimePermission(componentId, parttype, partid, permissiontype, permissionvalue);
        if (permission == Consts.CHKPERMISSION_YES) {
            this.setAttribute(myPermissionKey, true);
            return true;
        }
        if (permission == Consts.CHKPERMISSION_NO) {
            this.setAttribute(myPermissionKey, false);
            return false;
        }
        //?????Consts.CHKPERMISSION_EMPTY????
        IComponentConfigBean ccbean = null;
        if (this.pagebean.getId().equals(componentId)) {
            ccbean = this.pagebean;
        } else {
            ccbean = this.pagebean.getChildComponentBean(componentId, true);
            if (ccbean == null)
                throw new WabacusRuntimeException(
                        "?" + this.pagebean.getId() + "ID" + componentId + "");
        }
        permission = Config.getInstance().checkDefaultPermission(ccbean.getGuid(), parttype, partid, permissiontype,
                permissionvalue);
        if (permission == Consts.CHKPERMISSION_YES) {
            this.setAttribute(myPermissionKey, true);
            return true;//?/??
        }
        if (permission == Consts.CHKPERMISSION_NO) {
            this.setAttribute(myPermissionKey, false);
            return false;///???
        }
        boolean defaultpermission = AuthorizationAssistant.getInstance()
                .checkDefaultPermissionTypeValue(permissiontype, permissionvalue);
        this.setAttribute(myPermissionKey, defaultpermission);
        return defaultpermission;
    }

    private boolean checkParentPermission(String componentId, String parttype, String partid, String permissiontype,
            String permissionvalue) {
        if (componentId == null || componentId.trim().equals("")) {
            throw new WabacusRuntimeException("??ID");
        }
        if (partid != null && !partid.trim().equals("")) {
            if (parttype == null || parttype.trim().equals("")) {
                throw new WabacusRuntimeException("ID" + componentId
                        + "??partidparttype");
            }
            return checkPermission(componentId, parttype, null, permissiontype, permissionvalue);
        }
        if (parttype != null && !parttype.trim().equals("")) {
            return checkPermission(componentId, null, null, permissiontype, permissionvalue);
        }
        //????????
        if (componentId.equals(this.pagebean.getId()))
            throw new WabacusRuntimeException("?<page/>??");
        IComponentConfigBean ccbean = this.pagebean.getChildComponentBean(componentId, true);
        return ccbean.getParentContainer().invokeCheckPermissionByChild(this, ccbean, permissiontype,
                permissionvalue);
    }

    public int checkRuntimePermission(String componentId, String parttype, String partid, String permissiontype) {
        return checkRuntimePermission(componentId, parttype, partid, permissiontype, "true");
    }

    public int checkRuntimePermission(String componentId, String parttype, String partid, String permissiontype,
            String permissionvalue) {
        if (!AuthorizationAssistant.getInstance().isExistPermissiontype(permissiontype))
            return Consts.CHKPERMISSION_UNSUPPORTEDTYPE;
        if (!AuthorizationAssistant.getInstance().isExistValueOfPermissiontype(permissiontype, permissionvalue))
            return Consts.CHKPERMISSION_UNSUPPORTEDVALUE;
        if (mComponentsPermissions == null || this.mComponentsPermissions.get(componentId) == null)
            return Consts.CHKPERMISSION_EMPTY;
        return this.mComponentsPermissions.get(componentId).checkPermission(parttype, partid, permissiontype,
                permissionvalue);
    }

    public void disableAutoSuccessPrompt() {
        if (this.attributes == null)
            this.attributes = new HashMap();
        this.attributes.put("DISABLED_AUTO_SUCCESSED_PROMPT", "true");
    }

    public boolean isDisableAutoSuccessPrompt() {
        return this.attributes != null
                && "true".equals(String.valueOf(this.attributes.get("DISABLED_AUTO_SUCCESSED_PROMPT")));
    }

    public void disableAutoFailedPrompt() {
        if (this.attributes == null)
            this.attributes = new HashMap();
        this.attributes.put("DISABLED_AUTO_FAILED_PROMPT", "true");
    }

    public boolean isDisableAutoFailedPrompt() {
        return this.attributes != null
                && "true".equals(String.valueOf(this.attributes.get("DISABLED_AUTO_FAILED_PROMPT")));
    }

    public List<AbsPageInterceptor> getLstPageInterceptors() {
        return lstPageInterceptors;
    }

    public void destroy(boolean flag) {
        if (this.getActiontype().equalsIgnoreCase(Consts.SHOWREPORT_ACTION)) {
            if (flag && this.lstAllReportBeans != null && this.lstAllReportBeans.size() > 0) {//?
                for (ReportBean rbeanTemp : lstAllReportBeans) {
                    if (rbeanTemp != null && rbeanTemp.getInterceptor() != null) {
                        rbeanTemp.getInterceptor().doEnd(this, rbeanTemp);
                    }
                }
            }
            if (this.lstPageInterceptors != null && this.lstPageInterceptors.size() > 0) {
                AbsPageInterceptor interceptorTmp;
                for (int i = this.lstPageInterceptors.size() - 1; i >= 0; i--) {
                    interceptorTmp = this.lstPageInterceptors.get(i);
                    interceptorTmp.doEnd(this);
                }
            }
        }
        releaseDBResources();
    }

    public void releaseDBResources() {
        if (this.lstAllUsedStatement.size() > 0) {
            Statement stmt;
            for (int i = 0; i < this.lstAllUsedStatement.size(); i++) {
                stmt = this.lstAllUsedStatement.get(i);
                if (stmt == null)
                    continue;
                WabacusAssistant.getInstance().release(null, stmt);
            }
            this.lstAllUsedStatement.clear();
        }
        if (connections.size() > 0) {
            Iterator<String> itConns = connections.keySet().iterator();
            String name;
            while (itConns.hasNext()) {
                name = itConns.next();
                WabacusAssistant.getInstance().release(connections.get(name), null);
            }
            connections.clear();
        }
    }

    public void setEditableReportAccessMode(String reportid, String newaccessmode) {
        IComponentType typeObj = this.getComponentTypeObj(reportid, null, true);
        if (!(typeObj instanceof AbsReportType)) {
            throw new WabacusRuntimeException(
                    "?" + this.pagebean.getId() + "?ID" + reportid + "?");
        }
        if (!(typeObj instanceof IEditableReportType)) {
            throw new WabacusRuntimeException(
                    "?" + this.pagebean.getId() + "ID" + reportid + "??");
        }
        ((IEditableReportType) typeObj).setNewAccessMode(newaccessmode);
    }

    public String getCurrentAccessMode(String reportid) {
        AbsReportType reportObj = getDisplayReportTypeObj(reportid);
        if (reportObj == null || !(reportObj instanceof IEditableReportType))
            return "";
        return getStringAttribute(reportid, "CURRENT_ACCESSMODE",
                ((IEditableReportType) reportObj).getDefaultAccessMode());
    }

    public List<Map<String, String>> getLstUpdatedData(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedData(ersqlbean.getUpdatebean());
    }

    public List<Map<String, String>> getLstUpdatedData(String reportid) {
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstUpdatedData(rbean);
    }

    public List<Map<String, String>> getLstUpdatedParamValues(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedParamValues(ersqlbean.getUpdatebean());
    }

    public List<Map<String, String>> getLstUpdatedParamValues(String reportid) {
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstUpdatedParamValues(rbean);
    }

    public List<Map<String, String>> getLstInsertedData(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedData(ersqlbean.getInsertbean());
    }

    public List<Map<String, String>> getLstInsertedData(String reportid) {
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstInsertedData(rbean);
    }

    public List<Map<String, String>> getLstInsertedParamValues(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedParamValues(ersqlbean.getInsertbean());
    }

    public List<Map<String, String>> getLstInsertedParamValues(String reportid) {
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstInsertedParamValues(rbean);
    }

    public List<Map<String, String>> getLstDeletedData(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedData(ersqlbean.getDeletebean());
    }

    public List<Map<String, String>> getLstDeletedData(String reportid) {
        ReportBean rbean = pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstDeletedData(rbean);
    }

    public List<Map<String, String>> getLstDeletedParamValues(ReportBean rbean) {
        EditableReportSqlBean ersqlbean = (EditableReportSqlBean) rbean.getSbean()
                .getExtendConfigDataForReportType(EditableReportSqlBean.class);
        if (ersqlbean == null)
            return null;
        return this.getCdb(rbean.getId()).getLstEditedParamValues(ersqlbean.getDeletebean());
    }

    public List<Map<String, String>> getLstDeletedParamValues(String reportid) {
        ReportBean rbean = this.pagebean.getReportChild(reportid, true);
        if (rbean == null) {
            throw new WabacusRuntimeException("?" + reportid + "?"
                    + this.pagebean.getPath() + "");
        }
        return getLstDeletedParamValues(rbean);
    }

    public Map<String, String> getMCustomizeEditData(ReportBean rbean) {
        return (Map<String, String>) this.getCdb(rbean.getId()).getAttributes().get("WX_UPDATE_CUSTOMIZEDATAS");
    }

    public Map<String, String> getMCustomizeEditData(String reportid) {
        return (Map<String, String>) this.getCdb(reportid).getAttributes().get("WX_UPDATE_CUSTOMIZEDATAS");
    }

    public List<Map<String, String>> getLstInvokeServerActionParams(String componentid) {
        if (this.serverActionBean == null || componentid == null || componentid.trim().equals(""))
            return null;
        if (!componentid.equals(this.serverActionBean.getComponentid()))
            return null;
        return this.serverActionBean.getLstParams();
    }

    public String getColDisplayValue(String reportid, String property, int rowidx) {
        AbsReportType reportObj = getDisplayReportTypeObj(reportid);
        if (reportObj.getLstReportData() == null || reportObj.getLstReportData().size() == 0)
            return null;
        if (rowidx < 0)
            rowidx = 0;
        if (rowidx >= reportObj.getLstReportData().size())
            return null;
        ColBean cbean = reportObj.getReportBean().getDbean().getColBeanByColProperty(property);
        if (cbean == null)
            throw new WabacusRuntimeException("" + reportObj.getReportBean().getPath()
                    + "property" + property + "");
        return reportObj.getLstReportData().get(rowidx).getColStringValue(cbean);
    }

    public Object getColRealValue(String reportid, String property, int rowidx) {
        AbsReportType reportObj = getDisplayReportTypeObj(reportid);
        if (reportObj.getLstReportData() == null || reportObj.getLstReportData().size() == 0)
            return null;
        if (rowidx < 0)
            rowidx = 0;
        if (rowidx >= reportObj.getLstReportData().size())
            return null;
        ColBean cbean = reportObj.getReportBean().getDbean().getColBeanByColProperty(property);
        if (cbean == null)
            throw new WabacusRuntimeException("" + reportObj.getReportBean().getPath()
                    + "property" + property + "");
        return reportObj.getLstReportData().get(rowidx).getColValue(cbean);
    }

    public int getReportDataListSize(String reportid) {
        AbsReportType reportObj = getDisplayReportTypeObj(reportid);
        if (reportObj.getLstReportData() == null)
            return 0;
        return reportObj.getLstReportData().size();
    }

    public AbsReportDataPojo getReportDataObj(String reportid, int rowidx) {
        AbsReportType reportObj = getDisplayReportTypeObj(reportid);
        if (reportObj.getLstReportData() == null || reportObj.getLstReportData().size() == 0)
            return null;
        if (rowidx < 0)
            rowidx = 0;
        if (rowidx >= reportObj.getLstReportData().size())
            return null;
        return reportObj.getLstReportData().get(rowidx);
    }

    public Object getI18NObjectValue(String key) {
        if (key == null)
            return null;
        key = key.trim();
        if (key.equals("") || !key.startsWith("i18n"))
            return null;
        int len = key.length();
        key = Tools.getRealKeyByDefine("i18n", key);
        if (key.length() == len)
            return null;
        return Config.getInstance().getResources().getI18NObjectValue(key, this);
    }

    public Object getI18NObjectValue(String key, String localelanguage) {
        if (key == null)
            return null;
        key = key.trim();
        if (key.equals("") || !key.startsWith("i18n"))
            return null;
        int len = key.length();
        key = Tools.getRealKeyByDefine("i18n", key);
        if (key.length() == len)
            return null;
        return Config.getInstance().getResources().getI18NObjectValue(key, localelanguage);
    }

    public String getI18NStringValue(String key) {
        if (key == null)
            return key;
        key = key.trim();
        if (key.equals("") || !key.startsWith("i18n"))
            return key;
        int len = key.length();
        key = Tools.getRealKeyByDefine("i18n", key);
        if (key.length() == len)
            return key;
        return Config.getInstance().getResources().getI18NStringValue(key, this);
    }

    public String getI18NStringValue(String key, String localelanguage) {
        if (key == null)
            return key;
        key = key.trim();
        if (key.equals("") || !key.startsWith("i18n"))
            return key;
        int len = key.length();
        key = Tools.getRealKeyByDefine("i18n", key);
        if (key.length() == len)
            return key;
        return Config.getInstance().getResources().getI18NStringValue(key, localelanguage);
    }

    public List<ReportBean> getLstAllReportBeans() {
        return lstAllReportBeans;
    }

    public void addShouldAddToUrlAttributeName(String reportid, String attributename) {
        if (this.showtype != Consts.DISPLAY_ON_PAGE)
            return;
        if (attributename == null || attributename.trim().equals(""))
            return;
        if (this.mShouldAddToUrlAttriuteNames == null) {
            this.mShouldAddToUrlAttriuteNames = new HashMap<String, Set<String>>();
        }
        Set<String> sShouldAddToUrlAttriuteNames = this.mShouldAddToUrlAttriuteNames.get(reportid);
        if (sShouldAddToUrlAttriuteNames == null) {
            sShouldAddToUrlAttriuteNames = new HashSet<String>();
            this.mShouldAddToUrlAttriuteNames.put(reportid, sShouldAddToUrlAttriuteNames);
        }
        sShouldAddToUrlAttriuteNames.add(attributename);
    }

    public void addShouldAddToUrlAttributeName(String reportid, List<String> lstAttributeNames) {
        if (this.showtype != Consts.DISPLAY_ON_PAGE)
            return;
        if (lstAttributeNames == null || lstAttributeNames.size() == 0)
            return;
        if (this.mShouldAddToUrlAttriuteNames == null) {
            this.mShouldAddToUrlAttriuteNames = new HashMap<String, Set<String>>();
        }
        Set<String> sShouldAddToUrlAttriuteNames = this.mShouldAddToUrlAttriuteNames.get(reportid);
        if (sShouldAddToUrlAttriuteNames == null) {
            sShouldAddToUrlAttriuteNames = new HashSet<String>();
            this.mShouldAddToUrlAttriuteNames.put(reportid, sShouldAddToUrlAttriuteNames);
        }
        sShouldAddToUrlAttriuteNames.addAll(lstAttributeNames);
    }

    private boolean isShouldAddToUrlAttributeName(String attributename) {
        if (this.mShouldAddToUrlAttriuteNames == null)
            return false;
        for (Entry<String, Set<String>> entryTmp : this.mShouldAddToUrlAttriuteNames.entrySet()) {
            if (entryTmp != null && entryTmp.getValue() != null && entryTmp.getValue().contains(attributename))
                return true;
        }
        return false;
    }

    private boolean isShouldAddToUrlAttributeName(String reportid, String attributename) {
        if (this.mShouldAddToUrlAttriuteNames == null || this.mShouldAddToUrlAttriuteNames.get(reportid) == null)
            return false;
        return this.mShouldAddToUrlAttriuteNames.get(reportid).contains(attributename);
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getShowtype() {
        return showtype;
    }

    public void setShowtype(int showtype) {
        this.showtype = showtype;
    }

    public PageType getPageObj() {
        return pageObj;
    }

    public String getActiontype() {
        return actiontype;
    }

    public void setActiontype(String actiontype) {
        this.actiontype = actiontype;
    }

    public Map getAttributes() {
        return attributes;
    }

    public void addUsedStatement(Statement stmt) {
        this.lstAllUsedStatement.add(stmt);
    }

    public String getLocallanguage() {
        return locallanguage;
    }

    public void setLocallanguage(String locallanguage) {
        this.locallanguage = locallanguage;
    }

    public WabacusResponse getWResponse() {
        return wresponse;
    }

    public void setWResponse(WabacusResponse wresponse) {
        this.wresponse = wresponse;
    }

    public IComponentConfigBean getRefreshComponentBean() {
        return refreshComponentBean;
    }

    public void setRefreshComponentBean(IComponentConfigBean refreshComponentBean) {
        this.refreshComponentBean = refreshComponentBean;
    }

    public ReportBean getSlaveReportBean() {
        return slaveReportBean;
    }

    public void setSlaveReportBean(ReportBean slaveReportBean) {
        this.slaveReportBean = slaveReportBean;
    }

    public AbsReportType getSlaveReportTypeObj() {
        return slaveReportTypeObj;
    }

    public void setSlaveReportTypeObj(AbsReportType slaveReportTypeObj) {
        this.slaveReportTypeObj = slaveReportTypeObj;
    }

    public IComponentType getRefreshComponentTypeObj() {
        return refreshComponentTypeObj;
    }

    public void setRefreshComponentTypeObj(IComponentType refreshComponentTypeObj) {
        this.refreshComponentTypeObj = refreshComponentTypeObj;
    }

    public Map<String, ComponentPermissionBean> getMComponentsPermissions() {
        return mComponentsPermissions;
    }

    public List<String> getLstAncestorUrls() {
        return lstAncestorUrls;
    }

    public UpdateComponentDataServerActionBean getServerActionBean() {
        return serverActionBean;
    }

    public void setServerActionBean(UpdateComponentDataServerActionBean serverActionBean) {
        this.serverActionBean = serverActionBean;
    }

    public String getPageskin() {
        return pageskin;
    }

    public List<IComponentConfigBean> getLstComponentBeans() {
        return this.lstComponentBeans;
    }

    private Set<String> setSaveSlaveReportIds;

    public Set<String> getSaveSlaveReportIdsSet() {
        if (setSaveSlaveReportIds == null) {
            setSaveSlaveReportIds = new HashSet<String>();
            String saveSlaveReportIds = this.getStringAttribute("SAVEDSLAVEREPORT_ROOTREPORT_IDS", "");
            setSaveSlaveReportIds.addAll(Tools.parseStringToList(saveSlaveReportIds, ";", false));
        }
        return setSaveSlaveReportIds;
    }

    public void addListReportWithDefaultSelectedRows(ReportBean rbean, boolean isSelected) {
        if (rbean == null)
            return;
        AbsListReportBean alrbean = (AbsListReportBean) rbean
                .getExtendConfigDataForReportType(AbsListReportType.KEY);
        if (alrbean == null || alrbean.getRowSelectType() == null || alrbean.getRowSelectType().trim().equals("")
                || Consts.ROWSELECT_NONE.equals(alrbean.getRowSelectType()))
            return;//???
        if (isSelected) {
            if (this.lstReportWithDefaultSelectedRows == null)
                this.lstReportWithDefaultSelectedRows = new ArrayList<String>();
            if (!this.lstReportWithDefaultSelectedRows.contains(rbean.getId()))
                this.lstReportWithDefaultSelectedRows.add(rbean.getId());
        }
    }

    public List<String> getLstReportWithDefaultSelectedRows() {
        return lstReportWithDefaultSelectedRows;
    }

    public void addServerValidateParams(String paramname, String paramvalue) {
        if (this.mServerValidateDatas == null)
            this.mServerValidateDatas = new HashMap<String, String>();
        this.mServerValidateDatas.put(paramname, paramvalue);
    }

    public Map<String, String> getMServerValidateDatas() {
        return mServerValidateDatas;
    }
}