fixed mifosx-166 multi-tenant pentaho reports

This commit is contained in:
John Woodlock
2013-03-10 20:38:53 +00:00
parent b975da0d45
commit 485182db45
3 changed files with 15 additions and 9 deletions
+1
View File
@@ -138,6 +138,7 @@ dependencies {
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-core', version: '3.9.1.1'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions', version: '3.9.1-GA'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions-scripting', version: '3.9.1-GA'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-wizard-core', version: '3.9.1-GA'],
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Service;
*/
@Service
public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService {
private final Map<Long, DataSource> tenantToDataSourceMap = new ConcurrentHashMap<Long, DataSource>(1);
private final DataSource tenantDataSource;
@@ -60,7 +60,7 @@ import com.lowagie.text.pdf.PdfWriter;
@Service
public class ReadReportingServiceImpl implements ReadReportingService {
private final DataSource dataSource;
private final DataSource dataSource;
private final PlatformSecurityContext context;
private final static Logger logger = LoggerFactory
@@ -69,13 +69,14 @@ public class ReadReportingServiceImpl implements ReadReportingService {
private Boolean noPentaho = false;
@Autowired
public ReadReportingServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
public ReadReportingServiceImpl(final PlatformSecurityContext context,
final TenantAwareRoutingDataSource dataSource) {
// kick off pentaho reports server
ClassicEngineBoot.getInstance().start();
noPentaho = false;
this.context = context;
this.dataSource = dataSource;
this.dataSource = dataSource;
}
@Autowired
@@ -384,8 +385,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
private void addParametersToReport(final MasterReport report,
final Map<String, String> queryParams) {
//AppUser currentUser = context.authenticatedUser();
// AppUser currentUser = context.authenticatedUser();
try {
ReportParameterValues rptParamValues = report.getParameterValues();
ReportParameterDefinition paramsDefinition = report
@@ -401,7 +402,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition
.getParameterDefinitions()) {
String paramName = paramDefEntry.getName();
if (paramName != "tenantdb") {
if (!(paramName.equals("tenantdb"))) {
logger.info("paramName:" + paramName);
String pValue = queryParams.get(paramName);
if (StringUtils.isBlank(pValue))
throw new PlatformDataIntegrityException(
@@ -424,11 +426,14 @@ public class ReadReportingServiceImpl implements ReadReportingService {
else
rptParamValues.put(paramName, pValue);
}
logger.info("db name:" + dataSource.getConnection().getCatalog());
rptParamValues.put("tenantdb", "mifostenants-heavensfamily" /*dataSource.getConnection().getCatalog()*/);
String tenantdb = dataSource.getConnection().getCatalog();
logger.info("db name:" + tenantdb);
rptParamValues.put("tenantdb", tenantdb);
}
} catch (Exception e) {
logger.info("error.msg.reporting.error:" + e.getMessage());
throw new PlatformDataIntegrityException(
"error.msg.reporting.error", e.getMessage());
}