Search in sources :

Example 1 with IOlapConnectionFilter

use of org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter in project pentaho-platform by pentaho.

the class OlapServiceImpl method makeOlap4jConnection.

private OlapConnection makeOlap4jConnection(String name) {
    final Olap4jServerInfo olapServerInfo = getHelper().getOlap4jServerInfo(name);
    assert olapServerInfo != null;
    // Make sure the driver is present
    try {
        Class.forName(olapServerInfo.className);
    } catch (ClassNotFoundException e) {
        throw new IOlapServiceException(e);
    }
    // As per the JDBC specs, we can set the user/pass into
    // connection properties called 'user' and 'password'.
    final Properties newProps = new Properties(olapServerInfo.properties);
    // First, apply the filters.
    for (IOlapConnectionFilter filter : this.filters) {
        filter.filterProperties(newProps);
    }
    // so as not to expose this.
    if (olapServerInfo.user != null) {
        newProps.put("user", olapServerInfo.user);
    }
    if (olapServerInfo.password != null) {
        newProps.put("password", olapServerInfo.password);
    }
    try {
        final Connection conn = DriverManager.getConnection(olapServerInfo.URL, newProps);
        return conn.unwrap(OlapConnection.class);
    } catch (SQLException e) {
        throw new IOlapServiceException(e);
    }
}
Also used : IOlapConnectionFilter(org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter) SQLException(java.sql.SQLException) Connection(java.sql.Connection) RolapConnection(mondrian.rolap.RolapConnection) OlapConnection(org.olap4j.OlapConnection) MDXConnection(org.pentaho.platform.plugin.services.connections.mondrian.MDXConnection) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) Olap4jServerInfo(org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper.Olap4jServerInfo) RolapConnectionProperties(mondrian.rolap.RolapConnectionProperties) Properties(java.util.Properties)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1 RolapConnection (mondrian.rolap.RolapConnection)1 RolapConnectionProperties (mondrian.rolap.RolapConnectionProperties)1 OlapConnection (org.olap4j.OlapConnection)1 IOlapConnectionFilter (org.pentaho.platform.plugin.action.olap.IOlapConnectionFilter)1 IOlapServiceException (org.pentaho.platform.plugin.action.olap.IOlapServiceException)1 MDXConnection (org.pentaho.platform.plugin.services.connections.mondrian.MDXConnection)1 Olap4jServerInfo (org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper.Olap4jServerInfo)1