KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > mondrian > MondrianDrillThrough


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.mondrian;
14
15 import mondrian.olap.Util.PropertyList;
16 import mondrian.rolap.RolapConnectionProperties;
17
18 import com.tonbeller.jpivot.core.ExtensionSupport;
19 import com.tonbeller.jpivot.olap.model.Cell;
20 import com.tonbeller.jpivot.olap.navi.DrillThrough;
21 import com.tonbeller.wcf.table.TableModel;
22 /**
23  * @author Robin Bagot
24  *
25  * Implementation of the DrillExpand Extension for Mondrian Data Source.
26 */

27 public class MondrianDrillThrough extends ExtensionSupport implements DrillThrough {
28
29   private boolean extendedContext = true;
30
31   /**
32    * Constructor sets ID
33    */

34   public MondrianDrillThrough() {
35     super.setId(DrillThrough.ID);
36   }
37
38   /**
39    * drill through is possible if <code>member</code> is not calculated
40    */

41   public boolean canDrillThrough(Cell cell) {
42     return ((MondrianCell) cell).getMonCell().canDrillThrough();
43     //String sql = ((MondrianCell) cell).getMonCell().getDrillThroughSQL(extendedContext);
44
//return sql != null;
45
}
46
47   /**
48    * does a drill through, retrieves data that makes up the selected Cell
49    */

50   public TableModel drillThrough(Cell cell) {
51     String JavaDoc sql = ((MondrianCell) cell).getMonCell().getDrillThroughSQL(extendedContext);
52     if (sql == null) {
53       throw new NullPointerException JavaDoc("DrillThroughSQL returned null");
54     }
55     MondrianDrillThroughTableModel dtm = new MondrianDrillThroughTableModel();
56     dtm.setSql(sql);
57     PropertyList connectInfo = ((MondrianModel) getModel()).getConnectProperties();
58     String JavaDoc jdbcUrl = connectInfo.get(RolapConnectionProperties.Jdbc.name());
59     String JavaDoc jdbcUser = connectInfo.get(RolapConnectionProperties.JdbcUser.name());
60     String JavaDoc jdbcPassword = connectInfo.get(RolapConnectionProperties.JdbcPassword.name());
61     String JavaDoc dataSourceName = connectInfo.get(RolapConnectionProperties.DataSource.name());
62     dtm.setJdbcUrl(jdbcUrl);
63     dtm.setJdbcUser(jdbcUser);
64     dtm.setJdbcPassword(jdbcPassword);
65     dtm.setDataSourceName(dataSourceName);
66     return dtm;
67   }
68
69   public boolean isExtendedContext() {
70     return extendedContext;
71   }
72
73   public void setExtendedContext(boolean extendedContext) {
74     this.extendedContext = extendedContext;
75   }
76
77 }
78
Popular Tags