KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > xmla > XMLA_Level


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.xmla;
14
15 import java.util.HashMap JavaDoc;
16 import java.util.List JavaDoc;
17 import java.util.Map JavaDoc;
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 /**
30  * Level Implementation for XMLA
31  */

32 public class XMLA_Level implements Level, MDXLevel, Exp {
33
34   private String JavaDoc dimUniqueName;
35   private String JavaDoc hierUniqueName;
36   private String JavaDoc name;
37   private String JavaDoc uniqueName;
38   private String JavaDoc 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 JavaDoc orderingProperty;
47   private int dbType;
48   private String JavaDoc nameSqlColumnName;
49   private String JavaDoc keySqlColumnName;
50   private String JavaDoc uniqueNameSqlColumnName;
51
52   private XMLA_Level childLevel = null;
53   private XMLA_Level parentLevel = null;
54
55   private Hierarchy hierarchy = null;
56
57   private List JavaDoc aMembers = null;
58   private XMLA_Model model;
59
60   private Map JavaDoc props = new HashMap JavaDoc(); // member properties , not SAP
61

62   /**
63    * c'tor
64    * @param model
65    */

66   public XMLA_Level(XMLA_Model model) {
67     this.model = model;
68   }
69
70   /**
71    *
72    * @param other
73    * @return boolean
74    */

75   public boolean isEqual(XMLA_Level other) {
76     return this.uniqueName.equals(other.getUniqueName());
77   }
78
79   public void setMembers(List JavaDoc mList) {
80     aMembers = mList;
81   }
82
83   /**
84    * @see com.tonbeller.jpivot.olap.model.Visitable#accept(Visitor)
85    */

86   public void accept(Visitor visitor) {
87     visitor.visitLevel(this);
88   }
89
90   public Object JavaDoc getRootDecoree() {
91     return this;
92   }
93
94   /**
95    * Returns the caption as Label
96    * @return String
97    */

98   public String JavaDoc getLabel() {
99     return caption;
100   }
101
102   /**
103    * Returns the caption.
104    * @return String
105    */

106   public String JavaDoc getCaption() {
107     return caption;
108   }
109
110   /**
111    * Returns the cardinality.
112    * @return int
113    */

114   public int getCardinality() {
115     return cardinality;
116   }
117
118   /**
119    * Returns the customRollupSettings.
120    * @return int
121    */

122   public int getCustomRollupSettings() {
123     return customRollupSettings;
124   }
125
126   /**
127    * Returns the dbType.
128    * @return int
129    */

130   public int getDbType() {
131     return dbType;
132   }
133
134   /**
135    * Returns the dimType.
136    * @return int
137    */

138   public int getDimType() {
139     return dimType;
140   }
141
142   /**
143    * Returns the dimUniqueName.
144    * @return String
145    */

146   public String JavaDoc getDimUniqueName() {
147     return dimUniqueName;
148   }
149
150   /**
151    * Returns the hier.
152    * @return Hierarchy
153    */

154   public Hierarchy getHierarchy() {
155     return hierarchy;
156   }
157
158   /**
159    * Returns the hierUniqueName.
160    * @return String
161    */

162   public String JavaDoc getHierUniqueName() {
163     return hierUniqueName;
164   }
165
166   /**
167    * Returns the isVisible.
168    * @return boolean
169    */

170   public boolean isVisible() {
171     return isVisible;
172   }
173
174   /**
175    * Returns the keySqlColumnName.
176    * @return String
177    */

178   public String JavaDoc getKeySqlColumnName() {
179     return keySqlColumnName;
180   }
181
182   /**
183    * Returns the name.
184    * @return String
185    */

186   public String JavaDoc getName() {
187     return name;
188   }
189
190   /**
191    * Returns the nameSqlColumnName.
192    * @return String
193    */

194   public String JavaDoc getNameSqlColumnName() {
195     return nameSqlColumnName;
196   }
197
198   /*
199    * return depth ( = 0 for root level)
200    * @see com.tonbeller.jpivot.olap.model.MDXLevel#getDepth()
201    */

202   public int getDepth() {
203     return number;
204   }
205
206   /**
207    * Returns the orderingProperty.
208    * @return String
209    */

210   public String JavaDoc getOrderingProperty() {
211     return orderingProperty;
212   }
213
214   /**
215    * Returns the type.
216    * @return int
217    */

218   public int getType() {
219     return type;
220   }
221
222   /**
223    * Returns the uniqueName.
224    * @return String
225    */

226   public String JavaDoc getUniqueName() {
227     return uniqueName;
228   }
229
230   /**
231    * Returns the uniqueNameSqlColumnName.
232    * @return String
233    */

234   public String JavaDoc getUniqueNameSqlColumnName() {
235     return uniqueNameSqlColumnName;
236   }
237
238   /**
239    * Returns the uniqueSettings.
240    * @return int
241    */

242   public int getUniqueSettings() {
243     return uniqueSettings;
244   }
245
246   /**
247    * Sets the caption.
248    * @param caption The caption to set
249    */

250   public void setCaption(String JavaDoc caption) {
251     this.caption = caption;
252   }
253
254   /**
255    * Sets the cardinality.
256    * @param cardinality The cardinality to set
257    */

258   public void setCardinality(int cardinality) {
259     this.cardinality = cardinality;
260   }
261
262   /**
263    * Sets the customRollupSettings.
264    * @param customRollupSettings The customRollupSettings to set
265    */

266   public void setCustomRollupSettings(int customRollupSettings) {
267     this.customRollupSettings = customRollupSettings;
268   }
269
270   /**
271    * Sets the dbType.
272    * @param dbType The dbType to set
273    */

274   public void setDbType(int dbType) {
275     this.dbType = dbType;
276   }
277
278   /**
279    * Sets the dimType.
280    * @param dimType The dimType to set
281    */

282   public void setDimType(int dimType) {
283     this.dimType = dimType;
284   }
285
286   /**
287    * Sets the dimUniqueName.
288    * @param dimUniqueName The dimUniqueName to set
289    */

290   public void setDimUniqueName(String JavaDoc dimUniqueName) {
291     this.dimUniqueName = dimUniqueName;
292   }
293
294   /**
295    * Sets the hier.
296    * @param hier The hier to set
297    */

298   public void setHierarchy(Hierarchy hier) {
299     this.hierarchy = hier;
300   }
301
302   /**
303    * Sets the hierUniqueName.
304    * @param hierUniqueName The hierUniqueName to set
305    */

306   public void setHierUniqueName(String JavaDoc hierUniqueName) {
307     this.hierUniqueName = hierUniqueName;
308   }
309
310   /**
311    * Sets the isVisible.
312    * @param isVisible The isVisible to set
313    */

314   public void setVisible(boolean isVisible) {
315     this.isVisible = isVisible;
316   }
317
318   /**
319    * Sets the keySqlColumnName.
320    * @param keySqlColumnName The keySqlColumnName to set
321    */

322   public void setKeySqlColumnName(String JavaDoc keySqlColumnName) {
323     this.keySqlColumnName = keySqlColumnName;
324   }
325
326   /**
327    * Sets the name.
328    * @param name The name to set
329    */

330   public void setName(String JavaDoc name) {
331     this.name = name;
332   }
333
334   /**
335    * Sets the nameSqlColumnName.
336    * @param nameSqlColumnName The nameSqlColumnName to set
337    */

338   public void setNameSqlColumnName(String JavaDoc nameSqlColumnName) {
339     this.nameSqlColumnName = nameSqlColumnName;
340   }
341
342   /**
343    * Sets the number.
344    * @param number The number to set
345    */

346   public void setNumber(int number) {
347     this.number = number;
348   }
349
350   /**
351    * Sets the orderingProperty.
352    * @param orderingProperty The orderingProperty to set
353    */

354   public void setOrderingProperty(String JavaDoc orderingProperty) {
355     this.orderingProperty = orderingProperty;
356   }
357
358   /**
359    * Sets the type.
360    * @param type The type to set
361    */

362   public void setType(int type) {
363     this.type = type;
364   }
365
366   /**
367    * Sets the uniqueName.
368    * @param uniqueName The uniqueName to set
369    */

370   public void setUniqueName(String JavaDoc uniqueName) {
371     this.uniqueName = uniqueName;
372   }
373
374   /**
375    * Sets the uniqueNameSqlColumnName.
376    * @param uniqueNameSqlColumnName The uniqueNameSqlColumnName to set
377    */

378   public void setUniqueNameSqlColumnName(String JavaDoc uniqueNameSqlColumnName) {
379     this.uniqueNameSqlColumnName = uniqueNameSqlColumnName;
380   }
381
382   /**
383    * Sets the uniqueSettings.
384    * @param uniqueSettings The uniqueSettings to set
385    */

386   public void setUniqueSettings(int uniqueSettings) {
387     this.uniqueSettings = uniqueSettings;
388   }
389
390   /**
391    * Returns the childLevel.
392    * @return XMLA_Level
393    */

394   public XMLA_Level getChildLevel() {
395     return childLevel;
396   }
397
398   /**
399    * Returns the parentLevel.
400    * @return XMLA_Level
401    */

402   public XMLA_Level getParentLevel() {
403     return parentLevel;
404   }
405
406   /**
407    * Sets the childLevel.
408    * @param childLevel The childLevel to set
409    */

410   public void setChildLevel(XMLA_Level childLevel) {
411     this.childLevel = childLevel;
412   }
413
414   /**
415    * Sets the parentLevel.
416    * @param parentLevel The parentLevel to set
417    */

418   public void setParentLevel(XMLA_Level parentLevel) {
419     this.parentLevel = parentLevel;
420   }
421
422   /**
423    * get the members of this level
424    */

425   public XMLA_Member[] getMembers() throws OlapException {
426     // potentially killer function
427
if (aMembers != null)
428       return (XMLA_Member[]) aMembers.toArray(new XMLA_Member[0]);
429     model.completeLevel(this); // get the level's members
430
return (XMLA_Member[]) aMembers.toArray(new XMLA_Member[0]);
431   }
432
433   /**
434    * @return the unique name
435    */

436   public String JavaDoc toMdx() {
437     return this.uniqueName;
438   }
439
440   /**
441    * @see com.tonbeller.jpivot.olap.query.MDXLevel#isAll()
442    * @return true if Hierarchy has "All" member and level is top level
443    */

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   /**
453    * @see com.tonbeller.jpivot.olap.query.MDXLevel#hasChildLevel()
454    */

455   public boolean hasChildLevel() {
456     return (this.getChildLevel() != null);
457   }
458
459   /**
460    * @see com.tonbeller.jpivot.olap.mdxparse.Exp#clone()
461    * probably not needed
462    */

463   public Object JavaDoc clone() {
464     String JavaDoc[] 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   /**
473    * @return
474    */

475   public Map JavaDoc getProps() {
476     return props;
477   }
478
479   /**
480    * add a property
481    */

482   public void addProp(XMLA_MemberProp prop) {
483     if (!props.containsKey(prop.getXmlTag())) {
484       props.put(prop.getXmlTag(), prop);
485     }
486   }
487
488   /**
489    * retrieve a property
490    */

491   public XMLA_MemberProp getProp(String JavaDoc xmlTag) {
492     return (XMLA_MemberProp) props.get(xmlTag);
493   }
494
495   /**
496     * @see com.tonbeller.jpivot.olap.mdxparse.Exp#accept
497     */

498   public void accept(ExpVisitor visitor) {
499     visitor.visitLevel(this);
500   }
501
502 } // End XMLA_Level
503
Popular Tags