fixed mifosx-166 multi-tenant pentaho reports
This commit is contained in:
@@ -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-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', 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-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'],
|
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService {
|
public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService {
|
||||||
|
|
||||||
private final Map<Long, DataSource> tenantToDataSourceMap = new ConcurrentHashMap<Long, DataSource>(1);
|
private final Map<Long, DataSource> tenantToDataSourceMap = new ConcurrentHashMap<Long, DataSource>(1);
|
||||||
private final DataSource tenantDataSource;
|
private final DataSource tenantDataSource;
|
||||||
|
|
||||||
|
|||||||
+13
-8
@@ -60,7 +60,7 @@ import com.lowagie.text.pdf.PdfWriter;
|
|||||||
@Service
|
@Service
|
||||||
public class ReadReportingServiceImpl implements ReadReportingService {
|
public class ReadReportingServiceImpl implements ReadReportingService {
|
||||||
|
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory
|
private final static Logger logger = LoggerFactory
|
||||||
@@ -69,13 +69,14 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
private Boolean noPentaho = false;
|
private Boolean noPentaho = false;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ReadReportingServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
public ReadReportingServiceImpl(final PlatformSecurityContext context,
|
||||||
|
final TenantAwareRoutingDataSource dataSource) {
|
||||||
// kick off pentaho reports server
|
// kick off pentaho reports server
|
||||||
ClassicEngineBoot.getInstance().start();
|
ClassicEngineBoot.getInstance().start();
|
||||||
noPentaho = false;
|
noPentaho = false;
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -384,8 +385,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
private void addParametersToReport(final MasterReport report,
|
private void addParametersToReport(final MasterReport report,
|
||||||
final Map<String, String> queryParams) {
|
final Map<String, String> queryParams) {
|
||||||
|
|
||||||
//AppUser currentUser = context.authenticatedUser();
|
// AppUser currentUser = context.authenticatedUser();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReportParameterValues rptParamValues = report.getParameterValues();
|
ReportParameterValues rptParamValues = report.getParameterValues();
|
||||||
ReportParameterDefinition paramsDefinition = report
|
ReportParameterDefinition paramsDefinition = report
|
||||||
@@ -401,7 +402,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition
|
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition
|
||||||
.getParameterDefinitions()) {
|
.getParameterDefinitions()) {
|
||||||
String paramName = paramDefEntry.getName();
|
String paramName = paramDefEntry.getName();
|
||||||
if (paramName != "tenantdb") {
|
if (!(paramName.equals("tenantdb"))) {
|
||||||
|
logger.info("paramName:" + paramName);
|
||||||
String pValue = queryParams.get(paramName);
|
String pValue = queryParams.get(paramName);
|
||||||
if (StringUtils.isBlank(pValue))
|
if (StringUtils.isBlank(pValue))
|
||||||
throw new PlatformDataIntegrityException(
|
throw new PlatformDataIntegrityException(
|
||||||
@@ -424,11 +426,14 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
else
|
else
|
||||||
rptParamValues.put(paramName, pValue);
|
rptParamValues.put(paramName, pValue);
|
||||||
}
|
}
|
||||||
logger.info("db name:" + dataSource.getConnection().getCatalog());
|
String tenantdb = dataSource.getConnection().getCatalog();
|
||||||
rptParamValues.put("tenantdb", "mifostenants-heavensfamily" /*dataSource.getConnection().getCatalog()*/);
|
logger.info("db name:" + tenantdb);
|
||||||
|
rptParamValues.put("tenantdb", tenantdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
logger.info("error.msg.reporting.error:" + e.getMessage());
|
||||||
throw new PlatformDataIntegrityException(
|
throw new PlatformDataIntegrityException(
|
||||||
"error.msg.reporting.error", e.getMessage());
|
"error.msg.reporting.error", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user