Problem

Imagine that you have a custom Dynamic Schema Processor in your BA Platform that is responsible for changing Mondrian schema every time an Analyzer Report is executed. For example we do it to apply some additional security layer. Now lets say you want to create a report in the Report Designer, publish it to the BA Server, but at the same time you would like to reuse the existing Dynamic Schema Processor to modify the data present in that report. In our case: to apply security restriction by limiting records that the user will see when he/she opens this report in BA Server.

Solution

It turns out it is possible to achieve that. However, there is one (obvious) limitation, the datasource selected in Report Designer for that report has to be OLAP. To implement this we need to add a query script in datasource definition.

Dynamic Schema Processor

I use the same Dynamic Schema Processor in this example as described in my previous article: Dynamic Schema Processor : Modify Mondrian Schema in run time. If you do not know what Dynamic Schema Processor is or how to use inside BA Server please see the aforementioned article first.

Creating a report in Report Designer with OLAP datasource

As mentioned previously you have to specify OLAP as a datasource for your report.

As this is an OLAP connection you have to specify file with Mondrian Schema and a MDX query. I usually take the latter from BA Server logs.

If you press Preview you will see all five records inside the test table.

Now lets put Name and Age inside report template.

If you render this report you will see five pairs of name and age.

Applying Dynamic Schema Processor to report from Report Designer

To specify that Dynamic Schema Processor should be used for report generation we need to edit OLAP datasource and add Query Script.

Code of Query Script function initQuery(dataRow) { dataFactory.setDynamicSchemaProcessor("com.thejavatar.blog.mondriandsp.ChangeAgeDynamicSchemaProcessor"); } 1 2 3 4 5 function initQuery ( dataRow ) { dataFactory . setDynamicSchemaProcessor ( "com.thejavatar.blog.mondriandsp.ChangeAgeDynamicSchemaProcessor" ) ; }

Now lets publish this report to BA Server.

If we open this report in the BA Server we will see only three records instead of five.

The difference was caused by Dynamic Schema Processor, which was implemented to filter out all records for which column age is not larger than 24.

Links