Source Code Cross Referenced for CincomMDXFieldsProvider.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » data » 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 » iReport 2.0.5 » it.businesslogic.ireport.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         * Copyright (C) 2005, 2006 CINCOM SYSTEMS, INC.
004:         * All Rights Reserved
005:         * www.cincom.com
006:         *
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License as published by
010:         * the Free Software Foundation; either version 2 of the License, or
011:         * (at your option) any later version.
012:         *
013:         * This program is distributed WITHOUT ANY WARRANTY; and without the
014:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
015:         * See the GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
019:         * or write to:
020:         *
021:         * Free Software Foundation, Inc.,
022:         * 59 Temple Place - Suite 330,
023:         * Boston, MA  USA  02111-1307
024:         *
025:         *
026:         * CincomMDXFieldsProvider.java
027:         *
028:         * Created on December 18, 2006, 2:28 PM
029:         *
030:         * To change this template, choose Tools | Template Manager
031:         * and open the template in the editor.
032:         */
033:
034:        package it.businesslogic.ireport.data;
035:
036:        import it.businesslogic.ireport.FieldsProviderEditor;
037:        import it.businesslogic.ireport.IReportConnection;
038:        import it.businesslogic.ireport.connection.JRXMLADataSourceConnection;
039:        import it.businesslogic.ireport.gui.ReportQueryDialog;
040:        import java.util.Map;
041:        import net.sf.jasperreports.engine.JRDataset;
042:        import net.sf.jasperreports.engine.JRException;
043:
044:        import net.sf.jasperreports.engine.JRField;
045:        import net.sf.jasperreports.engine.design.JRDesignField;
046:
047:        /**
048:         *
049:         * @author gtoffoli
050:         */
051:        public class CincomMDXFieldsProvider extends MDXFieldsProvider {
052:
053:            private final String axis0 = "Axis0";
054:            private final String axis1 = "Axis1";
055:            private final String slicer = "SlicerAxis";
056:            private final char leftPar = '[';
057:            private final char rightPar = ']';
058:            public static java.util.ArrayList dimensionsList = new java.util.ArrayList();
059:            private boolean foundMeasure; // to handle queries with no explicit measure in them
060:
061:            /** Creates a new instance of CincomMDXFieldsProvider */
062:            public CincomMDXFieldsProvider() {
063:                super ();
064:            }
065:
066:            public boolean supportsGetFieldsOperation() {
067:                return true;
068:            }
069:
070:            public boolean supportsAutomaticQueryExecution() {
071:                return true;
072:            }
073:
074:            public boolean hasEditorComponent() {
075:                return false;
076:            }
077:
078:            public FieldsProviderEditor getEditorComponent(
079:                    ReportQueryDialog reportQueryDialog) {
080:
081:                return null;
082:            }
083:
084:            public JRField[] getFields(IReportConnection con,
085:                    JRDataset reportDataset, Map parameters)
086:                    throws JRException, UnsupportedOperationException {
087:                /**
088:                 * Copyright (C) 2006 CINCOM SYSTEMS, INC.
089:                 * All Rights Reserved
090:                 * www.cincom.com
091:                 */
092:                if (con instanceof  it.businesslogic.ireport.connection.JRXMLADataSourceConnection) {
093:                    try {
094:                        String query = reportDataset.getQuery().getText();
095:
096:                        java.util.ArrayList v_fields = getFields(query,
097:                                (JRXMLADataSourceConnection) con);
098:
099:                        // Translate 
100:                        JRField[] final_fields = new JRField[v_fields.size()];
101:                        for (int i = 0; i < v_fields.size(); ++i) {
102:                            XmlaFieldNode f = (XmlaFieldNode) v_fields.get(i);
103:                            JRDesignField field = new JRDesignField();
104:                            field.setName(f.getName());
105:                            field.setValueClassName(f.getClassType());
106:                            field.setDescription(f.getDescription());
107:                            final_fields[i] = field;
108:                        }
109:
110:                        return final_fields;
111:
112:                    } catch (Exception ex) {
113:                        throw new JRException(ex);
114:                    }
115:                } else {
116:                    throw new JRException(
117:                            "The active connection is not of type XMLA. Activate an XMLA connection first.");
118:                }
119:            }
120:
121:            /**
122:             * Returns the Fields discovered for the MDX Query
123:             * @param : Query String
124:             * @param : status is added to return the appropriate field values
125:             * Reason : to handle the Wizard Dialog and ReportQuery Dialog issue
126:             * ReportQueryDialog looks for a jTable / ArrayList
127:             * WizardDialog looks for a jList / List
128:             * status == true implies that the call is from WizardDialog
129:             *           false imples that the call is from ReportQueryDialog.
130:             * 
131:             */
132:            public java.util.ArrayList getFields(String query,
133:                    JRXMLADataSourceConnection con) throws java.lang.Exception {
134:                foundMeasure = false;
135:                it.businesslogic.ireport.data.XmlaFieldNode fld2;
136:                java.util.ArrayList fields = new java.util.ArrayList();
137:                rex.metadata.ServerMetadata smd = new rex.metadata.ServerMetadata(
138:                        con.getUrl(), null);
139:                if (smd.isValidUrl() == false) {
140:                    return null;
141:                }
142:                rex.xmla.RexXMLAExecuteProperties rexProperties = new rex.xmla.RexXMLAExecuteProperties();
143:                rexProperties.setDataSourceInfo(con.getDatasource());
144:                rexProperties.setCatalog(con.getCatalog());
145:                this .dimensionsList.clear();
146:                try {
147:                    rex.metadata.ExecuteResult eResult = new rex.metadata.ExecuteResult(
148:                            smd.execute(query, rexProperties), null);
149:                    if (!addMDXAxisColumns(fields, eResult, axis0)) {
150:                        return null;
151:                    }
152:                    if (!addMDXAxisColumns(fields, eResult, axis1)) {
153:                        return null;
154:                    }
155:                    if (!addMDXAxisColumns(fields, eResult, slicer)) {
156:                        return null;
157:                    }
158:                    //if no measure was explicitly parsed, then add one to pick up the default (ALL) measure:
159:                    if (!foundMeasure) {
160:                        fld2 = new it.businesslogic.ireport.data.XmlaFieldNode(
161:                                "DefaultMeasure", 2);
162:                        fld2.setDescription("DefaultMeasure");
163:
164:                        fields.add(fld2);
165:                    }
166:                    eResult = null;
167:                    rexProperties = null;
168:                    smd = null;
169:                }
170:
171:                catch (Exception e) {
172:                    throw e;
173:                }
174:                return fields;
175:            }
176:
177:            /**
178:             * Adds all the Dimensions and measures found on Rows, Columns and Slicer axis
179:             * 
180:             * @param fields : All the dimension / measures discovered are added and returned
181:             * @param : status is added to return the appropriate field values
182:             * Reason : to handle the Wizard Dialog and ReportQuery Dialog issue
183:             * ReportQueryDialog looks for a jTable / ArrayList
184:             * WizardDialog looks for a jList / List
185:             * status == true implies that the call is from WizardDialog
186:             *           false imples that the call is from ReportQueryDialog.
187:             *
188:             */
189:            private boolean addMDXAxisColumns(java.util.ArrayList fields,
190:                    rex.metadata.ExecuteResult eResult, String axisName) {
191:                java.util.HashSet fSet = new java.util.HashSet();
192:
193:                int axisNo = -1;
194:                if (eResult == null || fields == null || axisName == null) {
195:                    return false;
196:                }
197:                if ((axisName.compareTo(axis0) != 0)
198:                        && (axisName.compareTo(axis1) != 0)
199:                        && (axisName.compareTo(slicer) != 0)) {
200:                    return false;
201:                }
202:                rex.metadata.resultelements.Axis axis = eResult
203:                        .getAxis(axisName);
204:                if (axis == null) {
205:                    return false;
206:                }
207:                rex.metadata.resultelements.HierarchyInfo hierInfo;
208:                rex.metadata.resultelements.Tuple tuple;
209:
210:                if (axisName.compareTo(axis0) == 0) {
211:                    axisNo = 0;
212:                } else {
213:                    axisNo = 1;
214:                }
215:                tuple = null;
216:
217:                it.businesslogic.ireport.data.XmlaFieldNode fld;
218:                String longName = "";
219:                String shortName = "";
220:
221:                int hierarchyCount = axis.getHierarchyInfoCount();
222:                for (int hierIndex = 0; hierIndex < hierarchyCount; hierIndex++) {
223:                    hierInfo = axis.getHierarchyInfoAt(hierIndex);
224:                    if (hierInfo == null) {
225:                        return false;
226:                    }
227:
228:                    int tupleCount = axis.getTupleCount(); // ham 9/11/06
229:                    for (int tupleIndex = 0; tupleIndex < tupleCount; tupleIndex++) {
230:                        tuple = axis.getTupleAt(tupleIndex);
231:                        // following loop  for multiple dimensions in one (slicer) tuple
232:                        // references within this loop to getMemberAt(0) were changed to getMemberAt(tupleMemberIndex)
233:                        int tupleMemberCount = tuple.getMemberCount();
234:                        for (int tupleMemberIndex = 0; tupleMemberIndex < tupleMemberCount; tupleMemberIndex++) {
235:                            if (tuple.getMemberAt(tupleMemberIndex).isMeasure()) {
236:                                foundMeasure = true;
237:
238:                                longName = tuple.getMemberAt(tupleMemberIndex)
239:                                        .getUniqueName();
240:
241:                                shortName = longName.substring(longName
242:                                        .lastIndexOf(leftPar) + 1, longName
243:                                        .lastIndexOf(rightPar));
244:
245:                                // following IF and adding it to FSET added for duplicate fields in query problem
246:
247:                                if (!fSet.contains(shortName)) {
248:
249:                                    fld = new it.businesslogic.ireport.data.XmlaFieldNode(
250:                                            shortName, axisNo);
251:                                    fld.setDescription(longName);
252:                                    fSet.add(shortName);
253:
254:                                    // Checking the status and add the appropirte values to fields
255:                                    //if (status.booleanValue()){  //this incase of WizardDialog
256:                                    fields.add(fld);
257:                                    //} else{  //case of ReportQueryDialog
258:                                    //    fields.add(new Object[]{fld,fld.getClassType(),fld.getDescription()});
259:                                    //}
260:                                }
261:                            } else {
262:
263:                                longName = tuple.getMemberAt(tupleMemberIndex)
264:                                        .getLname();
265:
266:                                shortName = longName.substring(longName
267:                                        .lastIndexOf(leftPar) + 1, longName
268:                                        .lastIndexOf(rightPar));
269:                                if (!fSet.contains(shortName)) {
270:                                    fld = new it.businesslogic.ireport.data.XmlaFieldNode(
271:                                            shortName, axisNo);
272:                                    fld.setDescription(longName);
273:                                    fSet.add(shortName);
274:
275:                                    // Checking the status and add the appropirte values to fields
276:
277:                                    //if (status.booleanValue()){  //this incase of WizardDialog
278:                                    fields.add(fld);
279:
280:                                    if (!this .dimensionsList.contains(fld)) {
281:                                        this .dimensionsList.add(fld);
282:                                    }
283:
284:                                    //} else{  //case of ReportQueryDialog
285:                                    //    fields.add(new Object[]{fld,fld.getClassType(),fld.getDescription()});
286:
287:                                    //    if(!this.dimensionsList.contains(fld)){
288:                                    //          this.dimensionsList.add(new Object[]{fld,fld.getClassType(),fld.getDescription()});
289:                                    //    }
290:                                    //}
291:
292:                                }
293:                            }
294:                        }
295:                    }
296:
297:                }
298:                return true;
299:            }
300:
301:            /**
302:             * Helper method to return the dimensions discoverd in the MDX Query
303:             */
304:            public static java.util.ArrayList getDimensions() {
305:                return dimensionsList;
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.