com.tonbeller.jpivot.mondrian
Class MondrianModel

java.lang.Object
  extended by com.tonbeller.jpivot.core.ModelSupport
      extended by com.tonbeller.jpivot.olap.query.MdxOlapModel
          extended by com.tonbeller.jpivot.mondrian.MondrianModel
All Implemented Interfaces:
Model, OlapModel, QueryAdapter.QueryAdapterHolder, com.tonbeller.wcf.bookmarks.Bookmarkable

public class MondrianModel
extends MdxOlapModel
implements OlapModel, QueryAdapter.QueryAdapterHolder

The Model represents all (meta-)data for an MDX query.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.tonbeller.jpivot.olap.model.OlapModel
OlapModel.EmptyCubeException, OlapModel.ResultTooLargeException
 
Field Summary
static java.lang.Integer CELL_LIMIT_DEFAULT
          The default value of the cell limit, 0 means that there is no limit.
static java.lang.String CELL_LIMIT_PROP
          The maximum number of cells a given request can return.
 
Fields inherited from interface com.tonbeller.wcf.bookmarks.Bookmarkable
EXTENSIONAL, INTENSIONAL
 
Constructor Summary
MondrianModel()
          constructor must be "default"
 
Method Summary
protected  void addLevel(mondrian.olap.Level monLevel, MondrianHierarchy hierarchy)
          add Level to Hashtable, if not already there
 MondrianMember addMember(mondrian.olap.Member monMember)
          add Member to Hashtable, if not already there
protected  ExpBean createBeanFromExp(java.lang.Object exp)
           
protected  java.lang.Object createExpFromBean(ExpBean expBean)
          create Mondrian exp from expBean
 void destroy()
          session terminated, closing connections etc
 java.lang.Object getBookmarkState(int levelOfDetail)
          create a Memento bean object holding current state.
 mondrian.olap.Connection getConnection()
          get the Mondrian Connection
protected  mondrian.olap.Util.PropertyList getConnectProperties()
          Get connectProperties
protected  java.lang.String getConnectString()
          Get connectString.
 java.lang.String getCurrentMdx()
          get the MDX for the user to edit
 java.lang.String getDataSourceChangeListener()
          Getter for property dataSourceChangeListener.
 Dimension[] getDimensions()
           
 java.lang.String getDynLocale()
          Getter for property dynLocale.
 java.lang.String getDynresolver()
           
 javax.sql.DataSource getExternalDataSource()
          get the external DataSource to be used by Mondrian
 java.lang.String getID()
           
protected  java.lang.String getJdbcDriver()
          Get jdbcDriver.
protected  java.lang.String getMdxQuery()
          Returns the mdxQuery.
 Member[] getMeasures()
           
protected  mondrian.olap.Connection getMonConnection()
          Returns the monConnection.
 QueryAdapter getQueryAdapter()
          Returns the queryAdapter.
 Result getResult()
          Let Mondrian parse and execute the query
 mondrian.olap.Role getRole()
           
 java.lang.Object getRootDecoree()
           
 mondrian.olap.SchemaReader getSchemaReader()
          Attempts to use the Query object's SchemaReader because this is based upon the Cube (calculated Memember) and not just the Connection.
 javax.sql.DataSource getSqlDataSource()
           
 void initialize()
          complete the initilization.
 boolean isAtSameLevel(java.lang.String memberName, java.lang.String logicalName)
          Checks if 2 members are at the same level by comparing the no. of "."
 boolean isConnectionPooling()
          get Mondrian Connection Pooling property
 MondrianDimension lookupDimension(java.lang.String uniqueName)
          find the Dimension.
 MondrianHierarchy lookupHierarchy(java.lang.String uniqueName)
          find the Hierarchy in the dimensions.
 MondrianLevel lookupLevel(java.lang.String uniqueName)
          find level in the Olap Hierarchy.
 Member lookupMemberByUName(java.lang.String uniqueName)
          find member in the Olap Hierarchy.
protected  void removeLogicalNameFromList(java.lang.String hierName)
          sets the dirty hierarchy whose logical representation needs to be removed
 void removeMember(java.lang.String uniqueName)
          remove Member from Hashtable (for a calculated member)
 java.lang.String replaceEnumeratedQuery(java.lang.String query, java.lang.String memberName, java.lang.String logicalName)
          Converts a Enumerated MDX with logical one The enumerated list will always be present with in "{}" Find the first occurrence of the given member in the query and replace everything with the logicalName until we find "}"
protected  mondrian.olap.Query rewriteMDXQuery(mondrian.olap.Query query)
          Rewrites the given MDX query with a generic version
 void setBookmarkState(java.lang.Object state)
          restore state from Memento.
 void setConnectionPooling(boolean connectionPooling)
          set Mondrian Connection Pooling property
 void setConnectProperties(mondrian.olap.Util.PropertyList properties)
          set the Mondrian Connection Properties as an alternative to setConnectString
 void setConnectString(java.lang.String connectString)
          set the Mondrian Connect String
protected  void setCurrentMdx(java.lang.String currentMdx)
          Sets the currentMdx.
 void setDataSourceChangeListener(java.lang.String dataSourceChangeListener)
          Setter for property dataSourceChangeListener.
 void setDynLocale(java.lang.String dynLocale)
          Setter for property dynLocale.
 void setDynresolver(java.lang.String dynresolver)
           
 void setExternalDataSource(javax.sql.DataSource externalDataSource)
          set the external DataSource to be used by Mondrian
 void setID(java.lang.String ID)
          sets an ID string for this model
 void setJdbcDriver(java.lang.String jdbcDriver)
          set the JDBC Driver
 void setMdxQuery(java.lang.String mdxQuery)
          Sets the mdxQuery.
 void setRole(mondrian.olap.Role role)
           
 void setServletContext(javax.servlet.ServletContext servletContext)
          store a servlet context to the model
 
Methods inherited from class com.tonbeller.jpivot.olap.query.MdxOlapModel
beanFromQuax, quaxesFromBeans, restoreSort, storeSort
 
Methods inherited from class com.tonbeller.jpivot.core.ModelSupport
addExtension, addModelChangeListener, fireModelChanged, fireModelChanged, fireStructureChanged, fireStructureChanged, getExtension, getExtensions, getLocale, getRootModel, getTopDecorator, removeModelChangeListener, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.tonbeller.jpivot.core.Model
addExtension, addModelChangeListener, getExtension, getExtensions, getRootModel, getTopDecorator, removeModelChangeListener, setLocale
 

Field Detail

CELL_LIMIT_PROP

public static final java.lang.String CELL_LIMIT_PROP
The maximum number of cells a given request can return. If more are returned, a limit exceeded exception is thrown. Mondrian has a property that limits how many rows of data can be read in, but thats not sufficient. Consider, fifty thousand rows are read in but when the axis is "NON EMPTY" only 25 result versus "NON EMPTY" is not set on the axis and all fifty thousand are returned. One can not rely on the Mondrian "mondrian.result.limit" property to know what to do. So, this new property allows JPivot users to set how big tables can be (limit is rows time columns, total number of cells); this limits the size of the html page that is generated. By default, there is no limit.

See Also:
Constant Field Values

CELL_LIMIT_DEFAULT

public static final java.lang.Integer CELL_LIMIT_DEFAULT
The default value of the cell limit, 0 means that there is no limit.

Constructor Detail

MondrianModel

public MondrianModel()
constructor must be "default"

Method Detail

getID

public java.lang.String getID()
Specified by:
getID in interface OlapModel
Returns:
an ID string for this model

setID

public void setID(java.lang.String ID)
Description copied from interface: OlapModel
sets an ID string for this model

Specified by:
setID in interface OlapModel

getSchemaReader

public mondrian.olap.SchemaReader getSchemaReader()
Attempts to use the Query object's SchemaReader because this is based upon the Cube (calculated Memember) and not just the Connection. Cube SchemaReader contains calculated members. Query SchemaReader contains Cube plus defined members

Returns:

getQueryAdapter

public QueryAdapter getQueryAdapter()
Returns the queryAdapter.

Specified by:
getQueryAdapter in interface QueryAdapter.QueryAdapterHolder
Returns:
MondrianQueryAdapter

getResult

public Result getResult()
                 throws OlapException
Let Mondrian parse and execute the query

Specified by:
getResult in interface OlapModel
Returns:
Result of Query Execution
Throws:
OlapException
See Also:
OlapModel.getResult()

getDimensions

public Dimension[] getDimensions()
Specified by:
getDimensions in interface OlapModel
Returns:
all dimensions of the cube for navigation
See Also:
OlapModel.getDimensions()

getMeasures

public Member[] getMeasures()
Specified by:
getMeasures in interface OlapModel
Returns:
all measures of the cube for navigation
See Also:
OlapModel.getMeasures()

setConnectString

public void setConnectString(java.lang.String connectString)
set the Mondrian Connect String

Parameters:
connectString - Connect String - default: provider=Mondrian;Jdbc=jdbc:odbc:MondrianFoodMart; Catalog=file:///c:/j/mondrian/demo/FoodMart.xml

setConnectProperties

public void setConnectProperties(mondrian.olap.Util.PropertyList properties)
set the Mondrian Connection Properties as an alternative to setConnectString

Parameters:
properties -

setJdbcDriver

public void setJdbcDriver(java.lang.String jdbcDriver)
set the JDBC Driver

Parameters:
jdbcDriver - JDBC Driver - default: sun.jdbc.odbc.JdbcOdbcDriver

setMdxQuery

public void setMdxQuery(java.lang.String mdxQuery)
Sets the mdxQuery.

Parameters:
mdxQuery - The mdxQuery to set

initialize

public void initialize()
                throws OlapException
complete the initilization.

Specified by:
initialize in interface OlapModel
Throws:
OlapException

addLevel

protected void addLevel(mondrian.olap.Level monLevel,
                        MondrianHierarchy hierarchy)
add Level to Hashtable, if not already there

Parameters:
monLevel - - the "key" is the Mondrian Level

addMember

public MondrianMember addMember(mondrian.olap.Member monMember)
add Member to Hashtable, if not already there

Parameters:
monMember - - the "key" is the Mondrian Member
Returns:
the corresponding member

removeMember

public void removeMember(java.lang.String uniqueName)
remove Member from Hashtable (for a calculated member)

Parameters:
uniqueName -

lookupDimension

public MondrianDimension lookupDimension(java.lang.String uniqueName)
find the Dimension.

Parameters:
uniqueName - is the search key (
Returns:
the corresponding MondrianDimension

lookupHierarchy

public MondrianHierarchy lookupHierarchy(java.lang.String uniqueName)
find the Hierarchy in the dimensions.

Parameters:
uniqueName - is the search key
Returns:
the corresponding hierarchy

lookupMemberByUName

public Member lookupMemberByUName(java.lang.String uniqueName)
find member in the Olap Hierarchy.

Specified by:
lookupMemberByUName in class MdxOlapModel
Parameters:
uniqueName - is the search key (Mondrian member unique name)
Returns:
the corresponding member

lookupLevel

public MondrianLevel lookupLevel(java.lang.String uniqueName)
find level in the Olap Hierarchy.

Parameters:
uniqueName - is the search key (Mondrian level)
Returns:
the corresponding level

getRole

public mondrian.olap.Role getRole()

setRole

public void setRole(mondrian.olap.Role role)

getConnection

public mondrian.olap.Connection getConnection()
get the Mondrian Connection

Returns:
The Mondrian Connection

getCurrentMdx

public java.lang.String getCurrentMdx()
get the MDX for the user to edit

Specified by:
getCurrentMdx in class MdxOlapModel
Returns:
current MDX statement
See Also:
MdxOlapModel.getCurrentMdx()

getMdxQuery

protected java.lang.String getMdxQuery()
Returns the mdxQuery.

Returns:
String

getRootDecoree

public java.lang.Object getRootDecoree()

destroy

public void destroy()
session terminated, closing connections etc

Specified by:
destroy in interface OlapModel
Overrides:
destroy in class ModelSupport

setCurrentMdx

protected void setCurrentMdx(java.lang.String currentMdx)
Sets the currentMdx.

Parameters:
currentMdx - The currentMdx to set

getMonConnection

protected mondrian.olap.Connection getMonConnection()
Returns the monConnection.

Returns:
mondrian.olap.Connection

getJdbcDriver

protected java.lang.String getJdbcDriver()
Get jdbcDriver.

Returns:
jdbcDriver

getConnectString

protected java.lang.String getConnectString()
Get connectString.

Returns:
connectString.

getConnectProperties

protected mondrian.olap.Util.PropertyList getConnectProperties()
Get connectProperties

Returns:
connectProperties.

getBookmarkState

public java.lang.Object getBookmarkState(int levelOfDetail)
create a Memento bean object holding current state.

Specified by:
getBookmarkState in interface com.tonbeller.wcf.bookmarks.Bookmarkable
Overrides:
getBookmarkState in class ModelSupport
Returns:
MondrianMemento current state

setBookmarkState

public void setBookmarkState(java.lang.Object state)
restore state from Memento.

Specified by:
setBookmarkState in interface com.tonbeller.wcf.bookmarks.Bookmarkable
Overrides:
setBookmarkState in class ModelSupport
Parameters:
state - bean to be restored

createExpFromBean

protected java.lang.Object createExpFromBean(ExpBean expBean)
                                      throws OlapException
create Mondrian exp from expBean

Specified by:
createExpFromBean in class MdxOlapModel
Parameters:
expBean -
Returns:
@throws OlapException
Throws:
OlapException

createBeanFromExp

protected ExpBean createBeanFromExp(java.lang.Object exp)
                             throws OlapException
Specified by:
createBeanFromExp in class MdxOlapModel
Throws:
OlapException

getSqlDataSource

public javax.sql.DataSource getSqlDataSource()

getDynresolver

public java.lang.String getDynresolver()

setDynresolver

public void setDynresolver(java.lang.String dynresolver)

setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Description copied from interface: OlapModel
store a servlet context to the model

Specified by:
setServletContext in interface OlapModel

isConnectionPooling

public boolean isConnectionPooling()
get Mondrian Connection Pooling property


setConnectionPooling

public void setConnectionPooling(boolean connectionPooling)
set Mondrian Connection Pooling property


getExternalDataSource

public javax.sql.DataSource getExternalDataSource()
get the external DataSource to be used by Mondrian


setExternalDataSource

public void setExternalDataSource(javax.sql.DataSource externalDataSource)
set the external DataSource to be used by Mondrian


getDynLocale

public java.lang.String getDynLocale()
Getter for property dynLocale.

Returns:
Value of property dynLocale.

setDynLocale

public void setDynLocale(java.lang.String dynLocale)
Setter for property dynLocale.

Parameters:
dynLocale - New value of property dynLocale.

getDataSourceChangeListener

public java.lang.String getDataSourceChangeListener()
Getter for property dataSourceChangeListener.

Returns:
Value of property dataSourceChangeListener.

setDataSourceChangeListener

public void setDataSourceChangeListener(java.lang.String dataSourceChangeListener)
Setter for property dataSourceChangeListener.

Parameters:
dataSourceChangeListener - New value of property dataSourceChangeListener.

rewriteMDXQuery

protected mondrian.olap.Query rewriteMDXQuery(mondrian.olap.Query query)
Rewrites the given MDX query with a generic version

Parameters:
queryString - MDX query text
Returns:
a Result object

replaceEnumeratedQuery

public java.lang.String replaceEnumeratedQuery(java.lang.String query,
                                               java.lang.String memberName,
                                               java.lang.String logicalName)
Converts a Enumerated MDX with logical one The enumerated list will always be present with in "{}" Find the first occurrence of the given member in the query and replace everything with the logicalName until we find "}"

Parameters:
result -
Returns:
String version of mondrian Result object.

isAtSameLevel

public boolean isAtSameLevel(java.lang.String memberName,
                             java.lang.String logicalName)
Checks if 2 members are at the same level by comparing the no. of "." [dots] present

Parameters:
result -
Returns:
String version of mondrian Result object.

removeLogicalNameFromList

protected void removeLogicalNameFromList(java.lang.String hierName)
sets the dirty hierarchy whose logical representation needs to be removed