mondrian.rolap
Class RolapSchema

java.lang.Object
  extended by mondrian.rolap.RolapSchema
All Implemented Interfaces:
Annotated, Schema

public class RolapSchema
extends Object
implements Schema

A RolapSchema is a collection of RolapCubes and shared RolapDimensions. It is shared betweeen RolapConnections. It caches MemberReaders, etc.

Since:
26 July, 2001
Author:
jhyde
See Also:
RolapConnection

Nested Class Summary
(package private) static class RolapSchema.Pool
          A collection of schemas, identified by their connection properties (catalog name, JDBC URL, and so forth).
(package private) static class RolapSchema.RolapSchemaFunctionTable
          Function table which contains all of the user-defined functions in this schema, plus all of the standard functions.
 class RolapSchema.RolapStarRegistry
          RolapStarRegistry is a registry for RolapStars.
 
Field Summary
(package private)  RolapNativeRegistry nativeRegistry
           
(package private)  List<RolapSchemaParameter> parameterList
           
 
Method Summary
protected  void addCube(RolapCube cube)
          Adds a cube to the cube name map.
static boolean cacheContains(RolapSchema rolapSchema)
           
 Cube createCube(String xml)
          Creates a cube by parsing an XML string.
 Dimension createDimension(Cube cube, String xml)
          Creates a dimension in the given cube by parsing an XML string.
(package private)  MemberReader createMemberReader(String sharedName, RolapHierarchy hierarchy, String memberReaderClass)
          Gets a MemberReader with which to read a hierarchy.
(package private) static PropertyFormatter createPropertyFormatter(String className, Scripts.ScriptDefinition script)
          Given the name of a property formatter class, returns a propert formatter.
 boolean equals(Object o)
           
(package private)  void error(String message, mondrian.rolap.RolapSchema.XmlLocation xmlLocation)
          Reports an error.
protected  void finalCleanUp()
           
protected  void finalize()
           
 Map<String,Annotation> getAnnotationMap()
          Returns a list of annotations.
(package private)  Integer getCachedRelationExprCardinality(MondrianDef.Relation relation, MondrianDef.Expression columnExpr)
          Returns the cached cardinality for the column.
(package private) static CellFormatter getCellFormatter(String className, Scripts.ScriptDefinition script)
          Given the name of a cell formatter class and/or a cell formatter script, returns a cell formatter.
 ByteString getChecksum()
          Returns the checksum of this schema.
 List<RolapCube> getCubeList()
           
 Cube[] getCubes()
          Returns a list of all cubes in this schema.
 List<RolapCube> getCubesWithStar(RolapStar star)
           
 DataSourceChangeListener getDataSourceChangeListener()
           
 Role getDefaultRole()
           
 Dialect getDialect()
          Returns this schema's SQL dialect.
 FunTable getFunTable()
          Returns this schema's function table.
 String getId()
          Returns this schema instance unique ID.
 RolapConnection getInternalConnection()
          Connection for purposes of parsing and validation.
protected  org.apache.log4j.Logger getLogger()
           
(package private) static MemberFormatter getMemberFormatter(String className, Scripts.ScriptDefinition script)
          Given the name of a member formatter class, returns a member formatter.
 String getName()
          Returns the name of this schema.
 NamedSet getNamedSet(IdentifierSegment segment)
           
 NamedSet getNamedSet(String name)
           
(package private)  RolapNativeRegistry getNativeRegistry()
           
 Parameter[] getParameters()
          Returns this schema's parameters.
static List<RolapSchema> getRolapSchemas()
           
 RolapSchema.RolapStarRegistry getRolapStarRegistry()
           
 Date getSchemaLoadDate()
          Returns when this schema was last loaded.
 SchemaReader getSchemaReader()
          Creates a SchemaReader without any access control.
 Hierarchy[] getSharedHierarchies()
          Returns a list of shared dimensions in this schema.
(package private)  RolapHierarchy getSharedHierarchy(String name)
           
 RolapStar getStar(String factTableName)
           
 Collection<RolapStar> getStars()
           
 List<Exception> getWarnings()
          Returns a list of warnings and errors that occurred while loading this schema.
 MondrianDef.Schema getXMLSchema()
           
 int hashCode()
           
protected  void load(String catalogUrl, String catalogStr)
          Method called by all constructors to load the catalog into DOM and build application mdx and sql objects.
(package private)  mondrian.rolap.RolapSchema.XmlLocation locate(ElementDef node, String attributeName)
          Returns the location of an element or attribute in an XML document.
protected  RolapCube lookupCube(String cubeName)
          Finds a cube called 'cube' in the current catalog, or return null if no cube exists.
 Cube lookupCube(String cube, boolean failIfNotFound)
          Finds a cube called cube in this schema; if no cube exists, failIfNotFound controls whether to raise an error or return null.
 Role lookupRole(String role)
          Finds a role with a given name in the current catalog, or returns null if no such role exists.
protected  MondrianDef.CalculatedMember lookupXmlCalculatedMember(String calcMemberName, String cubeName)
          Returns an xmlCalculatedMember called 'calcMemberName' in the cube called 'cubeName' or return null if no calculatedMember or xmlCube by those name exists.
(package private)  void putCachedRelationExprCardinality(MondrianDef.Relation relation, MondrianDef.Expression columnExpr, Integer cardinality)
          Sets the cardinality for a given column in cache.
 boolean removeCube(String cubeName)
          Removes a cube.
 Set<String> roleNames()
           
 void setDataSourceChangeListener(DataSourceChangeListener dataSourceChangeListener)
           
(package private) static Scripts.ScriptDefinition toScriptDef(MondrianDef.Script script)
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameterList

final List<RolapSchemaParameter> parameterList

nativeRegistry

final RolapNativeRegistry nativeRegistry
Method Detail

getCellFormatter

static CellFormatter getCellFormatter(String className,
                                      Scripts.ScriptDefinition script)
                               throws Exception
Given the name of a cell formatter class and/or a cell formatter script, returns a cell formatter.

Parameters:
className - Name of cell formatter class
script - Script
Returns:
Cell formatter
Throws:
Exception - if class cannot be instantiated

getMemberFormatter

static MemberFormatter getMemberFormatter(String className,
                                          Scripts.ScriptDefinition script)
                                   throws Exception
Given the name of a member formatter class, returns a member formatter.

Parameters:
className - Name of cell formatter class
script - Script
Returns:
Member formatter
Throws:
Exception - if class cannot be instantiated

createPropertyFormatter

static PropertyFormatter createPropertyFormatter(String className,
                                                 Scripts.ScriptDefinition script)
                                          throws Exception
Given the name of a property formatter class, returns a propert formatter.

Parameters:
className - Name of property formatter class
script - Script
Returns:
Property formatter
Throws:
Exception - if class cannot be instantiated

finalCleanUp

protected void finalCleanUp()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getLogger

protected org.apache.log4j.Logger getLogger()

load

protected void load(String catalogUrl,
                    String catalogStr)
Method called by all constructors to load the catalog into DOM and build application mdx and sql objects.

Parameters:
catalogUrl - URL of catalog
catalogStr - Text of catalog, or null

getSchemaLoadDate

public Date getSchemaLoadDate()
Description copied from interface: Schema
Returns when this schema was last loaded.

Specified by:
getSchemaLoadDate in interface Schema
Returns:
Date and time when this schema was last loaded

getWarnings

public List<Exception> getWarnings()
Description copied from interface: Schema
Returns a list of warnings and errors that occurred while loading this schema.

Specified by:
getWarnings in interface Schema
Returns:
list of warnings

getDefaultRole

public Role getDefaultRole()

getXMLSchema

public MondrianDef.Schema getXMLSchema()

getName

public String getName()
Description copied from interface: Schema
Returns the name of this schema.

Specified by:
getName in interface Schema

getId

public String getId()
Returns this schema instance unique ID.

Specified by:
getId in interface Schema
Returns:
A string representing the schema ID.

getAnnotationMap

public Map<String,Annotation> getAnnotationMap()
Description copied from interface: Annotated
Returns a list of annotations.

The map may be empty, never null.

Specified by:
getAnnotationMap in interface Annotated
Returns:
Map from annotation name to annotations.

getDialect

public Dialect getDialect()
Returns this schema's SQL dialect.

NOTE: This method is not cheap. The implementation gets a connection from the connection pool.

Returns:
dialect

toScriptDef

static Scripts.ScriptDefinition toScriptDef(MondrianDef.Script script)

locate

mondrian.rolap.RolapSchema.XmlLocation locate(ElementDef node,
                                              String attributeName)
Returns the location of an element or attribute in an XML document.

TODO: modify eigenbase-xom parser to return position info

Parameters:
node - Node
attributeName - Attribute name, or null
Returns:
Location of node or attribute in an XML document

error

void error(String message,
           mondrian.rolap.RolapSchema.XmlLocation xmlLocation)
Reports an error. If we are tolerant of errors (see RolapConnectionProperties.Ignore), adds it to the stack, overwise throws. A thrown exception will typically abort the attempt to create the exception.

Parameters:
message - Message
xmlLocation - Location of XML element or attribute that caused the error, or null

createDimension

public Dimension createDimension(Cube cube,
                                 String xml)
Description copied from interface: Schema
Creates a dimension in the given cube by parsing an XML string. The XML string must be either a <Dimension> or a <DimensionUsage>. Returns the dimension created.

Specified by:
createDimension in interface Schema

createCube

public Cube createCube(String xml)
Description copied from interface: Schema
Creates a cube by parsing an XML string. Returns the cube created.

Specified by:
createCube in interface Schema

getRolapSchemas

public static List<RolapSchema> getRolapSchemas()

cacheContains

public static boolean cacheContains(RolapSchema rolapSchema)

lookupCube

public Cube lookupCube(String cube,
                       boolean failIfNotFound)
Description copied from interface: Schema
Finds a cube called cube in this schema; if no cube exists, failIfNotFound controls whether to raise an error or return null.

Specified by:
lookupCube in interface Schema

lookupCube

protected RolapCube lookupCube(String cubeName)
Finds a cube called 'cube' in the current catalog, or return null if no cube exists.


lookupXmlCalculatedMember

protected MondrianDef.CalculatedMember lookupXmlCalculatedMember(String calcMemberName,
                                                                 String cubeName)
Returns an xmlCalculatedMember called 'calcMemberName' in the cube called 'cubeName' or return null if no calculatedMember or xmlCube by those name exists.


getCubesWithStar

public List<RolapCube> getCubesWithStar(RolapStar star)

addCube

protected void addCube(RolapCube cube)
Adds a cube to the cube name map.

See Also:
lookupCube(String)

removeCube

public boolean removeCube(String cubeName)
Description copied from interface: Schema
Removes a cube.

Specified by:
removeCube in interface Schema
Returns:
Whether cube was removed

getCubes

public Cube[] getCubes()
Description copied from interface: Schema
Returns a list of all cubes in this schema.

Specified by:
getCubes in interface Schema

getCubeList

public List<RolapCube> getCubeList()

getSharedHierarchies

public Hierarchy[] getSharedHierarchies()
Description copied from interface: Schema
Returns a list of shared dimensions in this schema.

Specified by:
getSharedHierarchies in interface Schema

getSharedHierarchy

RolapHierarchy getSharedHierarchy(String name)

getNamedSet

public NamedSet getNamedSet(String name)

getNamedSet

public NamedSet getNamedSet(IdentifierSegment segment)

lookupRole

public Role lookupRole(String role)
Description copied from interface: Schema
Finds a role with a given name in the current catalog, or returns null if no such role exists.

Specified by:
lookupRole in interface Schema

roleNames

public Set<String> roleNames()

getFunTable

public FunTable getFunTable()
Description copied from interface: Schema
Returns this schema's function table.

Specified by:
getFunTable in interface Schema

getParameters

public Parameter[] getParameters()
Description copied from interface: Schema
Returns this schema's parameters.

Specified by:
getParameters in interface Schema

createMemberReader

MemberReader createMemberReader(String sharedName,
                                RolapHierarchy hierarchy,
                                String memberReaderClass)
Gets a MemberReader with which to read a hierarchy. If the hierarchy is shared (sharedName is not null), looks up a reader from a cache, or creates one if necessary.

Synchronization: thread safe


getSchemaReader

public SchemaReader getSchemaReader()
Description copied from interface: Schema
Creates a SchemaReader without any access control.

Specified by:
getSchemaReader in interface Schema

getChecksum

public ByteString getChecksum()
Returns the checksum of this schema. Returns null if RolapConnectionProperties.UseContentChecksum is set to false.

Returns:
MD5 checksum of this schema

getInternalConnection

public RolapConnection getInternalConnection()
Connection for purposes of parsing and validation. Careful! It won't have the correct locale or access-control profile.


getCachedRelationExprCardinality

Integer getCachedRelationExprCardinality(MondrianDef.Relation relation,
                                         MondrianDef.Expression columnExpr)
Returns the cached cardinality for the column. The cache is stored in the schema so that queries on different cubes can share them.

Returns:
the cardinality map

putCachedRelationExprCardinality

void putCachedRelationExprCardinality(MondrianDef.Relation relation,
                                      MondrianDef.Expression columnExpr,
                                      Integer cardinality)
Sets the cardinality for a given column in cache.

Parameters:
relation - the relation associated with the column expression
columnExpr - the column expression to cache the cardinality for
cardinality - the cardinality for the column expression

getRolapStarRegistry

public RolapSchema.RolapStarRegistry getRolapStarRegistry()

getStar

public RolapStar getStar(String factTableName)

getStars

public Collection<RolapStar> getStars()

getNativeRegistry

RolapNativeRegistry getNativeRegistry()

getDataSourceChangeListener

public DataSourceChangeListener getDataSourceChangeListener()
Returns:
Returns the dataSourceChangeListener.

setDataSourceChangeListener

public void setDataSourceChangeListener(DataSourceChangeListener dataSourceChangeListener)
Parameters:
dataSourceChangeListener - The dataSourceChangeListener to set.

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads