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