1 13 14 package mondrian.olap; 15 16 import mondrian.resource.MondrianResource; 17 18 25 public abstract class CubeBase extends OlapElementBase implements Cube { 26 27 32 public static final int CATALOG_NAME = 0; 33 public static final int SCHEMA_NAME = 1; 34 public static final int CUBE_NAME = 2; 35 public static final int DIMENSION_UNIQUE_NAME = 3; 36 public static final int HIERARCHY_UNIQUE_NAME = 4; 37 public static final int LEVEL_UNIQUE_NAME = 5; 38 public static final int LEVEL_NUMBER = 6; 39 public static final int MEMBER_NAME = 7; 40 public static final int MEMBER_UNIQUE_NAME = 8; 41 public static final int MEMBER_CAPTION = 9; 42 public static final int MEMBER_TYPE = 10; 43 public static final int Tree_Operator = 11; 44 public static final int maxNofConstraintsForAdSchemaMember = 12; 45 public static final int MDTREEOP_SELF = 0; 46 public static final int MDTREEOP_CHILDREN = 1; 47 public static final int MDPROP_USERDEFINED0 = 19; 48 49 protected final String name; 50 protected Dimension[] dimensions; 51 52 protected CubeBase(String name, Dimension[] dimensions) { 53 this.name = name; 54 this.dimensions = dimensions; 55 } 56 57 public String getName() { 59 return name; 60 } 61 62 public String getUniqueName() { 63 return name; 64 } 65 66 public String getQualifiedName() { 67 return MondrianResource.instance().MdxCubeName.str(getName()); 68 } 69 70 public Dimension getDimension() { 71 return null; 72 } 73 74 public Hierarchy getHierarchy() { 75 return null; 76 } 77 78 public String getDescription() { 79 return null; 80 } 81 82 public Dimension[] getDimensions() { 83 return dimensions; 84 } 85 86 public Hierarchy lookupHierarchy(String s, boolean unique) { 87 for (Dimension dimension : dimensions) { 88 Hierarchy[] hierarchies = dimension.getHierarchies(); 89 for (Hierarchy hierarchy : hierarchies) { 90 String name = unique 91 ? hierarchy.getUniqueName() : hierarchy.getName(); 92 if (name.equals(s)) { 93 return hierarchy; 94 } 95 } 96 } 97 return null; 98 } 99 100 public OlapElement lookupChild(SchemaReader schemaReader, String s) 101 { 102 return lookupChild(schemaReader, s, MatchType.EXACT); 103 } 104 105 public OlapElement lookupChild( 106 SchemaReader schemaReader, String s, MatchType matchType) 107 { 108 Dimension mdxDimension = (Dimension)lookupDimension(s); 109 if (mdxDimension != null) { 110 return mdxDimension; 111 } 112 113 for (Dimension dimension : dimensions) { 115 OlapElement mdxElement = dimension.lookupChild( 116 schemaReader, s, matchType); 117 if (mdxElement != null) { 118 return mdxElement; 119 } 120 } 121 return null; 122 } 123 124 public Dimension getTimeDimension() { 125 for (Dimension dimension : dimensions) { 126 if (dimension.getDimensionType() == 127 DimensionType.TimeDimension) { 128 return dimension; 129 } 130 } 131 132 return null; 133 } 134 135 public OlapElement lookupDimension(String s) { 136 for (Dimension dimension : dimensions) { 137 if (dimension.getName().equalsIgnoreCase(s)) { 138 return dimension; 139 } 140 } 141 return null; 142 } 143 144 146 private Level getTimeLevel(LevelType levelType) { 147 for (Dimension dimension : dimensions) { 148 if (dimension.getDimensionType() == DimensionType.TimeDimension) { 149 Hierarchy[] hierarchies = dimension.getHierarchies(); 150 for (Hierarchy hierarchy : hierarchies) { 151 Level[] levels = hierarchy.getLevels(); 152 for (Level level : levels) { 153 if (level.getLevelType() == levelType) { 154 return level; 155 } 156 } 157 } 158 } 159 } 160 return null; 161 } 162 163 public Level getYearLevel() { 164 return getTimeLevel(LevelType.TimeYears); 165 } 166 167 public Level getQuarterLevel() { 168 return getTimeLevel(LevelType.TimeQuarters); 169 } 170 171 public Level getMonthLevel() { 172 return getTimeLevel(LevelType.TimeMonths); 173 } 174 175 public Level getWeekLevel() { 176 return getTimeLevel(LevelType.TimeWeeks); 177 } 178 179 } 180 181 182 | Popular Tags |