1 13 14 package com.tonbeller.jpivot.xmla; 15 16 import java.util.ArrayList ; 17 import java.util.List ; 18 19 import org.apache.log4j.Logger; 20 21 import com.tonbeller.jpivot.core.ExtensionSupport; 22 import com.tonbeller.jpivot.olap.mdxparse.Exp; 23 import com.tonbeller.jpivot.olap.mdxparse.FunCall; 24 import com.tonbeller.jpivot.olap.model.Axis; 25 import com.tonbeller.jpivot.olap.model.Hierarchy; 26 import com.tonbeller.jpivot.olap.navi.PlaceHierarchiesOnAxes; 27 import com.tonbeller.jpivot.olap.query.Quax; 28 import com.tonbeller.jpivot.olap.query.QueryAdapter; 29 30 33 public class XMLA_PlaceHierarchies extends ExtensionSupport implements PlaceHierarchiesOnAxes { 34 35 private boolean expandAllMember = false; 36 ArrayList aMemberSet = null; 37 static Logger logger = Logger.getLogger(XMLA_PlaceHierarchies.class); 38 39 42 public XMLA_PlaceHierarchies() { 43 super.setId(PlaceHierarchiesOnAxes.ID); 44 } 45 46 49 public Object createMemberExpression(Hierarchy hier) { 50 QueryAdapter.QueryAdapterHolder model = (QueryAdapter.QueryAdapterHolder) getModel(); 53 XMLA_QueryAdapter adapter = (XMLA_QueryAdapter) model.getQueryAdapter(); 54 55 Quax quax = adapter.findQuax(hier.getDimension()); 57 if (quax == null) { 58 return XMLA_Util.topLevelMembers(hier, expandAllMember); } 61 62 int iDimension = quax.dimIdx(hier.getDimension()); 65 return quax.genExpForDim(iDimension); 66 } 67 68 71 public void setQueryAxis(Axis target, Object [] memberExpressions) { 72 73 XMLA_Model model = (XMLA_Model) getModel(); 74 XMLA_QueryAdapter adapter = (XMLA_QueryAdapter) model.getQueryAdapter(); 75 76 int iQuax = ((XMLA_Axis) target).getOrdinal(); 78 if (adapter.isSwapAxes()) 79 iQuax = (iQuax + 1) % 2; 80 Quax quax = adapter.getQuaxes()[iQuax]; 81 82 int nDimension = memberExpressions.length; 83 84 Object [] sets = new Object [nDimension]; 87 boolean changedMemberSet = false; 88 for (int i = 0; i < nDimension; i++) { 89 if (memberExpressions[i] instanceof List ) { 90 List memberList = (List ) memberExpressions[i]; 91 Exp[] members = (Exp[]) memberList.toArray(new Exp[0]); 92 if (members.length == 1) 93 sets[i] = members[0]; 94 else 95 sets[i] = new FunCall("{}", members, FunCall.TypeBraces); 96 changedMemberSet = true; 97 } else { 98 sets[i] = memberExpressions[i]; 100 } 101 } 102 103 quax.regeneratePosTree(sets, true); 105 106 if (logger.isInfoEnabled()) { 107 String changed = ""; 108 if (changedMemberSet) 109 changed = " changed by navi"; 110 logger.info("setQueryAxis axis=" + quax.getOrdinal() + " nDimension=" + nDimension + changed); 111 logger.info("Expression for Axis=" + quax.toString()); 112 } 113 114 quax.changed(this, changedMemberSet); 116 117 model.fireModelChanged(); 118 } 119 120 123 public void setExpandAllMember(boolean expandAllMember) { 124 this.expandAllMember = expandAllMember; 125 } 126 127 130 public boolean getExpandAllMember() { 131 return expandAllMember; 132 } 133 134 } | Popular Tags |