johnwoodlock edited a comment on Task MIFOSX-166

Mifosx is now upgraded to use pentaho reporting 3.9.1 - This has a scripting API that has a dataFactory global that allows you to change the database pointed to i.e. the pentaho report can point at different databases and so support multi-tenant deployments.

Pentaho Reporting Design 3.9.1 is now required for report development.

Mifox now passes two additional parameters to pentaho reports:
1) tenantdb - database name (to allow multi-tenant use of pentaho reports)
2) userhierarchy - the user's office hierarchy to allow data scoping

Attached is an example of a pentaho report that supports multi-tenancy.
It has tenantdb and userhierarchy parameters. It uses mifostenant-default JDBC datasource that points to mifostenant-default database... this might be the best convention to follow for development and testing. The parameter defaults of mifostenant-default and . are also probably the best for dev and testing.

To make the report pick the right datasource... Double click the JDBC entry that covers your query(s) and click the Global Scripting tab.
Select ECMAScript and then click Template button. Add the following 3 lines to the end of the init(dataRow) method:

var tenantdb = dataRow.get("tenantdb");
var tenantUrl = "jdbc:mysql://localhost:3306/" + tenantdb;
dataFactory.getConnectionProvider().setUrl(tenantUrl);

Then it should work fine through mifos X.

Notes:
The scripting setting of the database connection does mess up testing queries in preview window (then again so does using any parameter)

I found using the 'pencil' to kick-off the visual query editor caused complex queries to get messed up. However, you can still edit manually by first clicking on the query name.

There is a problem with connections being abandoned and time-outs (to do with Pentaho reporting in general not this specific change) .... to be flesh out later in a different issue.

still to do...
The directory mifosx looks into to find pentaho reports is now .mifosx\reports (no more reference to the tenant)
Existing pentaho reports still need to be refactored to use new 'contract' - new issue later

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Mifos-issues mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mifos-issues

Reply via email to