1 13 14 package com.tonbeller.jpivot.mondrian; 15 16 import mondrian.olap.Exp; 17 import mondrian.olap.Syntax; 18 import mondrian.mdx.UnresolvedFunCall; 19 import mondrian.mdx.MemberExpr; 20 21 import org.apache.log4j.Logger; 22 23 import com.tonbeller.jpivot.olap.model.Member; 24 import com.tonbeller.jpivot.olap.model.OlapException; 25 import com.tonbeller.jpivot.util.TreeNode; 26 27 31 32 public class MondrianOldStuff { 33 34 static Logger logger = Logger.getLogger(MondrianModel.class); 35 36 41 static void handleQubonMode( 42 MondrianQuax quax, 43 MondrianQuaxBean quaxBean, 44 MondrianModel model) { 45 46 MondrianMemberSetBean[] msbs = quaxBean.getMemberSets(); 47 48 TreeNode rootNode = new TreeNode(null); 50 TreeNode currentNode = rootNode; 51 for (int j = 0; j < msbs.length; j++) { 52 int msbType = msbs[j].getType(); 53 TreeNode node = null; 54 switch (msbType) { 55 case 0 : String [] memberList = msbs[j].getMemberList(); 57 MemberExpr[] monMembers = new MemberExpr[memberList.length]; 58 for (int k = 0; k < monMembers.length; k++) { 59 MondrianMember m = (MondrianMember) model.lookupMemberByUName(memberList[k]); 60 if (m == null) { 61 logger.error( 62 "old Memento Object is invalid, Axis " 63 + quax.getOrdinal() 64 + " #Member could not be found " 65 + memberList[k]); 66 return; 67 } 68 monMembers[k] = new MemberExpr(m.getMonMember()); 69 } 70 UnresolvedFunCall fSet = new UnresolvedFunCall("{}", Syntax.Braces, monMembers); 71 node = new TreeNode(fSet); 72 currentNode.addChildNode(node); 73 break; 74 case 1 : memberList = msbs[j].getMemberList(); 76 77 MondrianMember m = (MondrianMember) model.lookupMemberByUName(memberList[0]); 78 if (m == null) { 79 logger.error( 80 "old Memento Object is invalid, Axis " 81 + quax.getOrdinal() 82 + " #Member could not be found " 83 + memberList[0]); 84 return; 85 } 86 final mondrian.olap.Member monMember = m.getMonMember(); 87 88 UnresolvedFunCall fChildren = new UnresolvedFunCall("Children", Syntax.Property, new Exp[] { new MemberExpr(monMember) }); 89 node = new TreeNode(fChildren); 90 currentNode.addChildNode(node); 91 break; 92 default : 93 logger.error( 94 "old Memento Object is invalid, Axis " 95 + quax.getOrdinal() 96 + " unexpected member set type " 97 + msbType); 98 return; 99 } 100 101 currentNode = node; 102 } 104 quax.setPosTreeRoot(rootNode, true); 105 } 106 107 112 static void handleDrillExMode( 113 MondrianQuax quax, 114 MondrianQuaxBean quaxBean, 115 MondrianModel model) { 116 117 try { 118 model.getResult(); 120 } catch (OlapException e) { 121 logger.error("old Memento Object , Axis " + quax.getOrdinal() + " Exception getResult"); 122 e.printStackTrace(); 123 return; 124 } 125 MondrianDrillExBean[] drillExes = quaxBean.getDrillExes(); 126 for (int j = 0; j < drillExes.length; j++) { 127 String [] pathMembers = drillExes[j].getPathMembers(); 128 129 Member[] members = new Member[pathMembers.length]; 130 for (int k = 0; k < members.length; k++) { 131 Member m = model.lookupMemberByUName(pathMembers[k]); 132 if (m == null) { 133 logger.error( 134 "old Memento Object is invalid, Axis " 135 + quax.getOrdinal() 136 + " drillex Member could not be found " 137 + pathMembers[k]); 138 return; 139 } 140 members[k] = m; 141 142 } 144 if (quax.canExpand(members)) 145 quax.expand(members); 146 147 } } 149 150 } | Popular Tags |