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.component.application.report;
 
 import java.util.List;
 import java.util.Map;
 
 
 public class SqlBean extends AbsConfigBean
 {
     public final static int STMTYPE_STATEMENT=1;
     
     public final static int STMTYPE_PREPAREDSTATEMENT=2;
     
     private int stmttype=;
 
     private String datasource;//此报表所使用的数据源,默认为wabacus.cfg.xml中<datasources/>标签中的default属性配置的值
 
 //    private Object searchTemplateObj;//搜索栏的显示模板,可能是字符串或TemplateBean
     
 
     private Map<String,ConditionBeanmConditions;//运行时由lstConditions生成,方便根据<condition/>的name属性取到对应的ConditionBean对象
     
     
     private String beforeSearchMethod;
     
     private List<ReportDataSetBeanlstDatasetBeans;//存放所有<value/>子标签,存放顺序为它们的执行顺序
     
     
     public SqlBean(AbsConfigBean parent)
     {
         super(parent);
     }
 
     public int getStatementType()
     {
         return this.;
     }
     
     public String getBeforeSearchMethod()
     {
         return ;
     }
 
     public void setBeforeSearchMethod(String beforeSearchMethod)
     {
         this.=beforeSearchMethod;
     }
    
     //$ByQXO
      private String statementTypeName;
      
      public String getStatementTypeName()
      {
          return ;
      }
 
     public void setStatementType(String statementtype)
     {
         if(statementtype==null||statementtype.trim().equals(""))
             statementtype=Config.getInstance().getSystemConfigValue("default-sqltype","statement");
         statementtype=statementtype.toLowerCase().trim();
          =statementtype;
         
         if(statementtype.equals("statement"))
         {
             this.=;
         }else if(statementtype.equals("preparedstatement"))
         {
             this.=;
         }
     }
 //ByQXO$
    
    {
        return ;
    }
    public void setLstConditions(List<ConditionBeanlstConditions)
    {
        this.=lstConditions;
    }
    public String getDatasource()
    {
        return ;
    }
    public void setDatasource(String datasource)
    {
        this.=datasource;
    }
    
    {
        return ;
    }
    
    public void setLstDatasetBeans(List<ReportDataSetBeanlstDatasetBeans)
    {
        this.=lstDatasetBeans;
        if(lstDatasetBeans==null||lstDatasetBeans.size()==0)
        {
            this.=null;
        }else
        {
            this.=new HashMap<String,ReportDataSetBean>();
            for(ReportDataSetBean dsbeanTmp:this.)
            {
                .put(dsbeanTmp.getId(),dsbeanTmp);
            }
        }
    }
    public boolean isMultiDatasetRows()
    {
        return this.!=null&&this..size()>1;
    }
    
    public boolean isMultiDataSetCols()
    {
        if(this.==null||this..size()==0) return false;
        for(ReportDataSetBean datasetBeanTmp:this.)
        {
            if(datasetBeanTmp.getLstValueBeans()!=null&&datasetBeanTmp.getLstValueBeans().size()>1) return true;
        }
        return false;
    }
    
    public ReportDataSetBean getDatasetBeanById(String datasetid)
    {
        if(this.==nullreturn null;
        if(datasetid==null||datasetid.trim().equals("")) datasetid=.;
        return this..get(datasetid);
    }
    
    {
        if(this.==nullreturn null;
        if(valueid==null||valueid.trim().equals("")) valueid=.;
        List<ReportDataSetValueBeanlstResults=new ArrayList<ReportDataSetValueBean>();
        ReportDataSetValueBean dsvbeanTmp;
        for(ReportDataSetBean dsbeanTmp:this.)
        {
            dsvbeanTmp=dsbeanTmp.getDatasetValueBeanById(valueid);
            if(dsvbeanTmp!=nulllstResults.add(dsvbeanTmp);
        }
        return lstResults;
    }
    
    public boolean isExistDependentDataset(String dsvalueid)
    {
        if(==nullreturn false;
        if(dsvalueid==null||dsvalueid.trim().equals("")) dsvalueid=.;
        for(ReportDataSetBean dsbeanTmp:)
        {
            if(dsbeanTmp.isDependentDatasetValue(dsvalueid)) return true;
        }
        return false;
    }
    
    {
        if(==null&&!=null&&.size()>0)
        {
            List<StringlstConditionFromRequestNamesTmp=new ArrayList<String>();
            for(ConditionBean cbeanTmp:)
            {
                if(cbeanTmp==null||cbeanTmp.isConstant()) continue;
                if(cbeanTmp.isConditionValueFromUrl()) lstConditionFromRequestNamesTmp.add(cbeanTmp.getName());
            }
            this.=lstConditionFromRequestNamesTmp;
        }
        return ;
    }
    public void setLstConditionFromRequestNames(List<StringlstConditionFromRequestNames)
    {
        this.=lstConditionFromRequestNames;
    }
    {
        if(name==null||name.trim().equals("")) return null;
        if(this.==null||this..size()==0) return null;
        if(this.==null)
        {
            Map<String,ConditionBeanmConditionsTmp=new HashMap<String,ConditionBean>();
            for(ConditionBean cbTmp:)
            {
                mConditionsTmp.put(cbTmp.getName(),cbTmp);
            }
            this.=mConditionsTmp;
        }
        return this..get(name);
    }
    public void initConditionValues(ReportRequest rrequest)
    {
        if(this.==null||this..size()==0) return;
        Map<String,StringmConditionValues=new HashMap<String,String>();
        for(ConditionBean cbean:)
        {
            cbean.initConditionValueByInitMethod(rrequest,mConditionValues);
        }
        for(ConditionBean cbean:)
        {
            cbean.validateConditionValue(rrequest,mConditionValues);
        }
    }
    
    public boolean isExistConditionWithInputbox(ReportRequest rrequest)
    {
        if(this.==null||this..size()==0) return false;
        for(ConditionBean cbeanTmp:this.)
        {
            if(!cbeanTmp.isConditionWithInputbox()) continue;
            if(rrequest!=null
                    &&!rrequest.checkPermission(this.getReportBean().getId(),.,cbeanTmp.getName(),.))
                continue;
            return true;
        }
        return false;
    }
    
    {
        if(this.==null||this..size()==0) return null;
        List<ConditionBeanlstConditionsResult=new ArrayList<ConditionBean>();
        for(ConditionBean cbeanTmp:this.)
        {
            if(!cbeanTmp.isConditionWithInputbox()) continue;
            if(rrequest!=null
                    &&!rrequest.checkPermission(this.getReportBean().getId(),.,cbeanTmp.getName(),.))
                continue;
            lstConditionsResult.add(cbeanTmp);
        }
        return ;
    }
    
    public void afterSqlLoad()
    {
        if(==nullreturn;
        for(ReportDataSetBean dsbeanTmp:)
        {
            dsbeanTmp.afterSqlLoad();
        }
    }
    
    public void doPostLoad()
    {
        if(this.!=null)
        {
            List<StringlstTmp=new ArrayList<String>();
            for(ConditionBean cbTmp:)
            {
                if(cbTmp==null||cbTmp.getName()==nullcontinue;
                if(lstTmp.contains(cbTmp.getName()))
                {
                    throw new WabacusConfigLoadingException("报表 "+this.getReportBean().getPath()+"配置的查询条件name:"+cbTmp.getName()+"存在重复,必须确保唯一");
                }
                lstTmp.add(cbTmp.getName());
                cbTmp.doPostLoad();
            }
        }
        if(!=null)
        {
            for(ReportDataSetBean dsbeanTmp:this.)
            {
                for(ReportDataSetValueBean svbeanTmp:dsbeanTmp.getLstValueBeans())
                {
                    svbeanTmp.doPostLoad();
                }
            }
        }
    }
    
    public AbsConfigBean clone(AbsConfigBean parent)
    {
        SqlBean sbeanNew=(SqlBean)super.clone(parent);
        ((ReportBean)parent).setSbean(sbeanNew);
        sbeanNew.setLstConditions(ComponentConfigLoadAssistant.getInstance().cloneLstConditionBeans(sbeanNew,));
        if(!=null)
        {
        }
        if(!=null)
        {
            List<ReportDataSetBeanlstDataSetBeansNew=new ArrayList<ReportDataSetBean>();
            Map<String,ReportDataSetBeanmDatasetBeansNew=new HashMap<String,ReportDataSetBean>();
            ReportDataSetBean rdsbeanTmp;
            for(ReportDataSetBean svbeanTmp:)
            {
                rdsbeanTmp=(ReportDataSetBean)svbeanTmp.clone(sbeanNew);
                lstDataSetBeansNew.add(rdsbeanTmp);
                mDatasetBeansNew.put(rdsbeanTmp.getId(),rdsbeanTmp);
            }
            sbeanNew.lstDatasetBeans=lstDataSetBeansNew;
            sbeanNew.mDatasetBeans=mDatasetBeansNew;
        }
        cloneExtendConfig(sbeanNew);
        return sbeanNew;
    }
New to GrepCode? Check out our FAQ X