[Mondrian] mondrian.rolap.aggmatcher.JdbcSchema.Factory interface

rolf.lear at algorithmics.com rolf.lear at algorithmics.com
Tue Feb 24 10:59:20 EST 2009


hi All.

 

I am trying to figure out the usefulness of the JdbcSchema.Factory
interface.

 

My issue is related to scanning all schemas in an Oracle instance when
looking for Aggregation tables. I was hoping to call the
setSchemaName(String) method on the JdbcSchema instance in order to
restrict the scan for tables to just the schema with the Mondrian
tables.

 

There is no way outside of Mondrian to usefully access the setSchemaName
method though (*** see note later).

 

Based on the existence of the Factory interface, I thought I could
create a separate factory that called the setSchemaName() method
immediately after creating a JdbcSchema instance. Unfortunately this is
not possible because the constructor of JdbcSchema is 'package private'.
Further, I thought I could then extend the StdFactory, but the
constructor of that class is package private too.

 

Thus, there is no way to create a Factory other than the StdFactory.

 

I realized then that the JdbcSchema object is cached, so I though I
could access the cached version by calling JdbcSchema.makeDb() and
setting the SchemaName on the result. Unfortunately this does not work
because I need to pass in the DataSource for the JdbcSchema, and this is
based on the Mondrian Connection class, and this class creates the first
JdbcSchema instance, and loads all the tables before I get to set the
Schema Name...

 

Am I still making sense?

 

So, there is no way to set the schema name before the loadTables()
method is called (which uses the schema name...).

 

*** note: Well, I say all this, but there is a work-around.... the
Factory instance has to be in the mondrian.rolap.aggmatcher package. In
other words, to get it to work in my environment I have to create the
class:

 

package mondrian.rolap.aggmatcher;

 

import javax.sql.DataSource;

import mondrian.rolap.aggmatcher.JdbcSchema;

 

public class MondrianJDBCSchemaNameFactory extends JdbcSchema.StdFactory
{

    

    private static String s_schema = null;

    

    public static void setSchemaName(String schema) {

        s_schema = schema;

    }

    

    public MondrianJDBCSchemaNameFactory() {

        super();

    }

 

    public JdbcSchema makeDB(DataSource dataSource) {

        JdbcSchema db = super.makeDB(dataSource);

        if (s_schema != null) {

            db.setSchemaName(s_schema);

        }

        return db;

    }

 

    public void clearDB(JdbcSchema db) {

        super.clearDB(db);

    }

 

    public void removeDB(JdbcSchema db) {

        super.removeDB(db);

    }

 

}

 

 

Then, to use it I need to do the following:

 

        if (s_dmSchema != null) {

            MondrianProperties.instance().

 
JdbcFactoryClass.setString(MondrianJDBCSchemaNameFactory.class.getName()
);

            MondrianJDBCSchemaNameFactory.setSchemaName(s_dmSchema);

        }

 

        Connection mondrian = DriverManager.getConnection(connectString,
null);

 

 

Obviously, I am reluctant to 'cheat' and create new classes in the
mondrian.rolap.aggmatcher package which are not part of the 'formal'
mondrian distribution....

 

My suggestion would be to make either the constructor of the
JdbcSchema.StdFactory public (so that it can be extended), or
alternatively, the constructor for JdbcSchema public so that Factory
implementations outside of the package can be used to make one...

 

On an administrative note, should I be filing bugs for issues like this?

 

Thanks.

 

Rolf

 

 


 
--------------------------------------------------------------------------
This email and any files transmitted with it are confidential and proprietary to Algorithmics Incorporated and its affiliates ("Algorithmics"). If received in error, use is prohibited. Please destroy, and notify sender. Sender does not waive confidentiality or privilege. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. Algorithmics does not accept liability for any errors or omissions. Any commitment intended to bind Algorithmics must be reduced to writing and signed by an authorized signatory.
--------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090224/cceb8c0d/attachment.html 


More information about the Mondrian mailing list