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 theMondrianCatalogRepositoryHelperas a backend to store the connection informations and usesDriverManagerto create the connections.It will also check for the presence of a
IConnectionUserRoleMapperand change the roles accordingly before creating a connection.This implementation is thread safe. It will use a
ReadWriteLockto manage the access to its metadata.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.pentaho.platform.plugin.action.olap.IOlapService
IOlapService.Catalog, IOlapService.Cube, IOlapService.Schema
-
-
Field Summary
Fields Modifier and Type Field Description static StringCATALOG_CACHE_REGION
-
Constructor Summary
Constructors Constructor Description OlapServiceImpl()Empty constructor.OlapServiceImpl(org.pentaho.platform.api.repository2.unified.IUnifiedRepository repo, mondrian.olap.MondrianServer server)Constructor for testing purposes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHostedCatalog(String name, String dataSourceInfo, InputStream inputStream, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession session)Adds a hosted catalog on this server.voidaddOlap4jCatalog(String name, String className, String URL, String user, String password, Properties props, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession session)Adds a generic olap4j catalog to this server.voidflush(org.pentaho.platform.api.engine.IPentahoSession session, String name)Flushes a single schema from the cache.voidflushAll(org.pentaho.platform.api.engine.IPentahoSession session)Flushes all schema caches.protected List<IOlapService.Catalog>getCache(org.pentaho.platform.api.engine.IPentahoSession session)Returns a list of catalogs for the current session.List<String>getCatalogNames(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)Provides a list of catalog names known to this server, whether local or remote.List<IOlapService.Catalog>getCatalogs(org.pentaho.platform.api.engine.IPentahoSession session)Provides a list of catalogs known to this server, whether local or remote.org.olap4j.OlapConnectiongetConnection(String catalogName, org.pentaho.platform.api.engine.IPentahoSession session)Provides olap connections to a named catalog.List<IOlapService.Cube>getCubes(String parentCatalog, String parentSchema, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)Provides a list of the available cubes, whether constrained to a particular catalog and/or schema or not.List<IOlapService.Schema>getSchemas(String parentCatalog, org.pentaho.platform.api.engine.IPentahoSession session)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.protected mondrian.xmla.XmlaHandler.XmlaExtragetXmlaExtra(org.olap4j.OlapConnection connection)protected booleanhasAccess(String catalogName, EnumSet<org.pentaho.platform.api.repository2.unified.RepositoryFilePermission> perms, org.pentaho.platform.api.engine.IPentahoSession session)protected voidinitCache(org.pentaho.platform.api.engine.IPentahoSession session)Initializes the cache.protected ObjectmakeCacheSubRegionKey(Locale locale)voidremoveCatalog(String name, org.pentaho.platform.api.engine.IPentahoSession session)Removes a catalog from this server, whether hosted or remote.protected voidresetCache(org.pentaho.platform.api.engine.IPentahoSession session)Clears all caches for all locales.voidsetConnectionFilters(Collection<IOlapConnectionFilter> filters)voidsetHelper(MondrianCatalogRepositoryHelper helper)voidsetMondrianRole(mondrian.olap.Role role)
-
-
-
Field Detail
-
CATALOG_CACHE_REGION
public static String CATALOG_CACHE_REGION
-
-
Constructor Detail
-
OlapServiceImpl
public OlapServiceImpl()
Empty constructor. Creating an instance from here will use thePentahoSystemto fetch theIUnifiedRepositoryat 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 Detail
-
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.
-
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:IOlapServiceAdds a hosted catalog on this server.- Specified by:
addHostedCatalogin interfaceIOlapService- Parameters:
name- NAme of the catalog to createdataSourceInfo- Connection properties. ie: Provider=mondrian;DataSource=SampleData.inputStream- Stream of the mondrian schema's XMLoverwrite- 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:IOlapServiceAdds a generic olap4j catalog to this server.- Specified by:
addOlap4jCatalogin interfaceIOlapService- Parameters:
name- Name of the catalog to useclassName- 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:IOlapServiceRemoves a catalog from this server, whether hosted or remote.- Specified by:
removeCatalogin interfaceIOlapService- 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:
flushin interfaceIOlapService
-
flushAll
public void flushAll(org.pentaho.platform.api.engine.IPentahoSession session)
Description copied from interface:IOlapServiceFlushes all schema caches.- Specified by:
flushAllin interfaceIOlapService
-
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:IOlapServiceProvides 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:
getCatalogNamesin interfaceIOlapService- 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:IOlapServiceProvides 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:
getCatalogsin interfaceIOlapService- 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:IOlapServiceProvides 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:
getSchemasin interfaceIOlapService- 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:IOlapServiceProvides a list of the available cubes, whether constrained to a particular catalog and/or schema or not.- Specified by:
getCubesin interfaceIOlapService- 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:IOlapServiceProvides olap connections to a named catalog. For a list of available catalogs, seeIOlapService.getCatalogs(IPentahoSession).- Specified by:
getConnectionin interfaceIOlapService- Throws:
IOlapServiceException
-
setConnectionFilters
public void setConnectionFilters(Collection<IOlapConnectionFilter> filters)
-
setMondrianRole
public void setMondrianRole(mondrian.olap.Role role)
-
-