1 11 package com.tonbeller.jpivot.mondrian.script; 12 13 import mondrian.olap.Util.PropertyList; 14 import mondrian.rolap.RolapConnectionProperties; 15 16 import com.tonbeller.jpivot.core.ExtensionSupport; 17 import com.tonbeller.jpivot.mondrian.MondrianCell; 18 import com.tonbeller.jpivot.mondrian.MondrianModel; 19 import com.tonbeller.jpivot.olap.model.Cell; 20 import com.tonbeller.jpivot.olap.navi.DrillThrough; 21 import com.tonbeller.wcf.table.TableModel; 22 27 public class ScriptableMondrianDrillThrough extends ExtensionSupport implements DrillThrough { 28 29 private boolean extendedContext = true; 30 31 34 public ScriptableMondrianDrillThrough() { 35 super.setId(DrillThrough.ID); 36 } 37 38 41 public boolean canDrillThrough(Cell cell) { 42 return ((MondrianCell) cell).getMonCell().canDrillThrough(); 43 } 46 47 50 public TableModel drillThrough(Cell cell) { 51 String sql = ((MondrianCell) cell).getMonCell().getDrillThroughSQL(extendedContext); 52 if (sql == null) { throw new NullPointerException ("DrillThroughSQL returned null"); } 53 ScriptableMondrianDrillThroughTableModel dtm = new ScriptableMondrianDrillThroughTableModel(); 54 dtm.setSql(sql); 55 String connectString = getConnection().getConnectString(); 56 PropertyList connectInfo = mondrian.olap.Util.parseConnectString(connectString); 57 String jdbcUrl = connectInfo.get(RolapConnectionProperties.Jdbc.name()); 58 dtm.setJdbcUrl(jdbcUrl); 59 String jdbcUser = connectInfo.get(RolapConnectionProperties.JdbcUser.name()); 60 dtm.setJdbcUser(jdbcUser); 61 String jdbcPassword = connectInfo.get(RolapConnectionProperties.JdbcPassword.name()); 62 dtm.setJdbcPassword(jdbcPassword); 63 String dataSourceName = connectInfo.get(RolapConnectionProperties.DataSource.name()); 64 dtm.setDataSourceName(dataSourceName); 65 String catalog = connectInfo.get(RolapConnectionProperties.Catalog.name()); 66 String catalogExtension = catalog.replaceFirst(".*/", "").replaceFirst("\\.xml$", ".ext.xml"); 67 dtm.setCatalogExtension(catalogExtension); 68 return dtm; 69 } 70 71 75 public mondrian.olap.Connection getConnection() { 76 MondrianModel model = (MondrianModel) getModel(); 77 return model.getConnection(); 78 } 79 80 public boolean isExtendedContext() { 81 return extendedContext; 82 } 83 84 public void setExtendedContext(boolean extendedContext) { 85 this.extendedContext = extendedContext; 86 } 87 88 } 89 | Popular Tags |