1 13 package com.tonbeller.jpivot.mondrian; 14 15 import javax.sql.DataSource ; 16 17 import mondrian.rolap.RolapMember; 18 19 import org.apache.log4j.Logger; 20 21 import com.tonbeller.jpivot.core.ExtensionSupport; 22 import com.tonbeller.jpivot.olap.model.Member; 23 import com.tonbeller.jpivot.olap.navi.ExpressionParser; 24 import com.tonbeller.jpivot.param.SqlAccess; 25 import com.tonbeller.wcf.param.SessionParam; 26 27 30 public class MondrianSqlAccess extends ExtensionSupport implements SqlAccess { 31 private static Logger logger = Logger.getLogger(MondrianSqlAccess.class); 32 33 public DataSource getDataSource() { 34 MondrianModel mm = (MondrianModel) getModel(); 35 return mm.getSqlDataSource(); 36 } 37 38 public SessionParam createParameter(Member member, String paramName) { 39 MondrianMember mm = (MondrianMember) member; 40 RolapMember rm = (RolapMember) mm.getMonMember(); 41 paramName = checkParamName(paramName, rm); 42 if (rm.getSqlKey() == null) 44 return null; 45 SessionParam p = new SessionParam(); 46 p.setSqlValue(rm.getSqlKey()); 47 p.setDisplayName(member.getLevel().getLabel()); 48 p.setDisplayValue(member.getLabel()); 49 50 ExpressionParser parser = (ExpressionParser) getModel().getExtension(ExpressionParser.ID); 51 if (parser != null) 52 p.setMdxValue(parser.unparse(member)); 53 54 p.setName(paramName); 55 return p; 56 } 57 58 private String checkParamName(String paramName, RolapMember rm) { 59 if (paramName != null) 60 return paramName; 61 return MondrianUtil.defaultParamName(rm); 62 } 63 64 public SessionParam createParameter(Member member, String paramName, String propertyName) { 65 MondrianMember mm = (MondrianMember) member; 66 RolapMember rm = (RolapMember) mm.getMonMember(); 67 paramName = checkParamName(paramName, rm); 68 Object propertyValue = rm.getPropertyValue(propertyName); 70 SessionParam p = new SessionParam(); 71 p.setSqlValue(propertyValue); 72 p.setDisplayName(member.getLevel().getLabel()); 73 p.setDisplayValue(member.getLabel()); 74 75 ExpressionParser parser = (ExpressionParser) getModel().getExtension(ExpressionParser.ID); 76 if (parser != null) 77 p.setMdxValue(parser.unparse(member)); 78 p.setName(paramName); 79 return p; 80 } 81 82 } | Popular Tags |