Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 
   * Copyright (C) 2010---2013 星星(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.config.dataexport;
 
 import java.util.List;
 import java.util.Map;
 
 
 public class DataExportsConfigBean implements Cloneable
 {
     private String filename;//导出的文件名,这里是配置的本组件所有数据导出默认的文件名,每个<dataexport/>还可以配置自己的filename覆盖这里的配置
     
     private Map<String,StringmDynFilename;
     
     private int batchselectcount=.;
     
     private List<StringlstAutoDataExportTypes;
 
 
     private IComponentConfigBean owner;
 
     public int getBatchselectcount()
     {
         return ;
     }
 
     {
         this.=owner;
     }
 
     public String getFilename(ReportRequest rrequest)
     {
         String dataexporttype=ComponentAssistant.getInstance().getDataExportTypeByShowType(rrequest.getShowtype());
         String realfilename=null;
         if(this.!=null&&this..get(dataexporttype)!=null)
         {
             realfilename=this..get(dataexporttype).getFilename(rrequest);
         }
         if(realfilename!=null&&!realfilename.trim().equals("")) return realfilename;//在<dataexport/>中配置了自己的filename
         return WabacusAssistant.getInstance().getStringValueWithDynPart(rrequest,this.,this.,"");
     }
     
     {
         return ;
     }
 
     public void setMDataExportBeans(Map<String,AbsDataExportBeandataExportBeans)
     {
         =dataExportBeans;
     }
 
     {
         return ;
     }
 
     public void setLstAutoDataExportTypes(List<StringlstAutoDataExportTypes)
     {
         if(lstAutoDataExportTypes==null)
         {
             this.=null;
         }else
         {
             List<StringlstTmp=new UniqueArrayList<String>();
            for(String typeTmp:lstAutoDataExportTypes)
            {
                typeTmp=typeTmp.toLowerCase().trim();
                if(typeTmp.equals("")) continue;
                if(typeTmp.equals(.))
                {
                    lstTmp=null;
                    break;
                }else if(!..contains(typeTmp))
                {
                    throw new WabacusConfigLoadingException("加载组件"+this.getOwner().getPath()+"失败,无效的数据导出类型:"+typeTmp);
                }
                lstTmp.add(typeTmp);
            }
            if(lstTmp!=null&&lstTmp.size()==0) lstTmp=null;
            this.=lstTmp;
        }
    }
    {
        return ;
    }
    public void setOwner(IComponentConfigBean owner)
    {
        this.=owner;
    }
    public List<StringgetLstIncludeApplicationids(String dataexporttype)
    {
        if(this.==null||!this..containsKey(dataexporttype)) return null;
        return this..get(dataexporttype).getLstIncludeApplicationids();
    }
    
    public List<StringgetLstIncludeApplicationids(int showtype)
    {
        return getLstIncludeApplicationids(ComponentAssistant.getInstance().getDataExportTypeByShowType(showtype));
    }
    
    public String getIncludeApplicationids(String dataexporttype)
    {
        if(this.==null||!this..containsKey(dataexporttype)) return null;
        return this..get(dataexporttype).getIncludeApplicationids();
    }
    
    public String getIncludeApplicationids(int showtype)
    {
        return getIncludeApplicationids(ComponentAssistant.getInstance().getDataExportTypeByShowType(showtype));
    }
    
    public int getDataExportRecordcount(String reportid,String dataexporttype)
    {
        if(this.==null||!this..containsKey(dataexporttype)) return -1;
        return this..get(dataexporttype).getDataExportRecordcount(reportid);
    }
    
    public int getDataExportRecordcount(String reportid,int showtype)
    {
        return getDataExportRecordcount(reportid,ComponentAssistant.getInstance().getDataExportTypeByShowType(showtype));
    }
    public AbsDataExportBean getDataExportBean(String dataexporttype)
    {
        if(this.==nullreturn null;
        return this..get(dataexporttype);
    }
    
    public AbsDataExportBean getDataExportBean(int showtype)
    {
        return getDataExportBean(ComponentAssistant.getInstance().getDataExportTypeByShowType(showtype));
    }
    
    public void loadConfig(XmlElementBean eleDataExports)
    {
        String batchselectcount=eleDataExports.attributeValue("batchselectcount");
        if(batchselectcount==null||batchselectcount.trim().equals(""))
        {
            this.=Config.getInstance().getDataexportBatchCount();
        }else
        {
            this.=Integer.parseInt(batchselectcount);
        }
        String filename=eleDataExports.attributeValue("filename");
        if(filename!=null)
        {
            Object[] objArr=WabacusAssistant.getInstance().parseStringWithDynPart(filename);
            this.=(String)objArr[0];
            this.=(Map<String,String>)objArr[1];
        }
        List<XmlElementBeanlstEleChildren=eleDataExports.getLstChildElements();
        if(lstEleChildren==null||lstEleChildren.size()==0) return;
        AbsDataExportBean childDataExportBean;
        for(XmlElementBean eleChildTmp:lstEleChildren)
        {
            String type=eleChildTmp.attributeValue("type");
            type=type==null?"":type.toLowerCase().trim();
            if(type.equals(""))
            {
                throw new WabacusConfigLoadingException("加载组件"+this..getPath()+"的数据导出<dataexports/>失败,必须指定<dataexport/>的type属性");
            }
            if(!..contains(type))
            {
                throw new WabacusConfigLoadingException("加载组件"+this..getPath()+"的数据导出<dataexports/>失败,<dataexport/>配置的type属性"+type+"不支持");
            }
            if(.containsKey(type))
            {
                throw new WabacusConfigLoadingException("加载组件"+this..getPath()+"的数据导出<dataexports/>失败,<dataexport/>配置的type属性"+type+"存在重复");
            }
            childDataExportBean=createDataExportBean(type);
            childDataExportBean.loadConfig(eleChildTmp);
            .put(type,childDataExportBean);
        }
        if(.size()==0) =null;
    }
    {
        if(type==null||type.trim().equals("")||!..contains(type)) return null;
        if(type.equals(.)) return new PDFExportBean(,type);
        if(type.equals(.)) return new PlainExcelExportBean(,type);
        return new WordRichExcelExportBean(,type);
    }
    public void doPostLoad()
    {
        checkedAndAddButtons();
        if(==nullreturn;
        for(Entry<String,AbsDataExportBeanentryTmp:this..entrySet())
        {
            entryTmp.getValue().doPostLoad();
        }
    }
    private void checkedAndAddButtons()
    {
        if(==null||.size()==0) return;
        List<AbsButtonTypelstDataExportButtons=null;
        int i=1;
        for(String dataexportTypeTmp:)
        {
            lstDataExportButtons=null;
            if(this..getButtonsBean()!=nulllstDataExportButtons=this..getButtonsBean().getLstDataExportTypeButtons(dataexportTypeTmp);
            if(!isHasCertainTypeDataExportButton(lstDataExportButtons))
            {//此报表没有配置这种类型的数据导出按钮(注意这里不包括那些在<button/>标签内容中指定了自己导出应用ID的按钮)
                AbsButtonType buttonObj=Config.getInstance().getResourceButton(null,this.getOwner(),
                        ..get(dataexportTypeTmp),DataExportButton.class);
                if(buttonObj.getName()==null||buttonObj.getName().trim().equals(""))
                {
                    buttonObj.setName(DataExportButton.class.getName()+(i++)+"."+(int)(Math.random()*10000));
                }
                if(this. instanceof AbsContainerConfigBean)
                {
                    buttonObj.setPosition("top");
                }
                ComponentConfigLoadManager.addButtonToPositions(this.getOwner(),buttonObj);
            }
        }
        =null;
    }
    private boolean isHasCertainTypeDataExportButton(List<AbsButtonTypelstDataExportButtons)
    {
        if(lstDataExportButtons==null||lstDataExportButtons.size()==0) return false;
        DataExportButton debtnTmp;
        for(AbsButtonType buttonObjTmp:lstDataExportButtons)
        {
            debtnTmp=(DataExportButton)buttonObjTmp;
            if(!debtnTmp.isExportBySpecifyApplicationids()) return true;
        }
        return false;
    }
    {
        try
        {
            DataExportsConfigBean newBean=(DataExportsConfigBean)super.clone();
            newBean.setOwner(owner);
            if(!=null)
            {
                Map<String,AbsDataExportBeanmDataExportBeansNew=new HashMap<String,AbsDataExportBean>();
                for(Entry<String,AbsDataExportBeanentryTmp:this..entrySet())
                {
                    mDataExportBeansNew.put(entryTmp.getKey(),entryTmp.getValue().clone(owner));
                }
                newBean.setMDataExportBeans(mDataExportBeansNew);
            }
            return newBean;
        }catch(CloneNotSupportedException e)
        {
            throw new WabacusConfigLoadingException("clone组件"+this..getPath()+"的数据导出对象失败",e);
        }
    }
New to GrepCode? Check out our FAQ X