1   /*
2    * PRELYTIS.
3    * Copyright 2007, PRELYTIS S.A., and individual contributors
4    * as indicated by the @author tags. See the copyright.txt file in the
5    * distribution for a full listing of individual contributors.
6    *
7    * This is free software; you can redistribute it and/or modify it
8    * under the terms of the GNU Lesser General Public License as
9    * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */
22  package org.jdbc4olap.xmla;
23  
24  import javax.xml.soap.SOAPElement;
25  import javax.xml.soap.SOAPException;
26  import javax.xml.soap.SOAPFactory;
27  
28  /**
29   * @author <a href="mailto:fsiberchicot@jdbc4olap.org">Florian SIBERCHICOT</a>
30   */
31  class XmlaRestrictions {
32  
33      private String providerType;
34      private String catalog;
35      private String cubeName;
36      private String dimensionUniqueName;
37      private String hierarchyUniqueName;
38      private String levelUniqueName;
39      private String memberUniqueName;
40      private String treeOp;
41  
42      XmlaRestrictions() {
43      }
44  
45      XmlaRestrictions(final String catalogName) {
46          this();
47          catalog = catalogName;
48      }
49  
50      String getCatalog() {
51          return catalog;
52      }
53  
54      void setCatalog(final String s) {
55          catalog = s;
56      }
57  
58      String getCubeName() {
59          return cubeName;
60      }
61  
62      void setCubeName(final String s) {
63          cubeName = s;
64      }
65  
66      String getDimensionUniqueName() {
67          return dimensionUniqueName;
68      }
69  
70      void setDimensionUniqueName(final String s) {
71          dimensionUniqueName = s;
72      }
73  
74      String getHierarchyUniqueName() {
75          return hierarchyUniqueName;
76      }
77  
78      void setHierarchyUniqueName(final String s) {
79          hierarchyUniqueName = s;
80      }
81  
82      void setLevelUniqueName(final String s) {
83          levelUniqueName = s;
84      }
85  
86      String getLevelUniqueName() {
87          return levelUniqueName;
88      }
89  
90      void setMemberUniqueName(final String s) {
91          memberUniqueName = s;
92      }
93  
94      String getMemberUniqueName() {
95          return memberUniqueName;
96      }
97  
98      void setTreeOp(final String s) {
99          treeOp = s;
100     }
101 
102     String getTreeOp() {
103         return treeOp;
104     }
105 
106 
107     SOAPElement getXMLA() throws SOAPException {
108         final SOAPFactory factory = XmlaConn.SOAP_FACTORY;
109         final SOAPElement restrictions = factory.createElement("Restrictions", "", "urn:schemas-microsoft-com:xml-analysis");
110         final SOAPElement restrictionList = restrictions.addChildElement(factory.createName("RestrictionList", "", "urn:schemas-microsoft-com:xml-analysis"));
111         if (catalog != null && !catalog.equals("")) {
112             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("CATALOG_NAME"));
113             soapProperty.addTextNode(catalog);
114         }
115         if (cubeName != null && !cubeName.equals("")) {
116             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("CUBE_NAME"));
117             soapProperty.addTextNode(cubeName);
118         }
119         if (dimensionUniqueName != null && !dimensionUniqueName.equals("")) {
120             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("DIMENSION_UNIQUE_NAME"));
121             soapProperty.addTextNode(dimensionUniqueName);
122         }
123         if (hierarchyUniqueName != null && !hierarchyUniqueName.equals("")) {
124             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("HIERARCHY_UNIQUE_NAME"));
125             soapProperty.addTextNode(hierarchyUniqueName);
126         }
127         if (levelUniqueName != null && !levelUniqueName.equals("")) {
128             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("LEVEL_UNIQUE_NAME"));
129             soapProperty.addTextNode(levelUniqueName);
130         }
131         if (memberUniqueName != null && !memberUniqueName.equals("")) {
132             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("MEMBER_UNIQUE_NAME"));
133             soapProperty.addTextNode(memberUniqueName);
134         }
135         if (treeOp != null && !treeOp.equals("")) {
136             final SOAPElement soapProperty = restrictionList.addChildElement(factory.createName("TREE_OP"));
137             soapProperty.addTextNode(treeOp);
138         }
139 
140         return restrictions;
141     }
142 
143     String getProviderType() {
144         return providerType;
145     }
146 
147     // @todo Actual value of parameter 'providerType' is always '"MDP"',
148     // Inline value '"MDP"' for parameter 'providerType'?
149     void setProviderType(final String providerType) {
150         this.providerType = providerType;
151     }
152 
153 }