001    /*
002    // $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jCatalog.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.Catalog;
013    import org.olap4j.metadata.NamedList;
014    import org.olap4j.metadata.Schema;
015    import org.olap4j.OlapException;
016    import org.olap4j.OlapDatabaseMetaData;
017    import org.olap4j.impl.*;
018    
019    /**
020     * Implementation of {@link Catalog}
021     * for the Mondrian OLAP engine.
022     *
023     * @author jhyde
024     * @version $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jCatalog.java#1 $
025     * @since May 23, 2007
026     */
027    class MondrianOlap4jCatalog implements Catalog, Named {
028        final MondrianOlap4jDatabaseMetaData olap4jDatabaseMetaData;
029    
030        MondrianOlap4jCatalog(
031            MondrianOlap4jDatabaseMetaData olap4jDatabaseMetaData) {
032            this.olap4jDatabaseMetaData = olap4jDatabaseMetaData;
033        }
034    
035        public NamedList<Schema> getSchemas() throws OlapException {
036            // A mondrian instance contains one schema, so implicitly it contains
037            // one catalog
038            NamedList<MondrianOlap4jSchema> list =
039                new NamedListImpl<MondrianOlap4jSchema>();
040            final mondrian.olap.Schema schema =
041                olap4jDatabaseMetaData.olap4jConnection.connection.getSchema();
042            list.add(
043                olap4jDatabaseMetaData.olap4jConnection.toOlap4j(schema));
044            return Olap4jUtil.cast(list);
045        }
046    
047        public String getName() {
048            return MondrianOlap4jConnection.LOCALDB_CATALOG_NAME;
049        }
050    
051        public OlapDatabaseMetaData getMetaData() {
052            return olap4jDatabaseMetaData;
053        }
054    }
055    
056    // End MondrianOlap4jCatalog.java