throw new PlatformDataIntegrityException("error.msg.invalid.outputType", "No matching Output Type: " + outputType);
}
private void addParametersToReport(final MasterReport report, final Map<String, String> queryParams) {
final AppUser currentUser = this.context.authenticatedUser();
try {
final ReportParameterValues rptParamValues = report.getParameterValues();
final ReportParameterDefinition paramsDefinition = report.getParameterDefinition();
/*
* only allow integer, long, date and string parameter types and
* assume all mandatory - could go more detailed like Pawel did in
* Mifos later and could match incoming and pentaho parameters
* better... currently assuming they come in ok... and if not an
* error
*/
for (final ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) {
final String paramName = paramDefEntry.getName();
if (!((paramName.equals("tenantUrl")) || (paramName.equals("userhierarchy") || (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 tenantUrl;
try {
tenantUrl = connection.getMetaData().getURL();
} finally {
connection.close();
}
final String userhierarchy = currentUser.getOffice().getHierarchy();
logger.info("db URL:" + tenantUrl + " userhierarchy:" + userhierarchy);
rptParamValues.put("userhierarchy", userhierarchy);
final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();