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


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
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 version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * MondrianConnection.java
028:         * 
029:         * Created on 4 giugno 2003, 18.15
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.connection;
034:
035:        import it.businesslogic.ireport.*;
036:        import it.businesslogic.ireport.IReportConnectionEditor;
037:        import it.businesslogic.ireport.connection.gui.MondrianConnectionEditor;
038:        import it.businesslogic.ireport.gui.MainFrame;
039:        import it.businesslogic.ireport.util.*;
040:        import java.util.Vector;
041:        import javax.swing.JOptionPane;
042:        import javax.swing.SwingUtilities;
043:        import mondrian.olap.DriverManager;
044:
045:        /**
046:         *
047:         * @author  Administrator
048:         */
049:        public class MondrianConnection extends
050:                it.businesslogic.ireport.IReportConnection {
051:
052:            public static final String CATALOG_URI = "CatalogUri";
053:            public static final String CONNECTION_NAME = "ConnectionName";
054:
055:            private String name;
056:
057:            private java.util.HashMap map = null;
058:            private String persistenceUnit;
059:
060:            private mondrian.olap.Connection mondrianConnection = null;
061:
062:            private int usedby = 0;
063:
064:            /** Creates a new instance of JDBCConnection */
065:
066:            public MondrianConnection() {
067:                map = new java.util.HashMap();
068:            }
069:
070:            /**  This method return an instanced connection to the database.
071:             *  If isJDBCConnection() return false => getConnection() return null
072:             *
073:             */
074:            public java.sql.Connection getConnection() {
075:                return null;
076:            }
077:
078:            public boolean isJDBCConnection() {
079:                return false;
080:            }
081:
082:            public boolean isJRDataSource() {
083:                return false;
084:            }
085:
086:            /*
087:             *  This method return all properties used by this connection
088:             */
089:            public java.util.HashMap getProperties() {
090:                return map;
091:            }
092:
093:            public void loadProperties(java.util.HashMap map) {
094:                this .map = map;
095:            }
096:
097:            /**
098:             *  This method return an instanced JRDataDource to the database.
099:             *  If isJDBCConnection() return true => getJRDataSource() return false
100:             */
101:            public net.sf.jasperreports.engine.JRDataSource getJRDataSource() {
102:                return null;
103:            }
104:
105:            public void closeMondrianConnection() {
106:                try {
107:                    if (getMondrianConnection() != null) {
108:                        usedby--;
109:                        if (usedby == 0) {
110:                            mondrianConnection.close();
111:                            mondrianConnection = null;
112:                        }
113:                    }
114:                } catch (Exception ex) {
115:                }
116:            }
117:
118:            public mondrian.olap.Connection getMondrianConnection()
119:                    throws Exception {
120:
121:                if (mondrianConnection == null) {
122:                    JDBCConnection con = getJDBCConnection();
123:
124:                    mondrianConnection = DriverManager.getConnection(
125:                            "Provider=mondrian;" + "JdbcDrivers="
126:                                    + escapeProperty(con.getJDBCDriver()) + ";"
127:                                    + "Jdbc=" + escapeProperty(con.getUrl())
128:                                    + ";" + "JdbcUser="
129:                                    + escapeProperty(con.getUsername()) + ";"
130:                                    + "JdbcPassword="
131:                                    + escapeProperty(con.getPassword()) + ";"
132:                                    + "Catalog="
133:                                    + escapeProperty(getCatalogUri()) + ";",
134:                            null, false);
135:                }
136:                usedby++;
137:                return mondrianConnection;
138:            }
139:
140:            public void setMondrianConnection(
141:                    mondrian.olap.Connection mondrianConnection) {
142:                this .mondrianConnection = mondrianConnection;
143:            }
144:
145:            public String getCatalogUri() {
146:                return (String) getProperties().get(CATALOG_URI);
147:            }
148:
149:            public void setCatalogUri(String catalogUri) {
150:                getProperties().put(CATALOG_URI, catalogUri);
151:            }
152:
153:            public String getConnectionName() {
154:                return (String) getProperties().get(CONNECTION_NAME);
155:            }
156:
157:            public void setConnectionName(String connectionName) {
158:                getProperties().put(CONNECTION_NAME, connectionName);
159:            }
160:
161:            private JDBCConnection getJDBCConnection() {
162:                String name = getConnectionName();
163:                Vector conns = MainFrame.getMainInstance().getConnections();
164:                for (int i = 0; i < conns.size(); ++i) {
165:                    IReportConnection con = (IReportConnection) conns
166:                            .elementAt(i);
167:                    if (con instanceof  JDBCConnection
168:                            && con.getName().equals(name)) {
169:                        return (JDBCConnection) con;
170:                    }
171:                }
172:
173:                return null;
174:            }
175:
176:            public String escapeProperty(String s) {
177:                if (s == null)
178:                    s = "";
179:                s = Misc.string_replace("\"\"", "\"", s);
180:
181:                return s;
182:            }
183:
184:            public String getDescription() {
185:                return I18n.getString("connectionType.olap",
186:                        "Mondrian OLAP connection");
187:            }
188:
189:            public IReportConnectionEditor getIReportConnectionEditor() {
190:                return new MondrianConnectionEditor();
191:            }
192:
193:            public void test() throws Exception {
194:                try {
195:                    SwingUtilities.invokeLater(new Runnable() {
196:                        public void run() {
197:
198:                            Thread.currentThread().setContextClassLoader(
199:                                    MainFrame.getMainInstance()
200:                                            .getReportClassLoader());
201:                            try {
202:
203:                                getMondrianConnection();
204:                                closeMondrianConnection();
205:                                JOptionPane
206:                                        .showMessageDialog(
207:                                                MainFrame.getMainInstance(),
208:                                                I18n
209:                                                        .getString(
210:                                                                "messages.connectionDialog.connectionTestSuccessful",
211:                                                                "Connection test successful!"),
212:                                                "",
213:                                                JOptionPane.INFORMATION_MESSAGE);
214:
215:                            } catch (Exception ex) {
216:                                ex.printStackTrace();
217:                                JOptionPane.showMessageDialog(MainFrame
218:                                        .getMainInstance(), ex.getMessage(),
219:                                        I18n.getString("message.title.error",
220:                                                "Error"),
221:                                        JOptionPane.ERROR_MESSAGE);
222:                                return;
223:                            } finally {
224:
225:                            }
226:                        }
227:                    });
228:                } catch (Exception ex) {
229:                }
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.