Source Code Cross Referenced for JXLSReportManagerImpl.java in  » Report » openreports » org » efs » openreports » engine » 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 » openreports » org.efs.openreports.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*  
002:         * Copyright (C) 2006 by Open Source Software Solutions, LLC and Contributors
003:         *  
004:         * This program is free software; you can redistribute it and/or modify it
005:         * under the terms of the GNU General Public License as published by the Free
006:         * Software Foundation; either version 2 of the License, or (at your option)
007:         * any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful, but WITHOUT
010:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
012:         * more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License along with
015:         * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
016:         * Place - Suite 330, Boston, MA 02111-1307, USA.
017:         *   
018:         * Original Author	:	Lisa Shields 	- brillobaby@gmail.com 
019:         * Contributor(s)	:	Erik Swenson 	- erik@oreports.com
020:         * 
021:         */
022:
023:        package org.efs.openreports.engine;
024:
025:        import org.efs.openreports.providers.DataSourceProvider;
026:        import org.efs.openreports.providers.ProviderException;
027:        import org.apache.log4j.Logger;
028:
029:        import java.sql.Connection;
030:        import java.sql.SQLException;
031:        import java.util.List;
032:        import java.util.Map;
033:
034:        /**
035:         * Extension of the Jxls ReportManagerImpl class,
036:         * making it Open Reports DataSourceProvider aware.  This means 
037:         * JXLS reporting templates can create multiple datasource
038:         * reports in a single workbook.
039:         *
040:         * The standard JXLS xls template tag construct looks like this:
041:         * 	<jx:forEach items="${rm.exec("select email, jobtitle from employees")}" var="x">
042:         *
043:         * The underlaying ReportManagerImpl provides a single exec function,
044:         * with the following signature:
045:         *                     	rm.exec(String sql)
046:         * 
047:         * This class extends the above standard capability, without changing it, by adding
048:         * the following additional Report Manager exec functions:
049:         *
050:         * 			rm.exec(String datasourceName, String sql)
051:         * 			rm.exec(int datasourceId, String sql)
052:         *
053:         * These two additional methods support template constructs as below, enabling
054:         * multiple datasources (or parameter-driven datasource selection) for
055:         * JXLS reports in Open Reports:
056:         *
057:         * 	<jx:forEach items="${rm.exec("OpenReports Sample Data", "select email, jobtitle from employees")}" var="x">
058:         * 	<jx:forEach items="${rm.exec(3, "select email, jobtitle from employees")}" var="x">
059:         *	
060:         */
061:        public class JXLSReportManagerImpl extends
062:                net.sf.jxls.report.ReportManagerImpl {
063:
064:            protected static Logger log = Logger
065:                    .getLogger(JXLSReportManagerImpl.class);
066:
067:            DataSourceProvider dataSourceProvider = null;
068:
069:            public JXLSReportManagerImpl(Connection connection, Map beans,
070:                    DataSourceProvider dataSourceProvider) throws SQLException {
071:                super (connection, beans);
072:                this .dataSourceProvider = dataSourceProvider;
073:            }
074:
075:            // This method allows Open Reports JXLs templates to contain ReportManager
076:            // invocations of the form rm.exec(String datasourceName, String sql), where
077:            // datasourceName can match any report_datasource.NAME configured in the Open Reports Application.
078:            public List exec(String datasourceName, String sql)
079:                    throws SQLException, ProviderException {
080:                List results = null;
081:                log.debug("JXLS exec invoked for datasourceName=["
082:                        + datasourceName + "]");
083:                try {
084:                    results = exec(dataSourceProvider.getDataSource(
085:                            datasourceName).getId(), sql);
086:                } catch (Exception e) {
087:                    String msg = "Unable to complete query against datasourceName=["
088:                            + datasourceName
089:                            + "]."
090:                            + " Please ensure the datasourceName in your xls template is valid."
091:                            + "  Caught exception is "
092:                            + e.getClass().getName()
093:                            + ", message is " + e.getMessage();
094:                    log.error(msg);
095:                    throw new ProviderException(msg);
096:                }
097:                return results;
098:            }
099:
100:            // This new method allows Open Reports JXLs templates to contain ReportManager
101:            // invocations of the form rm.exec(int datasourceId, String sql), where
102:            // datasourceId can match any report_datasource.DATASOURCE_ID configured in the Open Reports Application.
103:            public List exec(Integer datasourceId, String sql)
104:                    throws SQLException, ProviderException {
105:                Connection defaultConnection = super .getConnection();
106:                List list = null;
107:                try {
108:                    super .setConnection(dataSourceProvider
109:                            .getConnection(datasourceId));
110:                    log.debug("JXLS exec sql=[" + sql
111:                            + "] against datasourceId=[" + datasourceId + "]");
112:                    list = super .exec(sql); // invokes net.sf.jxls.report.ReportManagerImpl.exec function
113:                } catch (Exception e) {
114:                    String msg = "Unable to execute sql=["
115:                            + sql
116:                            + "] against datasourceId=["
117:                            + datasourceId
118:                            + "]."
119:                            + " Please ensure the dataSourceId and SQL in your xls template are valid."
120:                            + "  Caught exception is " + e.getClass().getName()
121:                            + ", message is " + e.getMessage();
122:                    log.error(msg);
123:                    throw new ProviderException(msg);
124:                } finally {
125:                    super.setConnection(defaultConnection);
126:                }
127:                return list;
128:            }
129:
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.