1 13 package com.tonbeller.jpivot.xmla; 14 15 import java.util.ArrayList ; 16 17 import org.apache.log4j.Logger; 18 19 import com.tonbeller.jpivot.olap.mdxparse.CompoundId; 20 import com.tonbeller.jpivot.olap.mdxparse.Exp; 21 import com.tonbeller.jpivot.olap.mdxparse.ExpVisitor; 22 import com.tonbeller.jpivot.olap.model.Dimension; 23 import com.tonbeller.jpivot.olap.model.Hierarchy; 24 import com.tonbeller.jpivot.olap.model.Level; 25 import com.tonbeller.jpivot.olap.model.Member; 26 import com.tonbeller.jpivot.olap.model.OlapException; 27 import com.tonbeller.jpivot.olap.model.Visitor; 28 import com.tonbeller.jpivot.olap.query.MDXElement; 29 import com.tonbeller.jpivot.util.StringUtil; 30 31 34 public class XMLA_Hierarchy implements Hierarchy,Exp,MDXElement { 35 36 static Logger logger = Logger.getLogger(XMLA_Hierarchy.class); 37 38 private String dimUniqueName; 39 private String uniqueName; 40 private String caption; 41 private int dimType; 42 private int cardinality; 43 private String defaultMember; 44 private String allMember; 45 private XMLA_Model model; 46 47 public static final int STRUCTURE_FULLYBALANCED = 0; 50 public static final int STRUCTURE_RAGGEDBALANCED = 1; public static final int STRUCTURE_UNBALANCED = 2; private int structure = 0; 53 54 private boolean isVirtual; 55 private boolean isReadWrite; 56 private int dimUniqueSettings; 57 private boolean isDimVisible; 58 private int ordinal; 59 private boolean isDimShared; 60 61 private boolean isMembersGotten = false; 62 63 private Dimension dimension = null; 64 65 private ArrayList aLevels = new ArrayList (); 66 67 public XMLA_Hierarchy( XMLA_Model model) { 68 this.model = model; 69 } 70 71 75 public String getAllMemberName() { 76 return allMember; 77 } 78 79 83 public Member getAllMember() { 84 if (allMember == null) 85 return null; 86 Member mAll = model.lookupMemberByUName(allMember); 87 if (mAll != null) 88 return mAll; 89 try { 90 model.retrieveMember(allMember); 92 } catch (OlapException e) { 93 logger.error("could not retrieve member " + allMember, e); 95 } 96 return model.lookupMemberByUName(allMember); 97 } 98 99 103 public String getCaption() { 104 return caption; 105 } 106 107 111 public int getCardinality() { 112 return cardinality; 113 } 114 115 119 public String getDefaultMember() { 120 return defaultMember; 121 } 122 123 127 public int getDimType() { 128 return dimType; 129 } 130 131 135 public String getDimUniqueName() { 136 return dimUniqueName; 137 } 138 139 143 public int getDimUniqueSettings() { 144 return dimUniqueSettings; 145 } 146 147 151 public boolean isDimShared() { 152 return isDimShared; 153 } 154 155 159 public boolean isDimVisible() { 160 return isDimVisible; 161 } 162 163 167 public boolean isReadWrite() { 168 return isReadWrite; 169 } 170 171 175 public boolean isVirtual() { 176 return isVirtual; 177 } 178 179 183 public int getOrdinal() { 184 return ordinal; 185 } 186 187 191 public int getStructure() { 192 return structure; 193 } 194 195 199 public String getUniqueName() { 200 return uniqueName; 201 } 202 203 207 public void setAllMember(String allMember) { 208 this.allMember = allMember; 209 } 210 211 215 public void setCaption(String caption) { 216 this.caption = caption; 217 } 218 219 223 public void setCardinality(int cardinality) { 224 this.cardinality = cardinality; 225 } 226 227 231 public void setDefaultMember(String defaultMember) { 232 this.defaultMember = defaultMember; 233 } 234 235 239 public void setDimType(int dimType) { 240 this.dimType = dimType; 241 } 242 243 247 public void setDimUniqueName(String dimUniqueName) { 248 this.dimUniqueName = dimUniqueName; 249 } 250 251 255 public void setDimUniqueSettings(int dimUniqueSettings) { 256 this.dimUniqueSettings = dimUniqueSettings; 257 } 258 259 263 public void setDimShared(boolean isDimShared) { 264 this.isDimShared = isDimShared; 265 } 266 267 271 public void setDimVisible(boolean isDimVisible) { 272 this.isDimVisible = isDimVisible; 273 } 274 275 279 public void setReadWrite(boolean isReadWrite) { 280 this.isReadWrite = isReadWrite; 281 } 282 283 287 public void setVirtual(boolean isVirtual) { 288 this.isVirtual = isVirtual; 289 } 290 291 295 public void setOrdinal(int ordinal) { 296 this.ordinal = ordinal; 297 } 298 299 303 public void setStructure(int structure) { 304 this.structure = structure; 305 } 306 307 311 public void setUniqueName(String uniqueName) { 312 this.uniqueName = uniqueName; 313 } 314 315 318 public Dimension getDimension() { 319 return dimension; 320 } 321 322 325 public Level[] getLevels() { 326 return (Level[]) aLevels.toArray(new XMLA_Level[0]); 327 } 328 331 public String getLabel() { 332 return caption; 333 } 334 335 338 public void accept(Visitor visitor) { 339 visitor.visitHierarchy(this); 340 } 341 342 345 public Object getRootDecoree() { 346 return this; 347 } 348 349 353 public void setDimension(Dimension dimension) { 354 this.dimension = dimension; 355 } 356 357 361 public void addLevel(Level lev) { 362 aLevels.add(lev); 363 } 364 365 370 public boolean isEqual(XMLA_Hierarchy other) { 371 return (this.getUniqueName().equals(other.getUniqueName())); 372 } 373 374 378 protected boolean isMembersGotten() { 379 return isMembersGotten; 380 } 381 382 386 protected void setMembersGotten(boolean isMembersGotten) { 387 this.isMembersGotten = isMembersGotten; 388 } 389 390 393 public String toMdx() { 394 return this.uniqueName; 395 } 396 397 401 public Object clone() { 402 String [] nameParts = StringUtil.splitUniqueName(uniqueName); 403 CompoundId clone = new CompoundId(nameParts[0], false); 404 for (int i = 1; i < nameParts.length; i++) { 405 clone.append(nameParts[i], false); 406 } 407 return clone; 408 } 409 410 413 public void accept(ExpVisitor visitor) { 414 visitor.visitHierarchy(this); 415 } 416 public boolean hasAll() { 417 return allMember != null; 418 } 419 } | Popular Tags |