KickJava   Java API By Example, From Geeks To Geeks.

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


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.navi.SwapAxes;
17
18 /**
19  * @author hh
20  *
21  * Implementation of the Swap Axes Extension for Mondrian Data Source.
22  */

23 public class MondrianSwapAxes extends ExtensionSupport implements SwapAxes {
24
25   /**
26    * Constructor sets ID
27    */

28   public MondrianSwapAxes() {
29     super.setId(SwapAxes.ID);
30   }
31
32   /**
33    * @see com.tonbeller.jpivot.olap.navi.SwapAxes#canSwapAxes()
34    * @return true, if the Mondrian Query exists and has two axes
35    */

36   public boolean canSwapAxes() {
37     MondrianModel model = (MondrianModel) getModel();
38     mondrian.olap.Query monQuery = ((MondrianQueryAdapter)model.getQueryAdapter()).getMonQuery();
39     if ( monQuery != null )
40       return ( monQuery.getAxes().length == 2 );
41     else
42       return false;
43   }
44
45
46   public void setSwapAxes(boolean swap) {
47     MondrianModel model = (MondrianModel) getModel();
48     ((MondrianQueryAdapter)model.getQueryAdapter()).setSwapAxes(swap);
49   }
50
51   public boolean isSwapAxes() {
52     MondrianModel model = (MondrianModel) getModel();
53     return ((MondrianQueryAdapter)model.getQueryAdapter()).isSwapAxes();
54   }
55
56 }
57
Popular Tags