KickJava   Java API By Example, From Geeks To Geeks.

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


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.Iterator JavaDoc;
16 import java.util.Map JavaDoc;
17
18 import org.apache.log4j.Logger;
19
20 import com.tonbeller.jpivot.core.ExtensionSupport;
21 import com.tonbeller.jpivot.olap.model.Level;
22 import com.tonbeller.jpivot.olap.model.Member;
23 import com.tonbeller.jpivot.olap.model.MemberPropertyMeta;
24 import com.tonbeller.jpivot.olap.navi.MemberProperties;
25
26 /**
27  * retrieve member properties
28  */

29 public class XMLA_MemberProperties extends ExtensionSupport implements MemberProperties {
30
31   static Logger logger = Logger.getLogger(XMLA_MemberProperties.class);
32
33   private MemberPropertyMeta[] visibleProps;
34
35   public XMLA_MemberProperties() {
36     super.setId(MemberProperties.ID);
37   }
38
39   /* get the property definitions for a certain level
40    * @see com.tonbeller.jpivot.olap.navi.MemberProperties#getMemberPropertyMetas
41    */

42   public MemberPropertyMeta[] getMemberPropertyMetas(Level level) {
43     XMLA_Level xlev = (XMLA_Level) level;
44     Map JavaDoc propMap;
45     // for SAP the properties are stored with the dimension
46
XMLA_Model xmlaModel = (XMLA_Model) this.getModel();
47     
48     if (xmlaModel.isSAP() || xmlaModel.isMondrian()) {
49       propMap = ((XMLA_Dimension) xlev.getHierarchy().getDimension()).getProps();
50     } else {
51       propMap = xlev.getProps();
52     }
53     if (propMap.size() == 0)
54       return new MemberPropertyMeta[0];
55     String JavaDoc scope = getPropertyScope(level);
56     MemberPropertyMeta[] props = new MemberPropertyMeta[propMap.size()];
57     int i = 0;
58     for (Iterator JavaDoc iter = propMap.values().iterator(); iter.hasNext();) {
59       XMLA_MemberProp prop = (XMLA_MemberProp) iter.next();
60       String JavaDoc name = prop.getName();
61
62       String JavaDoc caption = prop.getCaption();
63       
64       if (xmlaModel.isSAP() || xmlaModel.isMondrian())
65         props[i++] = new MemberPropertyMeta(caption + " / " + name, name, scope);
66       else
67         props[i++] = new MemberPropertyMeta(caption, name, scope);
68     }
69
70     return props;
71   }
72
73   /**
74    * @return true if level scope
75    * @see com.tonbeller.jpivot.olap.navi.MemberProperties#isLevelScope()
76    */

77   public boolean isLevelScope() {
78     return false;
79   }
80
81   /**
82    * @return property scope for member
83    * @see com.tonbeller.jpivot.olap.navi.MemberProperties#getPropertyScope
84    */

85   public String JavaDoc getPropertyScope(Member m) {
86     Level level = m.getLevel();
87     return getPropertyScope(level);
88   }
89
90   /**
91    * returns the unique name of hierarchy
92    * @param level
93    * @return unique name of hierarchy
94    */

95   private String JavaDoc getPropertyScope(Level level) {
96     return ((XMLA_Dimension) level.getHierarchy().getDimension()).getUniqueName();
97   }
98
99   /**
100    * sets the visible properties. Optimizing implementations of
101    * PropertyHolder may only return these properties.
102    * @see com.tonbeller.jpivot.olap.model.PropertyHolder
103    */

104   public void setVisibleProperties(MemberPropertyMeta[] props) {
105     this.visibleProps = props;
106     ((XMLA_Model) getModel()).fireModelChanged();
107   }
108
109   /**
110     * sets the visible properties. Optimizing implementations of
111     * PropertyHolder may only return these properties.
112     * @see com.tonbeller.jpivot.olap.model.PropertyHolder
113     */

114   public MemberPropertyMeta[] getVisibleProperties() {
115     return this.visibleProps;
116   }
117
118 } // XMLA_MemberProperties
119
Popular Tags