Title: Message Title
|
|
|
Currently the Pentaho reports work in a multi-tenant environment as follows.
Code located at https://github.com/openMF/mifosx/blob/develop/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java#L241
1) Tenant Database name is passed into the report along with user hierarchy for datascoping. Global scripting is used within the pentaho report to form the right URL for the tenant database ( since the host and port are not passed to the pentaho report, global scripting assumes that tenant database is located on localhost on port 3306 ) 2) The default data source configured in the report has the right credentials for connecting to this tenant database. The same are used for connecting to the tenant database.
All 4 parameters need to be passed to the report (port, host,username and password)
I took a quick stab at the same, but seem to be running into issues.
The changes made were as follows
{code} for (final ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) { final String paramName = paramDefEntry.getName(); if (!((paramName.equals("tenantdb")) || (paramName.equals("userhierarchy")) || (paramName.equals("host")) || (paramName.equals("port")) || (paramName.equals("username")) || (paramName.equals("password")))) { logger.info("paramName:" + paramName); final String pValue = queryParams.get(paramName); if (StringUtils.isBlank(pValue)) { throw new PlatformDataIntegrityException("error.msg.reporting.error", "Pentaho Parameter: " + paramName + " - not Provided"); }
final Class<?> clazz = paramDefEntry.getValueType(); logger.info("addParametersToReport(" + paramName + " : " + pValue + " : " + clazz.getCanonicalName() + ")"); if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Integer")) { rptParamValues.put(paramName, Integer.parseInt(pValue)); } else if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Long")) { rptParamValues.put(paramName, Long.parseLong(pValue)); } else if (clazz.getCanonicalName().equalsIgnoreCase("java.sql.Date")) { rptParamValues.put(paramName, Date.valueOf(pValue)); } else { rptParamValues.put(paramName, pValue); } }
}
/** * tenant database name and current user's office hierarchy passed * as parameters to allow multitenant penaho reporting and data * scoping **/ final Connection connection = this.dataSource.getConnection(); String tenantdb; try { tenantdb = connection.getCatalog(); } finally { connection.close(); } final String userhierarchy = currentUser.getOffice().getHierarchy(); logger.info("db name:" + tenantdb + " userhierarchy:" + userhierarchy); rptParamValues.put("tenantdb", tenantdb); rptParamValues.put("userhierarchy", userhierarchy);
// Also pass in all Tenant Properties to pentaho report final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); rptParamValues.put("host", tenant.getSchemaServer()); rptParamValues.put("port", tenant.getSchemaServerPort()); rptParamValues.put("username", tenant.getSchemaUsername()); rptParamValues.put("password", tenant.getSchemaPassword()); {/code}
|
|
|
|
|
|
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mifos-issues mailing list
Mifos-issues@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mifos-issues