KickJava   Java API By Example, From Geeks To Geeks.

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


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
14 package com.tonbeller.jpivot.xmla;
15
16 import java.util.Collections JavaDoc;
17 import java.util.List JavaDoc;
18
19 import com.tonbeller.jpivot.olap.model.Hierarchy;
20 import com.tonbeller.jpivot.olap.navi.PlaceMembersOnAxes;
21 import com.tonbeller.jpivot.olap.query.Quax;
22
23 /**
24  *
25  * @author hh
26  */

27 public class XMLA_PlaceMembers extends XMLA_PlaceHierarchies implements PlaceMembersOnAxes {
28
29   /**
30    * Constructor for MondrianPlaceMembers.
31    */

32   public XMLA_PlaceMembers() {
33     setId(PlaceMembersOnAxes.ID);
34   }
35
36   /**
37    * return List of members, trivial for XMLA
38    * @see com.tonbeller.jpivot.olap.navi.PlaceMembersOnAxes#createMemberExpression(List)
39    */

40   public Object JavaDoc createMemberExpression(List JavaDoc members) {
41     return members;
42   }
43
44   /**
45    * find all members of an hierarchy
46    * @see com.tonbeller.jpivot.olap.navi.PlaceMembersOnAxes#findVisibleMembers(Hierarchy)
47    */

48   public List JavaDoc findVisibleMembers(Hierarchy hier) {
49
50     XMLA_Model model = (XMLA_Model) getModel();
51     XMLA_QueryAdapter adapter = (XMLA_QueryAdapter) model.getQueryAdapter();
52
53     // find the Quax for this hier
54
Quax quax = adapter.findQuax(hier.getDimension());
55
56     if (quax == null)
57       return Collections.EMPTY_LIST; // should not occur
58

59     int iDim = quax.dimIdx(hier.getDimension());
60
61     // use query axis
62
// problem: if NON EMPTY is on, then a member, which is excluded by Non Empty
63
// will be visible, although not occuring in the result. OK?
64
List JavaDoc memberList = XMLA_Util.collectMembers(quax.getPosTreeRoot(), iDim);
65
66     // use result
67
// problem: if NON EMPTY is on then a member, which is excluded by Non Empty
68
// will not be visible.
69
// It would be possible to add it (again) to the axis, which must be avoided
70
/*
71     Result res = null;
72     memberList = new ArrayList();
73     try {
74       res = model.getResult();
75     } catch (OlapException e) {
76       e.printStackTrace();
77       logger.error("findVisibleMembers: unexpected failure of getResult");
78       return Collections.EMPTY_LIST;
79     }
80     
81     // locate the appropriate result axis
82     int iAx = quax.getOrdinal();
83     if (adapter.isSwapAxes())
84       iAx = (iAx + 1) % 2;
85     Axis axis = res.getAxes()[iAx];
86     List positions = axis.getPositions();
87     for (Iterator iter = positions.iterator(); iter.hasNext();) {
88       Position pos = (Position)iter.next();
89       Member[] members = pos.getMembers();
90       MondrianMember mem = (MondrianMember)members[iDim];
91       if (mem != null && !memberList.contains(mem))
92         memberList.add(mem);
93     }
94     */

95     return memberList;
96   }
97
98 } // End XMLA_PlaceMembers
99
Popular Tags