001 /*
002 // $Id: //open/mondrian-release/3.0/src/main/mondrian/rolap/RolapCubeDimension.java#3 $
003 // This software is subject to the terms of the Common Public License
004 // Agreement, available at the following URL:
005 // http://www.opensource.org/licenses/cpl.html.
006 // Copyright (C) 2001-2002 Kana Software, Inc.
007 // Copyright (C) 2001-2007 Julian Hyde and others
008 // All Rights Reserved.
009 // You must accept the terms of that agreement to use this software.
010 //
011 // wgorman, 19 October 2007
012 */
013 package mondrian.rolap;
014
015 import mondrian.olap.Cube;
016 import mondrian.olap.DimensionType;
017 import mondrian.olap.HierarchyBase;
018 import mondrian.olap.MondrianDef;
019 import mondrian.olap.Schema;
020
021 /**
022 * RolapCubeDimension wraps a RolapDimension for a specific Cube.
023 *
024 * @author Will Gorman (wgorman@pentaho.org)
025 * @version $Id: //open/mondrian-release/3.0/src/main/mondrian/rolap/RolapCubeDimension.java#3 $
026 */
027 public class RolapCubeDimension extends RolapDimension {
028
029 RolapCube parent;
030
031 RolapDimension rolapDimension;
032 int cubeOrdinal;
033 MondrianDef.CubeDimension xmlDimension;
034
035 public RolapCubeDimension(RolapCube parent, RolapDimension rolapDim,
036 MondrianDef.CubeDimension cubeDim, String name, int cubeOrdinal) {
037 super(null, name, null);
038 this.xmlDimension = cubeDim;
039 this.rolapDimension = rolapDim;
040 this.cubeOrdinal = cubeOrdinal;
041 this.parent = parent;
042 this.caption = cubeDim.caption;
043
044 // create new hierarchies
045 hierarchies = new RolapCubeHierarchy[rolapDim.getHierarchies().length];
046
047 for (int i = 0; i < rolapDim.getHierarchies().length; i++) {
048 hierarchies[i] = new RolapCubeHierarchy(this, cubeDim,
049 (RolapHierarchy)rolapDim.getHierarchies()[i],
050 ((HierarchyBase)rolapDim.getHierarchies()[i]).getSubName());
051 }
052 }
053
054 public RolapCube getCube() {
055 return parent;
056 }
057
058 public Schema getSchema() {
059 return rolapDimension.getSchema();
060 }
061
062 // this method should eventually replace the call below
063 public int getOrdinal() {
064 return cubeOrdinal;
065 }
066
067 // note that the cube is not necessary here
068 public int getOrdinal(Cube cube) {
069 // this is temporary to validate that internals are consistant
070 assert(cube == parent);
071 return cubeOrdinal;
072 }
073
074 public boolean equals(Object o) {
075 if (this == o) {
076 return true;
077 }
078 if (!(o instanceof RolapCubeDimension)) {
079 return false;
080 }
081
082 RolapCubeDimension that = (RolapCubeDimension)o;
083 if (!parent.equals(that.parent)) {
084 return false;
085 }
086 return getUniqueName().equals(that.getUniqueName());
087 }
088
089 RolapCubeHierarchy newHierarchy(String subName, boolean hasAll) {
090 throw new UnsupportedOperationException();
091 }
092
093 public String getCaption() {
094 if (caption != null) {
095 return caption;
096 }
097 return rolapDimension.getCaption();
098 }
099
100 public void setCaption(String caption) {
101 if (true) {
102 throw new UnsupportedOperationException();
103 }
104 rolapDimension.setCaption(caption);
105 }
106
107 public DimensionType getDimensionType() {
108 return rolapDimension.getDimensionType();
109 }
110
111 }
112
113 // End RolapCubeDimension.java