KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > mondrian > MondrianMemberProperties


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.mondrian;
14
15 import com.tonbeller.jpivot.core.ExtensionSupport;
16 import com.tonbeller.jpivot.olap.model.Level;
17 import com.tonbeller.jpivot.olap.model.Member;
18 import com.tonbeller.jpivot.olap.model.MemberPropertyMeta;
19 import com.tonbeller.jpivot.olap.navi.MemberProperties;
20
21 /**
22  * get member properties from Mondrian
23  */

24 public class MondrianMemberProperties extends ExtensionSupport implements MemberProperties {
25
26   public MondrianMemberProperties() {
27     super.setId(MemberProperties.ID);
28   }
29
30   /* get the property definitions for a certain level
31    * @see com.tonbeller.jpivot.olap.navi.MemberProperties#getMemberPropertyMetas(com.tonbeller.jpivot.olap.model.Level)
32    */

33   public MemberPropertyMeta[] getMemberPropertyMetas(Level level) {
34     mondrian.olap.Level monLevel = ((MondrianLevel) level).getMonLevel();
35     mondrian.olap.Property[] monProps = monLevel.getProperties();
36     if (monProps == null || monProps.length == 0)
37       return new MemberPropertyMeta[0];
38
39     String JavaDoc scope = getPropertyScope(monLevel);
40     MemberPropertyMeta[] props = new MemberPropertyMeta[monProps.length];
41     for (int i = 0; i < props.length; i++) {
42       String JavaDoc name = monProps[i].getName();
43       String JavaDoc label = monProps[i].getCaption();
44       if (label==null)
45           label=name;
46        props[i] = new MemberPropertyMeta(label, name, scope);
47     }
48     return props;
49   }
50
51   /**
52    * returns the unique name of the level (if levelScope) or hierarchy (if !levelScope)
53    * @param monLevel
54    * @return
55    */

56   private String JavaDoc getPropertyScope(mondrian.olap.Level monLevel) {
57     return monLevel.getHierarchy().getUniqueName();
58   }
59
60   /**
61    * @return false
62    */

63   public boolean isLevelScope() {
64     return false;
65   }
66
67   public String JavaDoc getPropertyScope(Member m) {
68     MondrianLevel level = (MondrianLevel) m.getLevel();
69     return getPropertyScope(level.getMonLevel());
70   }
71
72   /**
73    * sets the visible properties. Optimizing implementations of
74    * PropertyHolder may only return these properties.
75    * @see com.tonbeller.jpivot.olap.model.PropertyHolder
76    */

77   public void setVisibleProperties(MemberPropertyMeta[] props) {
78     // ignored
79
}
80
81 } // End MondrianMemberProperties
82
Popular Tags