1 13 package com.tonbeller.jpivot.xmla; 14 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import org.apache.log4j.Logger; 19 20 import com.tonbeller.jpivot.core.ExtensionSupport; 21 import com.tonbeller.jpivot.olap.model.Level; 22 import com.tonbeller.jpivot.olap.model.Member; 23 import com.tonbeller.jpivot.olap.model.MemberPropertyMeta; 24 import com.tonbeller.jpivot.olap.navi.MemberProperties; 25 26 29 public class XMLA_MemberProperties extends ExtensionSupport implements MemberProperties { 30 31 static Logger logger = Logger.getLogger(XMLA_MemberProperties.class); 32 33 private MemberPropertyMeta[] visibleProps; 34 35 public XMLA_MemberProperties() { 36 super.setId(MemberProperties.ID); 37 } 38 39 42 public MemberPropertyMeta[] getMemberPropertyMetas(Level level) { 43 XMLA_Level xlev = (XMLA_Level) level; 44 Map propMap; 45 XMLA_Model xmlaModel = (XMLA_Model) this.getModel(); 47 48 if (xmlaModel.isSAP() || xmlaModel.isMondrian()) { 49 propMap = ((XMLA_Dimension) xlev.getHierarchy().getDimension()).getProps(); 50 } else { 51 propMap = xlev.getProps(); 52 } 53 if (propMap.size() == 0) 54 return new MemberPropertyMeta[0]; 55 String scope = getPropertyScope(level); 56 MemberPropertyMeta[] props = new MemberPropertyMeta[propMap.size()]; 57 int i = 0; 58 for (Iterator iter = propMap.values().iterator(); iter.hasNext();) { 59 XMLA_MemberProp prop = (XMLA_MemberProp) iter.next(); 60 String name = prop.getName(); 61 62 String caption = prop.getCaption(); 63 64 if (xmlaModel.isSAP() || xmlaModel.isMondrian()) 65 props[i++] = new MemberPropertyMeta(caption + " / " + name, name, scope); 66 else 67 props[i++] = new MemberPropertyMeta(caption, name, scope); 68 } 69 70 return props; 71 } 72 73 77 public boolean isLevelScope() { 78 return false; 79 } 80 81 85 public String getPropertyScope(Member m) { 86 Level level = m.getLevel(); 87 return getPropertyScope(level); 88 } 89 90 95 private String getPropertyScope(Level level) { 96 return ((XMLA_Dimension) level.getHierarchy().getDimension()).getUniqueName(); 97 } 98 99 104 public void setVisibleProperties(MemberPropertyMeta[] props) { 105 this.visibleProps = props; 106 ((XMLA_Model) getModel()).fireModelChanged(); 107 } 108 109 114 public MemberPropertyMeta[] getVisibleProperties() { 115 return this.visibleProps; 116 } 117 118 } | Popular Tags |