KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportmanager > CubeReportData


1 package com.calipso.reportgenerator.reportmanager;
2
3 import com.calipso.reportgenerator.reportcalculator.Cube;
4 import com.calipso.reportgenerator.reportcalculator.Pivot;
5 import com.calipso.reportgenerator.reportcalculator.CubeQuery;
6 import com.calipso.reportgenerator.common.ReportQuery;
7 import com.calipso.reportgenerator.common.ReportSpec;
8 import com.calipso.reportgenerator.common.InfoException;
9
10 import java.util.Iterator JavaDoc;
11 import java.util.Set JavaDoc;
12
13 /**
14  * Representa los datos para un reporte de tipo Cube
15  */

16 public class CubeReportData extends ReportData {
17   private Cube cube;
18
19   /**
20    * Inicializa una instancia de <code>CubeReportData</code>
21     * @param reportSpec
22    */

23   public CubeReportData(ReportSpec reportSpec){
24     super(reportSpec);
25     cube = new Cube();
26     cube.setDefinition(reportSpec);
27   }
28
29   /**
30    * Devuelve el Cube correspondiente al <code>CubeReportData</code>
31    * @return
32    */

33   protected Cube getCube() {
34     return cube;
35   }
36
37   public Iterator JavaDoc valuesFor(int dimension, int[] previousDimensions, Object JavaDoc[] values) {
38     return getCube().valuesFor(dimension, previousDimensions, values);
39   }
40
41   /**
42    * Retorna el iterador del <code>CubeReportData</code>
43    * @return
44    */

45   public ReportDataIterator iterator() {
46     return new CubeReportDataIterator(getCube().iterator());
47   }
48
49   public Object JavaDoc[] measuresAtDimensionsValues(int[] dimensions, Object JavaDoc[] values) {
50     return getCube().measuresAtDimensionsValues(dimensions, values);
51   }
52
53   /**
54    * Asigna la <code>CubeQuery</code> a la instancia de <code>Cube</code>
55    * @param query
56    * @param pivot
57    * @throws InfoException
58    */

59   protected void doSetQuery(ReportQuery query, Pivot pivot) throws InfoException {
60     CubeQuery oldQuery = getCube().getQuery();
61     CubeQuery newQuery = query.getCubeQuery();
62     boolean eqvQuery = newQuery.equivalentQuery(oldQuery);
63     getCube().setQuery(newQuery);
64     if (!eqvQuery) {
65       pivot.fill(getCube());
66     }
67   }
68
69   /**
70    * Devuelve un conjunto de datos del Cube
71    * que representan los valores de
72    * las dimensiones
73    * @return
74    */

75   public Set JavaDoc[] getDimensionValues() {
76     return getCube().getDimensionValues();
77   }
78
79   public Object JavaDoc[] getMetricValues(int[] groupingDimensionsIndexArray, Object JavaDoc[] values){
80       return getCube().getMetricsValuesAt(groupingDimensionsIndexArray, values);
81   }
82
83   public Set JavaDoc getDimensionValues(int index) throws InfoException {
84     return getCube().getDimensionValues(index);
85   }
86
87 }
88
Popular Tags