001/*
002// Licensed to Julian Hyde under one or more contributor license
003// agreements. See the NOTICE file distributed with this work for
004// additional information regarding copyright ownership.
005//
006// Julian Hyde licenses this file to you under the Apache License,
007// Version 2.0 (the "License"); you may not use this file except in
008// compliance with the License. You may obtain a copy of the License at:
009//
010// http://www.apache.org/licenses/LICENSE-2.0
011//
012// Unless required by applicable law or agreed to in writing, software
013// distributed under the License is distributed on an "AS IS" BASIS,
014// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015// See the License for the specific language governing permissions and
016// limitations under the License.
017*/
018package org.olap4j.metadata;
019
020import org.olap4j.OlapException;
021
022/**
023 * An organized hierarchy of categories, known as levels, that describes data
024 * in a cube.
025 *
026 * <p>A Dimension typically describes a similar set of members upon which the
027 * user wants to base an analysis.
028 *
029 * <p>A Dimension must have at least one Hierarchy, and may have more than one,
030 * but most have exactly one Hierarchy.</p>
031 *
032 * @author jhyde
033 * @since Aug 22, 2006
034 */
035public interface Dimension extends MetadataElement {
036
037    /**
038     * Returns the hierarchies in this Dimension.
039     *
040     * <p>Many dimensions have only one Hierarchy, whose name is the same as the
041     * Dimension.
042     *
043     * <p>The caller should assume that the list is immutable;
044     * if the caller modifies the list, behavior is undefined.</p>
045     *
046     * @see org.olap4j.OlapDatabaseMetaData#getHierarchies
047     *
048     * @return hierarchies in this dimension
049     */
050    NamedList<Hierarchy> getHierarchies();
051
052    /**
053     * Returns the type of this Dimension.
054     *
055     * @return dimension type
056     *
057     * @throws OlapException if database error occurs
058     */
059    Dimension.Type getDimensionType() throws OlapException;
060
061    /**
062     * Returns the default <code>Hierarchy</code> of this Dimension.
063     *
064     * @return default hierarchy
065     */
066    Hierarchy getDefaultHierarchy();
067
068    /**
069     * Enumeration of the types of a <code>Dimension</code>.
070     *
071     * <p>Some of the values are as specified by XMLA.
072     * For example, XMLA specifies MD_DIMTYPE_PRODUCTS with ordinal 8,
073     * which corresponds to the value {@link #PRODUCTS},
074     * whose {@link #xmlaOrdinal} is 8.
075     *
076     * @see Level.Type
077     * @see Member.Type
078     * @see Dimension#getDimensionType
079     */
080    public enum Type implements XmlaConstant {
081        /**
082         * Indicates that the dimension is not related to time.
083         *
084         * <p>Corresponds to the XMLA constant
085         * <code>MD_DIMTYPE_UNKNOWN(0)</code>.</p>
086         */
087        UNKNOWN(0),
088
089        /**
090         * Indicates that a dimension is a time dimension.
091         *
092         * <p>Corresponds to the XMLA constant
093         * <code>MD_DIMTYPE_TIME(1)</code>.</p>
094         */
095        TIME(1),
096
097        /**
098         * Indicates that a dimension is the Measures dimension.
099         *
100         * <p>Corresponds to the XMLA constant
101         * <code>MD_DIMTYPE_MEASURE(2)</code>.</p>
102         */
103        MEASURE(2),
104
105        /** Corresponds to the XMLA constant
106         * <code>MD_DIMTYPE_OTHER(3)</code>. */
107        OTHER(3),
108
109        /** Corresponds to the XMLA constant
110         * <code>MD_DIMTYPE_QUANTITATIVE(5)</code>. */
111        QUANTITATIVE(5),
112
113        /** Corresponds to the XMLA constant
114         * <code>MD_DIMTYPE_ACCOUNTS(6)</code>. */
115        ACCOUNTS(6),
116
117        /** Corresponds to the XMLA constant
118         * <code>MD_DIMTYPE_CUSTOMERS(7)</code>. */
119        CUSTOMERS(7),
120
121        /** Corresponds to the XMLA constant
122         * <code>MD_DIMTYPE_PRODUCTS(8)</code>. */
123        PRODUCTS(8),
124
125        /** Corresponds to the XMLA constant
126         * <code>MD_DIMTYPE_SCENARIO(9)</code>. */
127        SCENARIO(9),
128
129        /** Corresponds to the XMLA constant
130         * <code>MD_DIMTYPE_UTILIY(10)</code> (sic). */
131        UTILITY(10) {
132            public String xmlaName() {
133                // The XMLA constant is apparently mis-spelled.
134                // Who are we to question?
135                return "MD_DIMTYPE_UTILIY";
136            }
137        },
138
139        /** Corresponds to the XMLA constant
140         * <code>MD_DIMTYPE_CURRENCY(11)</code>. */
141        CURRENCY(11),
142
143        /** Corresponds to the XMLA constant
144         * <code>MD_DIMTYPE_RATES(12)</code>. */
145        RATES(12),
146
147        /** Corresponds to the XMLA constant
148         * <code>MD_DIMTYPE_CHANNEL(13)</code>. */
149        CHANNEL(13),
150
151        /** Corresponds to the XMLA constant
152         * <code>MD_DIMTYPE_PROMOTION(14)</code>. */
153        PROMOTION(14),
154
155        /** Corresponds to the XMLA constant
156         * <code>MD_DIMTYPE_ORGANIZATION(15)</code>. */
157        ORGANIZATION(15),
158
159        /** Corresponds to the XMLA constant
160         * <code>MD_DIMTYPE_BILL_OF_MATERIALS(16)</code>. */
161        BILL_OF_MATERIALS(16),
162
163        /** Corresponds to the XMLA constant
164         * <code>MD_DIMTYPE_GEOGRAPHY(17)</code>. */
165        GEOGRAPHY(17);
166
167        private final int xmlaOrdinal;
168
169        private static final Dictionary<Type> DICTIONARY =
170            DictionaryImpl.forClass(Type.class);
171
172        /**
173         * Per {@link org.olap4j.metadata.XmlaConstant}, returns a dictionary
174         * of all values of this enumeration.
175         *
176         * @return Dictionary of all values
177         */
178        public static Dictionary<Type> getDictionary() {
179            return DICTIONARY;
180        }
181
182        /**
183         * Creates a Dimension Type.
184         *
185         * @param xmlaOrdinal Ordinal code as specified by XMLA
186         */
187        private Type(int xmlaOrdinal) {
188            this.xmlaOrdinal = xmlaOrdinal;
189        }
190
191        public String xmlaName() {
192            return "MD_DIMTYPE_" + name();
193        }
194
195        public String getDescription() {
196            return "";
197        }
198
199        public int xmlaOrdinal() {
200            return xmlaOrdinal;
201        }
202    }
203}
204
205// End Dimension.java