01: package com.calipso.reportgenerator.reportmanager;
02:
03: import com.calipso.reportgenerator.common.*;
04: import com.calipso.reportgenerator.reportcalculator.DataTree;
05: import com.calipso.reportgenerator.reportdefinitions.types.FilterDefinitionFilterTypeType;
06: import com.calipso.reportgenerator.common.InfoException;
07:
08: /**
09: *
10: * User: soliveri
11: * Date: Dec 15, 2003
12: * Time: 5:03:14 PM
13: *
14: */
15:
16: public class StaticReport extends Report {
17:
18: private DataTree dataTree;
19:
20: public StaticReport() throws InfoException {
21: }
22:
23: public StaticReport(ReportSpec reportSpec,
24: ReportSource reportSource,
25: ReportGeneratorConfiguration configuration)
26: throws InfoException {
27: super (reportSpec, reportSource, configuration);
28: initialize();
29: }
30:
31: /**
32: * Ejecuta la inicialización, recolecta toda la información que necesita de la definición del reporte, inicializa
33: * los objetos encargados de resolver los cálculos y obtiene los valores de parámetros por defecto.
34: * @throws InfoException
35: */
36: private void initialize() throws InfoException {
37: try {
38: setReportData(new StaticReportData(getReportSpec()));
39: } catch (Exception e) {
40: throw new InfoException(LanguageTraslator.traslate("48"), e);
41: }
42: }
43:
44: public String getXml() throws InfoException {
45: ReportXmlWriter resultWriter = new StaticReportXmlWriter(
46: getReportData(), getReportSpec(), getQuery()
47: .getParamValues());
48: return resultWriter.getXml().toString();
49: }
50:
51: public ReportResult ExecQuery(ReportQuery query)
52: throws InfoException {
53: if (query == null) {
54: throw new InfoException(LanguageTraslator.traslate("49"));
55: } else {
56: if (!getFiltersByType(getReportSpec(),
57: FilterDefinitionFilterTypeType.RANKING).isEmpty()) {
58: fillEnumeration(query);
59: }
60: if (!getFiltersByType(getReportSpec(),
61: FilterDefinitionFilterTypeType.EXCLUDEGROUP)
62: .isEmpty()) {
63: fillExcludedEnumeration(query);
64: }
65: if (query.isValid()) {
66: getReportData().setQuery(query, getPivot());
67: dataTree = ((StaticReportData) getReportData())
68: .getDataTree();
69: } else {
70: throw new InfoException(LanguageTraslator
71: .traslate("50"));
72: }
73: }
74: return new StaticReportResult(getReportSpec(), query, dataTree);
75: }
76:
77: }
|