Search in sources :

Example 6 with OlapException

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

the class OlapServiceImpl method addCatalogToCache.

/**
 * Adds a catalog and its children to the cache.
 * Do not use directly. This must be called with a write lock
 * on the cache.
 *
 * @param catalogName The name of the catalog to load in cache.
 */
private void addCatalogToCache(IPentahoSession session, String catalogName) {
    final IOlapService.Catalog catalog = new Catalog(catalogName, new ArrayList<IOlapService.Schema>());
    OlapConnection connection = null;
    try {
        connection = getConnection(catalogName, session);
        for (org.olap4j.metadata.Schema schema4j : connection.getOlapSchemas()) {
            connection.setSchema(schema4j.getName());
            final IOlapService.Schema schema = new Schema(schema4j.getName(), catalog, new ArrayList<IOlapService.Cube>(), new ArrayList<String>(connection.getAvailableRoleNames()));
            for (org.olap4j.metadata.Cube cube4j : schema4j.getCubes()) {
                schema.cubes.add(new IOlapService.Cube(cube4j.getName(), cube4j.getCaption(), schema));
            }
            catalog.schemas.add(schema);
        }
        // We're done.
        getCache(session).add(catalog);
    } catch (OlapException e) {
        LOG.warn("Failed to initialize the olap connection cache for catalog " + catalogName, e);
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            LOG.warn("Failed to gracefully close an olap connection to catalog " + catalogName, e);
        }
    }
}
Also used : IOlapService(org.pentaho.platform.plugin.action.olap.IOlapService) SQLException(java.sql.SQLException) OlapConnection(org.olap4j.OlapConnection) OlapException(org.olap4j.OlapException)

Aggregations

OlapException (org.olap4j.OlapException)6 SQLException (java.sql.SQLException)4 OlapConnection (org.olap4j.OlapConnection)3 PropertyList (mondrian.olap.Util.PropertyList)2 OlapWrapper (org.olap4j.OlapWrapper)2 IOlapService (org.pentaho.platform.plugin.action.olap.IOlapService)2 Properties (java.util.Properties)1 mondrian.olap (mondrian.olap)1 MondrianProperties (mondrian.olap.MondrianProperties)1 MondrianOlap4jDriver (mondrian.olap4j.MondrianOlap4jDriver)1 RolapConnectionProperties (mondrian.rolap.RolapConnectionProperties)1 LockBox (mondrian.util.LockBox)1 CellSet (org.olap4j.CellSet)1 OlapStatement (org.olap4j.OlapStatement)1 Dimension (org.olap4j.metadata.Dimension)1 Member (org.olap4j.metadata.Member)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)1 MondrianCatalog (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog)1