001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jSchema.java#1 $ 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) 2007-2007 Julian Hyde 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.olap4j; 011 012 import org.olap4j.metadata.*; 013 import org.olap4j.metadata.Cube; 014 import org.olap4j.metadata.Dimension; 015 import org.olap4j.metadata.Schema; 016 import org.olap4j.OlapException; 017 import org.olap4j.impl.*; 018 019 import java.util.Locale; 020 import java.util.Collection; 021 import java.util.Collections; 022 023 import mondrian.olap.*; 024 import mondrian.olap.Hierarchy; 025 026 /** 027 * Implementation of {@link org.olap4j.metadata.Schema} 028 * for the Mondrian OLAP engine. 029 * 030 * @author jhyde 031 * @version $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jSchema.java#1 $ 032 * @since May 24, 2007 033 */ 034 class MondrianOlap4jSchema implements Schema, Named { 035 final MondrianOlap4jCatalog olap4jCatalog; 036 private final mondrian.olap.Schema schema; 037 final SchemaReader schemaReader; 038 039 MondrianOlap4jSchema( 040 MondrianOlap4jCatalog olap4jCatalog, 041 SchemaReader schemaReader, 042 mondrian.olap.Schema schema) 043 { 044 this.olap4jCatalog = olap4jCatalog; 045 this.schemaReader = schemaReader; 046 this.schema = schema; 047 } 048 049 public Catalog getCatalog() { 050 return olap4jCatalog; 051 } 052 053 public NamedList<Cube> getCubes() throws OlapException { 054 NamedList<MondrianOlap4jCube> list = 055 new NamedListImpl<MondrianOlap4jCube>(); 056 final MondrianOlap4jConnection olap4jConnection = 057 olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection; 058 for (mondrian.olap.Cube cube : schema.getCubes()) { 059 list.add(olap4jConnection.toOlap4j(cube)); 060 } 061 return Olap4jUtil.cast(list); 062 } 063 064 public NamedList<Dimension> getSharedDimensions() throws OlapException { 065 NamedList<MondrianOlap4jDimension> list = 066 new NamedListImpl<MondrianOlap4jDimension>(); 067 final MondrianOlap4jConnection olap4jConnection = 068 olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection; 069 for (Hierarchy hierarchy : schema.getSharedHierarchies()) { 070 list.add(olap4jConnection.toOlap4j(hierarchy.getDimension())); 071 } 072 return Olap4jUtil.cast(list); 073 } 074 075 public Collection<Locale> getSupportedLocales() throws OlapException { 076 return Collections.emptyList(); 077 } 078 079 public String getName() { 080 return schema.getName(); 081 } 082 } 083 084 // End MondrianOlap4jSchema.java