1 13 package com.tonbeller.jpivot.xmla; 14 15 import java.util.HashMap ; 16 import java.util.List ; 17 import java.util.Map ; 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.Hierarchy; 23 import com.tonbeller.jpivot.olap.model.Level; 24 import com.tonbeller.jpivot.olap.model.OlapException; 25 import com.tonbeller.jpivot.olap.model.Visitor; 26 import com.tonbeller.jpivot.olap.query.MDXLevel; 27 import com.tonbeller.jpivot.util.StringUtil; 28 29 32 public class XMLA_Level implements Level, MDXLevel, Exp { 33 34 private String dimUniqueName; 35 private String hierUniqueName; 36 private String name; 37 private String uniqueName; 38 private String caption; 39 private int number; 40 private int dimType; 41 private int cardinality; 42 private int type; 43 private int customRollupSettings; 44 private int uniqueSettings; 45 private boolean isVisible; 46 private String orderingProperty; 47 private int dbType; 48 private String nameSqlColumnName; 49 private String keySqlColumnName; 50 private String uniqueNameSqlColumnName; 51 52 private XMLA_Level childLevel = null; 53 private XMLA_Level parentLevel = null; 54 55 private Hierarchy hierarchy = null; 56 57 private List aMembers = null; 58 private XMLA_Model model; 59 60 private Map props = new HashMap (); 62 66 public XMLA_Level(XMLA_Model model) { 67 this.model = model; 68 } 69 70 75 public boolean isEqual(XMLA_Level other) { 76 return this.uniqueName.equals(other.getUniqueName()); 77 } 78 79 public void setMembers(List mList) { 80 aMembers = mList; 81 } 82 83 86 public void accept(Visitor visitor) { 87 visitor.visitLevel(this); 88 } 89 90 public Object getRootDecoree() { 91 return this; 92 } 93 94 98 public String getLabel() { 99 return caption; 100 } 101 102 106 public String getCaption() { 107 return caption; 108 } 109 110 114 public int getCardinality() { 115 return cardinality; 116 } 117 118 122 public int getCustomRollupSettings() { 123 return customRollupSettings; 124 } 125 126 130 public int getDbType() { 131 return dbType; 132 } 133 134 138 public int getDimType() { 139 return dimType; 140 } 141 142 146 public String getDimUniqueName() { 147 return dimUniqueName; 148 } 149 150 154 public Hierarchy getHierarchy() { 155 return hierarchy; 156 } 157 158 162 public String getHierUniqueName() { 163 return hierUniqueName; 164 } 165 166 170 public boolean isVisible() { 171 return isVisible; 172 } 173 174 178 public String getKeySqlColumnName() { 179 return keySqlColumnName; 180 } 181 182 186 public String getName() { 187 return name; 188 } 189 190 194 public String getNameSqlColumnName() { 195 return nameSqlColumnName; 196 } 197 198 202 public int getDepth() { 203 return number; 204 } 205 206 210 public String getOrderingProperty() { 211 return orderingProperty; 212 } 213 214 218 public int getType() { 219 return type; 220 } 221 222 226 public String getUniqueName() { 227 return uniqueName; 228 } 229 230 234 public String getUniqueNameSqlColumnName() { 235 return uniqueNameSqlColumnName; 236 } 237 238 242 public int getUniqueSettings() { 243 return uniqueSettings; 244 } 245 246 250 public void setCaption(String caption) { 251 this.caption = caption; 252 } 253 254 258 public void setCardinality(int cardinality) { 259 this.cardinality = cardinality; 260 } 261 262 266 public void setCustomRollupSettings(int customRollupSettings) { 267 this.customRollupSettings = customRollupSettings; 268 } 269 270 274 public void setDbType(int dbType) { 275 this.dbType = dbType; 276 } 277 278 282 public void setDimType(int dimType) { 283 this.dimType = dimType; 284 } 285 286 290 public void setDimUniqueName(String dimUniqueName) { 291 this.dimUniqueName = dimUniqueName; 292 } 293 294 298 public void setHierarchy(Hierarchy hier) { 299 this.hierarchy = hier; 300 } 301 302 306 public void setHierUniqueName(String hierUniqueName) { 307 this.hierUniqueName = hierUniqueName; 308 } 309 310 314 public void setVisible(boolean isVisible) { 315 this.isVisible = isVisible; 316 } 317 318 322 public void setKeySqlColumnName(String keySqlColumnName) { 323 this.keySqlColumnName = keySqlColumnName; 324 } 325 326 330 public void setName(String name) { 331 this.name = name; 332 } 333 334 338 public void setNameSqlColumnName(String nameSqlColumnName) { 339 this.nameSqlColumnName = nameSqlColumnName; 340 } 341 342 346 public void setNumber(int number) { 347 this.number = number; 348 } 349 350 354 public void setOrderingProperty(String orderingProperty) { 355 this.orderingProperty = orderingProperty; 356 } 357 358 362 public void setType(int type) { 363 this.type = type; 364 } 365 366 370 public void setUniqueName(String uniqueName) { 371 this.uniqueName = uniqueName; 372 } 373 374 378 public void setUniqueNameSqlColumnName(String uniqueNameSqlColumnName) { 379 this.uniqueNameSqlColumnName = uniqueNameSqlColumnName; 380 } 381 382 386 public void setUniqueSettings(int uniqueSettings) { 387 this.uniqueSettings = uniqueSettings; 388 } 389 390 394 public XMLA_Level getChildLevel() { 395 return childLevel; 396 } 397 398 402 public XMLA_Level getParentLevel() { 403 return parentLevel; 404 } 405 406 410 public void setChildLevel(XMLA_Level childLevel) { 411 this.childLevel = childLevel; 412 } 413 414 418 public void setParentLevel(XMLA_Level parentLevel) { 419 this.parentLevel = parentLevel; 420 } 421 422 425 public XMLA_Member[] getMembers() throws OlapException { 426 if (aMembers != null) 428 return (XMLA_Member[]) aMembers.toArray(new XMLA_Member[0]); 429 model.completeLevel(this); return (XMLA_Member[]) aMembers.toArray(new XMLA_Member[0]); 431 } 432 433 436 public String toMdx() { 437 return this.uniqueName; 438 } 439 440 444 public boolean isAll() { 445 if (this.getParentLevel() != null) 446 return false; 447 if (((XMLA_Hierarchy) this.getHierarchy()).getAllMember() != null) 448 return true; 449 return false; 450 } 451 452 455 public boolean hasChildLevel() { 456 return (this.getChildLevel() != null); 457 } 458 459 463 public Object clone() { 464 String [] nameParts = StringUtil.splitUniqueName(uniqueName); 465 CompoundId clone = new CompoundId(nameParts[0], false); 466 for (int i = 1; i < nameParts.length; i++) { 467 clone.append(nameParts[i], false); 468 } 469 return clone; 470 } 471 472 475 public Map getProps() { 476 return props; 477 } 478 479 482 public void addProp(XMLA_MemberProp prop) { 483 if (!props.containsKey(prop.getXmlTag())) { 484 props.put(prop.getXmlTag(), prop); 485 } 486 } 487 488 491 public XMLA_MemberProp getProp(String xmlTag) { 492 return (XMLA_MemberProp) props.get(xmlTag); 493 } 494 495 498 public void accept(ExpVisitor visitor) { 499 visitor.visitLevel(this); 500 } 501 502 } | Popular Tags |