Search code examples
pentaho

Resources accessible via the DataFactory Interface


Looking into org.pentaho.reporting.engine.classic.core.DataFactory and more specifically into the initialize method (which was formerly part of the ContextAwareDataFactory) I was wondering what resources/what part of the context is accessible via the interface, e.g. via the ResourceManager.

For instance, is it possible to get access to "resources" defined in a report, e.g. data sources or formulas (aside from the report parameters which are accessible via the query Method)? Thanks in advance!


Solution

  • The resource-manager allows you to access raw data stored in the zip/prpt file - but we do not allow you to access the parsed report or any of its (parsed) components.

    With the resource-manager you can for instance load embedded xml- or other files and parse them as part of the query process.

    If you were to do something extra nasty that requires access to the report definition and its content, then you could gain access via a wild hack using subreports:

    1. Create a new report-function (via code). In that function, override the "reportInitialized" method to get the report instance ("event.getState().getReportDefinition()"). Store that object in the function and return it via the "getValue()" method of your function.

    2. Pass that function's result as parameter to a subreport.

    3. The subreport's data-factories can now access the parameter, which is the report object returned by the master-report's function.

    This process is intentionally complex and not fun. We are strongly against using the report in the process of querying data.

    P.S: If you intent to access a SQL/MQL/MDX datasource from a scriptable datasource, then simply use the script-extensions that are built into these datasources since PRD-3.9.

    http://www.sherito.org/2011/11/pentaho-reportings-metadata-datasources.html