Search in sources :

Example 21 with OlapConnection

use of org.olap4j.OlapConnection 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)

Example 22 with OlapConnection

use of org.olap4j.OlapConnection in project pentaho-platform by pentaho.

the class OlapServiceImpl method flush.

/**
 * Flushes a single schema from the cache.
 */
public void flush(IPentahoSession session, String name) {
    final Lock writeLock = cacheLock.writeLock();
    writeLock.lock();
    try (OlapConnection connection = getConnection(name, session)) {
        final RolapConnection rc = connection.unwrap(RolapConnection.class);
        rc.getCacheControl(null).flushSchema(rc.getSchema());
    } catch (Exception e) {
        LOG.warn(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0019_FAILED_TO_FLUSH", name), e);
        throw new IOlapServiceException(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0019_FAILED_TO_FLUSH", name));
    } finally {
        writeLock.unlock();
    }
}
Also used : RolapConnection(mondrian.rolap.RolapConnection) OlapConnection(org.olap4j.OlapConnection) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) FileSystemException(org.apache.commons.vfs2.FileSystemException) OlapException(org.olap4j.OlapException) SQLException(java.sql.SQLException) IOlapServiceException(org.pentaho.platform.plugin.action.olap.IOlapServiceException) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

OlapConnection (org.olap4j.OlapConnection)22 SQLException (java.sql.SQLException)8 RolapConnection (mondrian.rolap.RolapConnection)5 OlapException (org.olap4j.OlapException)5 Properties (java.util.Properties)4 MondrianServer (mondrian.olap.MondrianServer)4 IOlapServiceException (org.pentaho.platform.plugin.action.olap.IOlapServiceException)4 PrintWriter (java.io.PrintWriter)3 Connection (java.sql.Connection)3 Test (org.junit.Test)3 OlapWrapper (org.olap4j.OlapWrapper)3 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)3 IOException (java.io.IOException)2 Connection (mondrian.olap.Connection)2 RolapConnectionProperties (mondrian.rolap.RolapConnectionProperties)2 UrlRepositoryContentFinder (mondrian.server.UrlRepositoryContentFinder)2 XmlaHandler (mondrian.xmla.XmlaHandler)2 XmlaTestContext (mondrian.xmla.test.XmlaTestContext)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 OlapDataSource (org.olap4j.OlapDataSource)2