StaticReport.java :  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » reportmanager » Java Open Source

Java Open Source » Report » jmagallanes 1.0 
jmagallanes 1.0 » com » calipso » reportgenerator » reportmanager » StaticReport.java
package com.calipso.reportgenerator.reportmanager;

import com.calipso.reportgenerator.common.*;
import com.calipso.reportgenerator.reportcalculator.DataTree;
import com.calipso.reportgenerator.reportdefinitions.types.FilterDefinitionFilterTypeType;
import com.calipso.reportgenerator.common.InfoException;

/**
 *
 * User: soliveri
 * Date: Dec 15, 2003
 * Time: 5:03:14 PM
 *
 */

public class StaticReport extends Report {

  private DataTree dataTree;

  public StaticReport() throws InfoException{
  }

  public StaticReport(ReportSpec reportSpec, ReportSource reportSource, ReportGeneratorConfiguration configuration) throws InfoException {
    super(reportSpec, reportSource, configuration);
    initialize();
  }

  /**
   * Ejecuta la inicializacin, recolecta toda la informacin que necesita de la definicin del reporte, inicializa
   * los objetos encargados de resolver los clculos y obtiene los valores de parmetros por defecto.
   * @throws InfoException
   */
  private void initialize() throws InfoException {
    try {
       setReportData(new StaticReportData(getReportSpec()));
    } catch (Exception e) {
      throw new InfoException(LanguageTraslator.traslate("48"), e);
    }
  }

  public String getXml() throws InfoException {
    ReportXmlWriter resultWriter = new StaticReportXmlWriter(getReportData(), getReportSpec(), getQuery().getParamValues());
    return resultWriter.getXml().toString();
  }

  public ReportResult ExecQuery(ReportQuery query) throws InfoException {
    if (query == null) {
      throw new InfoException(LanguageTraslator.traslate("49"));
    } else {
      if(!getFiltersByType(getReportSpec(), FilterDefinitionFilterTypeType.RANKING).isEmpty()){
        fillEnumeration(query);
      }
      if(!getFiltersByType(getReportSpec(), FilterDefinitionFilterTypeType.EXCLUDEGROUP).isEmpty()){
        fillExcludedEnumeration(query);
      }
      if(query.isValid()) {
        getReportData().setQuery(query, getPivot());
        dataTree = ((StaticReportData)getReportData()).getDataTree();
      } else {
        throw new InfoException(LanguageTraslator.traslate("50"));
      }
    }
    return new StaticReportResult(getReportSpec(), query, dataTree);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.