KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.tonbeller.jpivot.core.ExtensionSupport;
16 import com.tonbeller.jpivot.olap.mdxparse.ParsedQuery;
17 import com.tonbeller.jpivot.olap.mdxparse.QueryAxis;
18 import com.tonbeller.jpivot.olap.navi.NonEmpty;
19
20 /**
21  * Non Empty extension
22  */

23 public class XMLA_NonEmpty extends ExtensionSupport implements NonEmpty {
24
25
26   /**
27    * Constructor sets ID
28    */

29   public XMLA_NonEmpty() {
30     super.setId(NonEmpty.ID);
31   }
32
33   /**
34    * @see com.tonbeller.jpivot.olap.navi.NonEmpty#isNonEmpty()
35    */

36   public boolean isNonEmpty() {
37
38     XMLA_Model m = (XMLA_Model) getModel();
39     XMLA_QueryAdapter adapter = (XMLA_QueryAdapter) m.getQueryAdapter();
40     ParsedQuery pQuery = adapter.getParsedQuery();
41
42     // loop over query axes
43
// say yes if all axes have the nonEmpty flag
44
// say no. if there is an axis w/o NON EMPTY
45

46     QueryAxis[] qAxes = pQuery.getAxes();
47     for (int i = 0; i < qAxes.length; i++) {
48       QueryAxis qAxis = qAxes[i];
49       if (!qAxis.isNonEmpty())
50         return false;
51     }
52     return true; // all axes NON EMPTY so far
53

54   }
55
56   /**
57    * @see com.tonbeller.jpivot.olap.navi.NonEmpty#setNonEmpty(boolean)
58    */

59   public void setNonEmpty(boolean nonEmpty) {
60
61     XMLA_Model m = (XMLA_Model) getModel();
62     XMLA_QueryAdapter adapter = (XMLA_QueryAdapter) m.getQueryAdapter();
63     ParsedQuery pQuery = adapter.getParsedQuery();
64
65     // loop over query axes
66
// set the nonEmpty flag, for all axes,
67

68     boolean bChange = false;
69     QueryAxis[] qAxes = pQuery.getAxes();
70     for (int i = 0; i < qAxes.length; i++) {
71       QueryAxis qAxis = qAxes[i];
72       if (qAxis.isNonEmpty() != nonEmpty) {
73         qAxis.setNonEmpty(nonEmpty);
74         bChange = true;
75       }
76     }
77
78     if (bChange)
79        m.fireModelChanged();
80
81   }
82
83  
84 } // End XMLA_NonEmpty
85
Popular Tags