001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2006-2010 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.olap;
011
012import java.util.Date;
013import java.util.List;
014
015/**
016 * A <code>Schema</code> is a collection of cubes, shared dimensions, and roles.
017 *
018 * @author jhyde
019 */
020public interface Schema extends Annotated {
021
022    /**
023     * Returns the name of this schema.
024     * @post return != null
025     * @post return.length() > 0
026     */
027    String getName();
028
029    /**
030     * Returns the uniquely generated id of this schema.
031     */
032    String getId();
033
034    /**
035     * Finds a cube called <code>cube</code> in this schema; if no cube
036     * exists, <code>failIfNotFound</code> controls whether to raise an error
037     * or return <code>null</code>.
038     */
039    Cube lookupCube(String cube, boolean failIfNotFound);
040
041    /**
042     * Returns a list of all cubes in this schema.
043     */
044    Cube[] getCubes();
045
046    /**
047     * Returns a list of shared dimensions in this schema.
048     */
049    Hierarchy[] getSharedHierarchies();
050
051    /**
052     * Creates a dimension in the given cube by parsing an XML string. The XML
053     * string must be either a &lt;Dimension&gt; or a &lt;DimensionUsage&gt;.
054     * Returns the dimension created.
055     */
056    Dimension createDimension(Cube cube, String xml);
057
058    /**
059     * Creates a cube by parsing an XML string. Returns the cube created.
060     */
061    Cube createCube(String xml);
062
063    /**
064     * Removes a cube.
065     *
066     * @return Whether cube was removed
067     */
068    boolean removeCube(String cubeName);
069
070    /**
071     * Creates a {@link SchemaReader} without any access control.
072     */
073    SchemaReader getSchemaReader();
074
075    /**
076     * Finds a role with a given name in the current catalog, or returns
077     * <code>null</code> if no such role exists.
078     */
079    Role lookupRole(String role);
080
081    /**
082     * Returns this schema's function table.
083     */
084    FunTable getFunTable();
085
086    /**
087     * Returns this schema's parameters.
088     */
089    Parameter[] getParameters();
090
091    /**
092     * Returns when this schema was last loaded.
093     *
094     * @return Date and time when this schema was last loaded
095     */
096    Date getSchemaLoadDate();
097
098    /**
099     * Returns a list of warnings and errors that occurred while loading this
100     * schema.
101     *
102     * @return list of warnings
103     */
104    List<Exception> getWarnings();
105}
106
107// End Schema.java