KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > connection > JRXMLADataSourceConnection


1 /**
2  * Copyright (C) 2005, 2006 CINCOM SYSTEMS, INC.
3  * All Rights Reserved
4  * www.cincom.com
5  *
6  * JRXMLADataSourceConnection.java
7  * @authors MPenningroth, HMays.
8  */

9
10 package it.businesslogic.ireport.connection;
11 import it.businesslogic.ireport.util.*;
12 import java.util.Map JavaDoc;
13 import net.sf.jasperreports.engine.JRException;
14 import net.sf.jasperreports.engine.query.JRXmlaQueryExecuterFactory;
15 import rex.graphics.datasourcetree.elements.*;
16
17 public class JRXMLADataSourceConnection extends it.businesslogic.ireport.IReportConnection {
18     
19     private String JavaDoc url;
20     
21     
22     /** Creates a new instance of JRXMLADataSourceConnection */
23     public JRXMLADataSourceConnection() {
24         
25     }
26     
27     /**
28      * Returns the url of XMLA Server.
29      * @return Value of property url.
30      */

31     public String JavaDoc getUrl() {
32         return this.url;
33     }
34     
35     /**
36      * Setter method for url.
37      * @param <code>String</code> assigns value of the <code>url </code>
38      */

39     public void setUrl(String JavaDoc url) {
40         this.url = url;
41     }
42     /**
43      * Returns XMLA Datasource
44      */

45     public String JavaDoc getDescription(){ return "XMLA Datasource"; }
46     
47     public java.util.HashMap JavaDoc getProperties() {
48         java.util.HashMap JavaDoc map = new java.util.HashMap JavaDoc();
49         map.put("url", Misc.nvl(this.getUrl(),"") );
50         map.put("datasource", Misc.nvl(this.getDatasource(),"") );
51         map.put("catalog", Misc.nvl(this.getCatalog(),"") );
52         map.put("cube", Misc.nvl(this.getCube(),"") );
53         return map;
54     }
55     /**
56      * Assigns the values of Url, Datasource, Catalog, Cube
57      */

58     public void loadProperties(java.util.HashMap JavaDoc map) {
59         this.setUrl( (String JavaDoc)map.get("url"));
60         this.setDatasource((String JavaDoc)map.get("datasource"));
61         this.setCatalog((String JavaDoc)map.get("catalog"));
62         this.setCube((String JavaDoc)map.get("cube"));
63     }
64     
65     /**
66      * Holds value of property datasource.
67      */

68     private String JavaDoc datasource;
69     
70     /**
71      * Getter for property datasource.
72      * @return Value of property datasource.
73      */

74     public String JavaDoc getDatasource() {
75         return this.datasource;
76     }
77     
78     /**
79      * Setter for property datasource.
80      * @param datasource New value of property datasource.
81      */

82     public void setDatasource(String JavaDoc datasource) {
83         this.datasource = datasource;
84     }
85     
86     /**
87      * Holds value of property catalog.
88      */

89     private String JavaDoc catalog;
90     
91     /**
92      * Getter for property catalog.
93      * @return Value of property catalog.
94      */

95     public String JavaDoc getCatalog() {
96         return this.catalog;
97     }
98     
99     /**
100      * Setter for property catalog.
101      * @param catalog New value of property catalog.
102      */

103     public void setCatalog(String JavaDoc catalog) {
104         this.catalog = catalog;
105     }
106     
107     /**
108      * Holds value of property cube.
109      */

110     private String JavaDoc cube;
111     
112     /**
113      * Getter for property cube.
114      * @return Value of property cube.
115      */

116     public String JavaDoc getCube() {
117         return this.cube;
118     }
119     
120     /**
121      * Setter for property cube.
122      * @param cube New value of property cube.
123      */

124     public void setCube(String JavaDoc cube) {
125         this.cube = cube;
126     }
127     
128
129     /*
130    * Return true if this ireport connection can be used using getJRDataSource
131    * I.E. you can see JDBCConnection
132    */

133   public boolean isJRDataSource() { return false; }
134   
135
136   /**
137      * This method is call before the datasource is used and permit to add special parameters to the map
138      *
139      */

140     public Map JavaDoc getSpecialParameters(Map JavaDoc map) throws net.sf.jasperreports.engine.JRException
141     {
142        //System.out.println("Starting XMLA MDX Query");
143
map.put(JRXmlaQueryExecuterFactory.PARAM_XMLA_URL, getUrl());
144         map.put(JRXmlaQueryExecuterFactory.PARAM_XMLA_DS, getDatasource());
145         map.put(JRXmlaQueryExecuterFactory.PARAM_XMLA_CAT, getCatalog());
146         
147         
148         map.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL, getUrl());
149         map.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE, getDatasource());
150         map.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG, getCatalog());
151
152         //System.out.println("XMLA MDX Query completed");
153

154         return map;
155     }
156     
157     /**
158      * This method is call after the datasource is used to dispose special parameters
159      * (i.e. closing an Hibernate session create as parameter with a getSpecialParameters...
160      *
161      */

162     public Map JavaDoc disposeSpecialParameters(Map JavaDoc map)
163     {
164         return map;
165     }
166 }
167
Popular Tags