1 13 package com.tonbeller.jpivot.olap.query; 14 15 import com.tonbeller.jpivot.core.ExtensionSupport; 16 import com.tonbeller.jpivot.olap.model.Member; 17 import com.tonbeller.jpivot.olap.model.Position; 18 import com.tonbeller.jpivot.olap.navi.DrillExpandPosition; 19 20 23 public class DrillExpandPositionExt extends ExtensionSupport implements DrillExpandPosition { 24 25 28 public DrillExpandPositionExt() { 29 super.setId(DrillExpandPosition.ID); 30 } 31 32 38 public boolean canExpand(Position position, Member member) { 39 QueryAdapter.QueryAdapterHolder model = (QueryAdapter.QueryAdapterHolder) getModel(); 40 Member[] pathMembers = memberPath(position, member); 41 return model.getQueryAdapter().canExpand(pathMembers); 42 } 43 44 49 public boolean canCollapse(Position position, Member member) { 50 QueryAdapter.QueryAdapterHolder model = (QueryAdapter.QueryAdapterHolder) getModel(); 51 Member[] pathMembers = memberPath(position, member); 52 return model.getQueryAdapter().canCollapse(pathMembers); 53 54 } 55 56 61 public void expand(Position position, Member member) { 62 63 QueryAdapter.QueryAdapterHolder model = (QueryAdapter.QueryAdapterHolder) getModel(); 64 Member[] pathMembers = memberPath(position, member); 65 model.getQueryAdapter().expand(pathMembers); 66 } 67 68 73 public void collapse(Position position, Member member) { 74 QueryAdapter.QueryAdapterHolder model = (QueryAdapter.QueryAdapterHolder) getModel(); 75 Member[] pathMembers = memberPath(position, member); 76 model.getQueryAdapter().collapse(pathMembers); 77 } 78 79 85 private Member[] memberPath(Position position, Member member) { 86 Member[] posMembers = position.getMembers(); 87 int pathlen = 0; 88 for (int i = 0; i < posMembers.length; i++) { 89 if (posMembers[i].equals(member)) { 90 pathlen = i + 1; 91 break; 92 } 93 } 94 if (pathlen == 0) 95 return null; Member[] pathMembers = new Member[pathlen]; 97 for (int i = 0; i < pathlen; i++) { 98 pathMembers[i] = posMembers[i]; 99 } 100 return pathMembers; 101 } 102 103 } | Popular Tags |