Class OlapServiceImpl

java.lang.Object
org.pentaho.platform.plugin.action.olap.impl.OlapServiceImpl
All Implemented Interfaces:
IOlapService

public class OlapServiceImpl extends Object implements IOlapService
Implementation of the IOlapService which uses the MondrianCatalogRepositoryHelper as a backend to store the connection informations and uses DriverManager to create the connections.

It will also check for the presence of a IConnectionUserRoleMapper and change the roles accordingly before creating a connection.

This implementation is thread safe. It will use a ReadWriteLock to manage the access to its metadata.

  • Field Details

    • CATALOG_CACHE_REGION

      public static String CATALOG_CACHE_REGION
  • Constructor Details

    • OlapServiceImpl

      public OlapServiceImpl()
      Empty constructor. Creating an instance from here will use the PentahoSystem to fetch the IUnifiedRepository at runtime.
    • OlapServiceImpl

      public OlapServiceImpl(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repo, mondrian.olap.MondrianServer server)
      Constructor for testing purposes. Takes a repository as a parameter.
  • Method Details

    • setHelper

      public void setHelper(MondrianCatalogRepositoryHelper helper)
    • getCache

      protected List<IOlapService.Catalog> getCache(org.pentaho.platform.api.engine.IPentahoSession session)
      Returns a list of catalogs for the current session.

      The cache is stored in the platform's caches in the region CATALOG_CACHE_REGION. It is also segmented by locale, but we only return the correct sub-region according to the session passed as a parameter.

    • resetCache

      protected void resetCache(org.pentaho.platform.api.engine.IPentahoSession session)
      Clears all caches for all locales.
    • makeCacheSubRegionKey

      protected Object makeCacheSubRegionKey(Locale locale)
    • initCache

      protected void initCache(org.pentaho.platform.api.engine.IPentahoSession session)
      Initializes the cache. Only the cache specific to the sesison's locale will be populated.
    • addHostedCatalog

      public void addHostedCatalog(String name, String dataSourceInfo, InputStream inputStream, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession session)
      Description copied from interface: IOlapService
      Adds a hosted catalog on this server.
      Specified by:
      addHostedCatalog in interface IOlapService
      Parameters:
      name - NAme of the catalog to create
      dataSourceInfo - Connection properties. ie: Provider=mondrian;DataSource=SampleData.
      inputStream - Stream of the mondrian schema's XML
      overwrite - Whether to overwrite a catalog of the same name.
      session - Pentaho session to perform this task.
    • hasAccess

      protected boolean hasAccess(String catalogName, EnumSet<org.pentaho.platform.api.repository2.unified.RepositoryFilePermission> perms, org.pentaho.platform.api.engine.IPentahoSession session)
    • addOlap4jCatalog

      public void addOlap4jCatalog(String name, String className, String URL, String user, String password, Properties props, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession session)
      Description copied from interface: IOlapService
      Adds a generic olap4j catalog to this server.
      Specified by:
      addOlap4jCatalog in interface IOlapService
      Parameters:
      name - Name of the catalog to use
      className - The class of the driver to use. Must be an implementation of java.sql.Driver.
      URL - The URL to use.
      user - Username to use when connecting.
      password - Password to use when connecting.
      props - Extra connection parameters to pass.
      overwrite - Whether to overwrite the catalog if it exists.
      session - The session to use when creating the connection.
    • removeCatalog

      public void removeCatalog(String name, org.pentaho.platform.api.engine.IPentahoSession session)
      Description copied from interface: IOlapService
      Removes a catalog from this server, whether hosted or remote.
      Specified by:
      removeCatalog in interface IOlapService
      Parameters:
      name - Name of the catalog to delete.
      session - Session to use when deleting.
    • flush

      public void flush(org.pentaho.platform.api.engine.IPentahoSession session, String name)
      Flushes a single schema from the cache.
      Specified by:
      flush in interface IOlapService
    • flushAll

      public void flushAll(org.pentaho.platform.api.engine.IPentahoSession session)
      Description copied from interface: IOlapService
      Flushes all schema caches.
      Specified by:
      flushAll in interface IOlapService
    • getXmlaExtra

      protected mondrian.xmla.XmlaHandler.XmlaExtra getXmlaExtra(org.olap4j.OlapConnection connection) throws SQLException
      Throws:
      SQLException
    • getCatalogNames

      public List<String> getCatalogNames(org.pentaho.platform.api.engine.IPentahoSession pentahoSession) throws IOlapServiceException
      Description copied from interface: IOlapService
      Provides a list of catalog names known to this server, whether local or remote.

      This method is much cheaper to invoke than IOlapService.getCatalogs(IPentahoSession) since it doesn't require the connection to be opened.

      Specified by:
      getCatalogNames in interface IOlapService
      Parameters:
      pentahoSession - The session asking for catalogs.
      Throws:
      IOlapServiceException
    • getCatalogs

      public List<IOlapService.Catalog> getCatalogs(org.pentaho.platform.api.engine.IPentahoSession session) throws IOlapServiceException
      Description copied from interface: IOlapService
      Provides a list of catalogs known to this server, whether local or remote. Returns a tree, rooted at the catalog, representing all of the schemas and cubes included in this catalog.
      Specified by:
      getCatalogs in interface IOlapService
      Parameters:
      session - The session asking for catalogs.
      Throws:
      IOlapServiceException
    • getSchemas

      public List<IOlapService.Schema> getSchemas(String parentCatalog, org.pentaho.platform.api.engine.IPentahoSession session)
      Description copied from interface: IOlapService
      Provides a list of the available schemas, whether constrained to a particular catalog or not, represented as a tree of the schema and all of its cubes.
      Specified by:
      getSchemas in interface IOlapService
      Parameters:
      parentCatalog - The catalog to constrain the list of schemas, or null to return the whole list.
      session - The session asking for schemas.
      Returns:
      A list of schemas.
    • getCubes

      public List<IOlapService.Cube> getCubes(String parentCatalog, String parentSchema, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
      Description copied from interface: IOlapService
      Provides a list of the available cubes, whether constrained to a particular catalog and/or schema or not.
      Specified by:
      getCubes in interface IOlapService
      Parameters:
      parentCatalog - The catalog to constrain the list of cubes, or null to return the whole list.
      parentSchema - The schema to constrain the list of cubes, or null to return the whole list.
      pentahoSession - The session asking for cubes.
      Returns:
      A list of cubes.
    • getConnection

      public org.olap4j.OlapConnection getConnection(String catalogName, org.pentaho.platform.api.engine.IPentahoSession session) throws IOlapServiceException
      Description copied from interface: IOlapService
      Provides olap connections to a named catalog. For a list of available catalogs, see IOlapService.getCatalogs(IPentahoSession).
      Specified by:
      getConnection in interface IOlapService
      Throws:
      IOlapServiceException
    • setConnectionFilters

      public void setConnectionFilters(Collection<IOlapConnectionFilter> filters)
    • setMondrianRole

      public void setMondrianRole(mondrian.olap.Role role)