Source Code Cross Referenced for StaticReportTableModel.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jmagallanes 1.0 » com.calipso.reportgenerator.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.common;
002:
003:        import com.calipso.reportgenerator.reportcalculator.*;
004:        import com.calipso.reportgenerator.common.ReportTableModel;
005:
006:        import java.util.Vector;
007:        import java.util.Iterator;
008:
009:        /**
010:         *
011:         * User: soliveri
012:         * Date: Dec 16, 2003
013:         * Time: 3:03:05 PM
014:         *
015:         */
016:
017:        public class StaticReportTableModel extends ReportTableModel {
018:
019:            private StaticReportResult reportResult;
020:
021:            public StaticReportTableModel(StaticReportResult reportResult)
022:                    throws InfoException {
023:                super ();
024:                this .reportResult = reportResult;
025:                initialize();
026:            }
027:
028:            public StaticReportTableModel(ReportSpec reportSpec,
029:                    ReportQuery query) {
030:                super ();
031:                initialize(reportSpec, query);
032:            }
033:
034:            public StaticReportTableModel(ReportSpec reportSpec)
035:                    throws InfoException {
036:                super ();
037:                ReportQuery query = new ReportQuery(reportSpec);
038:                initialize(reportSpec, query);
039:            }
040:
041:            private void initialize(ReportSpec reportSpec, ReportQuery query) {
042:                Object[] groupingDimensions;
043:                Object[] nonGroupingDimensions;
044:                groupingDimensions = reportSpec
045:                        .getVisibleDimensionsByGrouping(true);
046:                nonGroupingDimensions = reportSpec
047:                        .getVisibleDimensionsByGrouping(false);
048:                Object[] totalMetrics = reportSpec.getMetrics();
049:                setGroupingDimCount(groupingDimensions.length);
050:                setNonGroupingDimCount(nonGroupingDimensions.length);
051:                setCommonMetricsCount(query.getVisibleMetrics().size());
052:                setAccMetricsCount(query.getVisibleAccumulableMetrics().size());
053:                setTableColumnNames(getSpecTableModelColumns(
054:                        groupingDimensions, nonGroupingDimensions, totalMetrics));
055:                //    setTableData(getTableModelData());
056:                newNonDataTableModel();
057:            }
058:
059:            protected Vector getSpecTableModelColumns(
060:                    Object[] groupingDimensions,
061:                    Object[] nonGroupingDimensions, Object[] metricsArray) {
062:                Vector columnNames = new Vector();
063:                for (int i = 0; i < groupingDimensions.length; i++) {
064:                    ReportDimensionSpec qd = (ReportDimensionSpec) groupingDimensions[i];
065:                    columnNames.add(qd.getName());
066:                }
067:                for (int i = 0; i < nonGroupingDimensions.length; i++) {
068:                    ReportDimensionSpec qd = (ReportDimensionSpec) nonGroupingDimensions[i];
069:                    columnNames.add(qd.getName());
070:                }
071:                for (int i = 0; i < metricsArray.length; i++) {
072:                    ReportMetricSpec qm = (ReportMetricSpec) metricsArray[i];
073:                    columnNames.add(qm.getName());
074:                }
075:                return columnNames;
076:            }
077:
078:            private void initialize() throws InfoException {
079:                Object[] groupingDimensions = getGroupingDimensions();
080:                Object[] nonGroupingDimensions = getNonGroupingDimensions();
081:                Object[] totalMetrics = getTotalMetrics();
082:                setGroupingDimCount(groupingDimensions.length);
083:                setNonGroupingDimCount(nonGroupingDimensions.length);
084:                setCommonMetricsCount(reportResult.getReportQuery()
085:                        .getVisibleMetrics().size());
086:                setAccMetricsCount(reportResult.getReportQuery()
087:                        .getVisibleAccumulableMetrics().size());
088:                setTableColumnNames(getTableModelColumns(groupingDimensions,
089:                        nonGroupingDimensions, totalMetrics));
090:                setTableData(getTableModelData());
091:                newDefaultTableModel();
092:            }
093:
094:            /**
095:             * Obtiene los valores de las Dimensiones que agrupan, es decir, las Row Dimensiones
096:             * a partir de un reporte tipo Static.
097:             * @return array que contiene objetos de tipo QueryDimension
098:             * @throws com.calipso.reportgenerator.common.InfoException
099:             */
100:            private Object[] getGroupingDimensions() throws InfoException {
101:                StaticQuery staticQuery = reportResult.getDataTree().getQuery();
102:                int[] dimensionIndexes = staticQuery.getGroupDimensions();
103:                return getQueryDimensionsArray(dimensionIndexes, reportResult);
104:            }
105:
106:            /**
107:             * Obtiene los valores de las Dimensiones que no agrupan, es decir, las Row Dimensiones
108:             * a partir de un reporte tipo Static.
109:             * @return array que contiene objetos de tipo QueryDimension
110:             * @throws com.calipso.reportgenerator.common.InfoException
111:             */
112:            private Object[] getNonGroupingDimensions() throws InfoException {
113:                StaticQuery staticQuery = reportResult.getDataTree().getQuery();
114:                int[] dimensionIndexes = staticQuery.getNoGroupDimensions();
115:                return getQueryDimensionsArray(dimensionIndexes, reportResult);
116:            }
117:
118:            /**
119:             * Inicializa un array con objetos de tipo QueryDimension.
120:             * @param indexes array que contiene los valores de las dimensiones
121:             * @param reportResult necesario para obtener los valores de las dimensions
122:             * @return array que contiene objetos de tipo QueryDimension
123:             * @throws com.calipso.reportgenerator.common.InfoException
124:             */
125:            private Object[] getQueryDimensionsArray(int[] indexes,
126:                    ReportResult reportResult) throws InfoException {
127:                ReportQuery query = reportResult.getReportQuery();
128:                Object[] result = new Object[indexes.length];
129:                for (int i = 0; i < indexes.length; i++) {
130:                    String name = reportResult.getReportSpec()
131:                            .getDimensionFromIndex(indexes[i]).getName();
132:                    QueryDimension dimension = query
133:                            .getQueryDimensionFromName(name);
134:                    result[i] = dimension;
135:                }
136:                return result;
137:            }
138:
139:            private Object[] getTotalMetrics() {
140:                Object[] metricsNames = reportResult.getReportQuery()
141:                        .getVisibleMetrics().toArray();
142:                Object[] accuMetricsNames = reportResult.getReportQuery()
143:                        .getAccumulableMetrics().toArray();
144:                Object[] allMetrics = new Object[metricsNames.length
145:                        + accuMetricsNames.length];
146:                int i = 0;
147:                for (; i < metricsNames.length; i++) {
148:                    allMetrics[i] = metricsNames[i];
149:                }
150:                for (int j = 0; j < accuMetricsNames.length; j++, i++) {
151:                    QueryMetric queryMetric = (QueryMetric) accuMetricsNames[j];
152:                    queryMetric.setName(queryMetric.getName() + "_ACCUM");//LanguageTraslator.traslate("314")
153:                    allMetrics[i] = queryMetric;
154:                }
155:                return allMetrics;
156:            }
157:
158:            /**
159:             * Devuelve un vector que contiene los datos para el model de la tabla
160:             * para un reporte de tipo estatico
161:             * @return datos para el model de la tabla
162:             */
163:            private Vector getTableModelData() {
164:                DataTree dataTree = reportResult.getDataTree();
165:                return getDataVector(dataTree);
166:            }
167:
168:            /**
169:             * Se ejecuta en caso de que el tipo de Reporte sea Static. Devuelve un vector
170:             * que contiene los datos de la tabla necesarios para generar el modelo
171:             * @param dataTree arbol de datos
172:             * @return datos de la tabla
173:             */
174:            private Vector getDataVector(DataTree dataTree) {
175:                Vector dataVector = new Vector();
176:                Vector previousValues = new Vector();
177:                fillFromNode(dataVector, dataTree.getRoot(), previousValues);
178:                return dataVector;
179:            }
180:
181:            /**
182:             * Itera el arbol de datos y llena un vector que contiene los datos
183:             * en formato plano para generar el modelo de la table
184:             * @param dataVector datos necesarios para generar la tabla
185:             * @param node nodo del arbol de datos
186:             * @param previousValues
187:             */
188:            private void fillFromNode(Vector dataVector, DataTreeNode node,
189:                    Vector previousValues) {
190:                if (node.getSubNodes().size() == 0) {
191:                    Iterator iterator = node.getSubItems().iterator();
192:                    while (iterator.hasNext()) {
193:                        DataTreeSubItem subItem = (DataTreeSubItem) iterator
194:                                .next();
195:                        dataVector.add(getItemVector(previousValues, subItem));
196:                    }
197:                } else {
198:                    Iterator iterator = node.getSubNodes().values().iterator();
199:                    while (iterator.hasNext()) {
200:                        DataTreeNode subNode = (DataTreeNode) iterator.next();
201:                        previousValues.add(subNode.getValue());
202:                        fillFromNode(dataVector, subNode, previousValues);
203:                        previousValues.remove(previousValues.size() - 1);
204:                    }
205:                }
206:            }
207:
208:            /**
209:             * Devuelve un vector que contiene los datos de una fila.
210:             * @param previousValues
211:             * @param subItem
212:             * @return
213:             */
214:            private Vector getItemVector(Vector previousValues,
215:                    DataTreeSubItem subItem) {
216:                Vector itemVector = new Vector(previousValues);
217:                String[] ngValues = subItem.getNonGroupingDimensionValues();
218:                for (int i = 0; i < ngValues.length; i++) {
219:                    String ngValue = ngValues[i];
220:                    itemVector.add(ngValue);
221:                }
222:
223:                SharedFloat[] metricValues = subItem.getMetricValues();
224:                for (int i = 0; i < metricValues.length; i++) {
225:                    SharedFloat metricValue = metricValues[i];
226:                    itemVector.add(new Float(metricValue.floatValue()));
227:                }
228:
229:                SharedFloat[] accMetricValues = subItem
230:                        .getAccumulableMetricValues();
231:                for (int i = 0; i < accMetricValues.length; i++) {
232:                    SharedFloat accMetricValue = accMetricValues[i];
233:                    itemVector.add(new Float(accMetricValue.floatValue()));
234:                }
235:
236:                return itemVector;
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.