adding support for pentaho report localization
This commit is contained in:
@@ -13419,6 +13419,12 @@ Request Body:
|
|||||||
<dd>Valid Values are HTML, XLS, CSV and PDF for html, Excel,
|
<dd>Valid Values are HTML, XLS, CSV and PDF for html, Excel,
|
||||||
CSV and PDF formats respectively.</dd>
|
CSV and PDF formats respectively.</dd>
|
||||||
<dd>Only applies to Pentaho reports.</dd>
|
<dd>Only applies to Pentaho reports.</dd>
|
||||||
|
<dt>locale</dt>
|
||||||
|
<dd>
|
||||||
|
optional
|
||||||
|
</dd>
|
||||||
|
<dd>Any valid locale Ex: en_US, en_IN, fr_FR etc</dd>
|
||||||
|
<dd>Only applies to Pentaho reports.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>Example Requests:</p>
|
<p>Example Requests:</p>
|
||||||
<div class=apiClick>runreports/Client%20Listing?R_officeId=1</div>
|
<div class=apiClick>runreports/Client%20Listing?R_officeId=1</div>
|
||||||
|
|||||||
+12
-1
@@ -9,12 +9,14 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||||
|
|
||||||
public class ApiParameterHelper {
|
public class ApiParameterHelper {
|
||||||
|
|
||||||
@@ -62,6 +64,15 @@ public class ApiParameterHelper {
|
|||||||
return prettyPrint;
|
return prettyPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
|
||||||
|
Locale locale = null;
|
||||||
|
if (queryParams.getFirst("locale") != null) {
|
||||||
|
String localeAsString = queryParams.getFirst("locale");
|
||||||
|
locale = JsonParserHelper.localeFromString(localeAsString);
|
||||||
|
}
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean exportCsv = false;
|
boolean exportCsv = false;
|
||||||
if (queryParams.getFirst("exportCSV") != null) {
|
if (queryParams.getFirst("exportCSV") != null) {
|
||||||
@@ -128,7 +139,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean genericResultSetPassed(MultivaluedMap<String, String> queryParams) {
|
public static boolean genericResultSetPassed(MultivaluedMap<String, String> queryParams) {
|
||||||
return queryParams.getFirst("genericResultSet") != null;
|
return queryParams.getFirst("genericResultSet") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sqlEncodeString(String str) {
|
public static String sqlEncodeString(String str) {
|
||||||
String singleQuote = "'";
|
String singleQuote = "'";
|
||||||
String twoSingleQuotes = "''";
|
String twoSingleQuotes = "''";
|
||||||
|
|||||||
+6
-6
@@ -518,7 +518,7 @@ public class JsonParserHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Locale localeFromString(final String localeAsString) {
|
public static Locale localeFromString(final String localeAsString) {
|
||||||
|
|
||||||
if (StringUtils.isBlank(localeAsString)) {
|
if (StringUtils.isBlank(localeAsString)) {
|
||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
@@ -531,7 +531,7 @@ public class JsonParserHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String languageCode = "";
|
String languageCode = "";
|
||||||
String courntryCode = "";
|
String countryCode = "";
|
||||||
String variantCode = "";
|
String variantCode = "";
|
||||||
|
|
||||||
String[] localeParts = localeAsString.split("_");
|
String[] localeParts = localeAsString.split("_");
|
||||||
@@ -542,19 +542,19 @@ public class JsonParserHelper {
|
|||||||
|
|
||||||
if (localeParts != null && localeParts.length == 2) {
|
if (localeParts != null && localeParts.length == 2) {
|
||||||
languageCode = localeParts[0];
|
languageCode = localeParts[0];
|
||||||
courntryCode = localeParts[1];
|
countryCode = localeParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localeParts != null && localeParts.length == 3) {
|
if (localeParts != null && localeParts.length == 3) {
|
||||||
languageCode = localeParts[0];
|
languageCode = localeParts[0];
|
||||||
courntryCode = localeParts[1];
|
countryCode = localeParts[1];
|
||||||
variantCode = localeParts[2];
|
variantCode = localeParts[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return localeFrom(languageCode, courntryCode, variantCode);
|
return localeFrom(languageCode, countryCode, variantCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) {
|
private static Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) {
|
||||||
|
|
||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
|
||||||
|
|||||||
+96
-130
@@ -7,6 +7,7 @@ package org.mifosplatform.infrastructure.dataqueries.api;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -41,158 +42,123 @@ import org.springframework.stereotype.Component;
|
|||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class RunreportsApiResource {
|
public class RunreportsApiResource {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final ToApiJsonSerializer<ReportData> toApiJsonSerializer;
|
private final ToApiJsonSerializer<ReportData> toApiJsonSerializer;
|
||||||
private final ReadReportingService readExtraDataAndReportingService;
|
private final ReadReportingService readExtraDataAndReportingService;
|
||||||
private final GenericDataService genericDataService;
|
private final GenericDataService genericDataService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RunreportsApiResource(final PlatformSecurityContext context,
|
public RunreportsApiResource(final PlatformSecurityContext context, final ReadReportingService readExtraDataAndReportingService,
|
||||||
final ReadReportingService readExtraDataAndReportingService,
|
final GenericDataService genericDataService, final ToApiJsonSerializer<ReportData> toApiJsonSerializer) {
|
||||||
final GenericDataService genericDataService,
|
this.context = context;
|
||||||
final ToApiJsonSerializer<ReportData> toApiJsonSerializer) {
|
this.readExtraDataAndReportingService = readExtraDataAndReportingService;
|
||||||
this.context = context;
|
this.genericDataService = genericDataService;
|
||||||
this.readExtraDataAndReportingService = readExtraDataAndReportingService;
|
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||||
this.genericDataService = genericDataService;
|
}
|
||||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{reportName}")
|
@Path("{reportName}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload",
|
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload", "application/vnd.ms-excel", "application/pdf", "text/html" })
|
||||||
"application/vnd.ms-excel", "application/pdf", "text/html" })
|
public Response runReport(@PathParam("reportName") final String reportName, @Context final UriInfo uriInfo) {
|
||||||
public Response runReport(@PathParam("reportName") final String reportName,
|
|
||||||
@Context final UriInfo uriInfo) {
|
|
||||||
|
|
||||||
MultivaluedMap<String, String> queryParams = uriInfo
|
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
|
||||||
.getQueryParameters();
|
|
||||||
|
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
.getQueryParameters());
|
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo.getQueryParameters());
|
||||||
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo
|
boolean parameterType = ApiParameterHelper.parameterType(uriInfo.getQueryParameters());
|
||||||
.getQueryParameters());
|
boolean exportPdf = ApiParameterHelper.exportPdf(uriInfo.getQueryParameters());
|
||||||
boolean parameterType = ApiParameterHelper.parameterType(uriInfo
|
|
||||||
.getQueryParameters());
|
|
||||||
boolean exportPdf = ApiParameterHelper.exportPdf(uriInfo
|
|
||||||
.getQueryParameters());
|
|
||||||
|
|
||||||
checkUserPermissionForReport(reportName, parameterType);
|
checkUserPermissionForReport(reportName, parameterType);
|
||||||
|
|
||||||
String parameterTypeValue = null;
|
String parameterTypeValue = null;
|
||||||
if (!parameterType) {
|
if (!parameterType) {
|
||||||
parameterTypeValue = "report";
|
parameterTypeValue = "report";
|
||||||
if (this.readExtraDataAndReportingService.getReportType(reportName)
|
if (this.readExtraDataAndReportingService.getReportType(reportName).equalsIgnoreCase("Pentaho")) {
|
||||||
.equalsIgnoreCase("Pentaho")) {
|
Map<String, String> reportParams = getReportParams(queryParams, true);
|
||||||
Map<String, String> reportParams = getReportParams(queryParams,
|
Locale locale = ApiParameterHelper.extractLocale(queryParams);
|
||||||
true);
|
return this.readExtraDataAndReportingService.processPentahoRequest(reportName, queryParams.getFirst("output-type"),
|
||||||
return this.readExtraDataAndReportingService
|
reportParams, locale);
|
||||||
.processPentahoRequest(reportName,
|
}
|
||||||
queryParams.getFirst("output-type"),
|
} else {
|
||||||
reportParams);
|
parameterTypeValue = "parameter";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
parameterTypeValue = "parameter";
|
|
||||||
}
|
|
||||||
|
|
||||||
// PDF format
|
// PDF format
|
||||||
|
|
||||||
if (exportPdf) {
|
if (exportPdf) {
|
||||||
Map<String, String> reportParams = getReportParams(queryParams,
|
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||||
false);
|
String pdfFileName = this.readExtraDataAndReportingService.retrieveReportPDF(reportName, parameterTypeValue, reportParams);
|
||||||
String pdfFileName = this.readExtraDataAndReportingService
|
|
||||||
.retrieveReportPDF(reportName, parameterTypeValue,
|
|
||||||
reportParams);
|
|
||||||
|
|
||||||
File file = new File(pdfFileName);
|
File file = new File(pdfFileName);
|
||||||
|
|
||||||
ResponseBuilder response = Response.ok(file);
|
ResponseBuilder response = Response.ok(file);
|
||||||
response.header("Content-Disposition", "attachment; filename=\""
|
response.header("Content-Disposition", "attachment; filename=\"" + pdfFileName + "\"");
|
||||||
+ pdfFileName + "\"");
|
response.header("content-Type", "application/pdf");
|
||||||
response.header("content-Type", "application/pdf");
|
|
||||||
|
|
||||||
return response.build();
|
return response.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exportCsv) {
|
if (!exportCsv) {
|
||||||
Map<String, String> reportParams = getReportParams(queryParams,
|
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||||
false);
|
|
||||||
|
|
||||||
GenericResultsetData result = this.readExtraDataAndReportingService
|
GenericResultsetData result = this.readExtraDataAndReportingService.retrieveGenericResultset(reportName, parameterTypeValue,
|
||||||
.retrieveGenericResultset(reportName, parameterTypeValue,
|
reportParams);
|
||||||
reportParams);
|
|
||||||
|
|
||||||
String json = "";
|
String json = "";
|
||||||
final boolean genericResultSetIsPassed = ApiParameterHelper
|
final boolean genericResultSetIsPassed = ApiParameterHelper.genericResultSetPassed(uriInfo.getQueryParameters());
|
||||||
.genericResultSetPassed(uriInfo.getQueryParameters());
|
final boolean genericResultSet = ApiParameterHelper.genericResultSet(uriInfo.getQueryParameters());
|
||||||
final boolean genericResultSet = ApiParameterHelper
|
if (genericResultSetIsPassed) {
|
||||||
.genericResultSet(uriInfo.getQueryParameters());
|
if (genericResultSet) {
|
||||||
if (genericResultSetIsPassed) {
|
json = this.toApiJsonSerializer.serializePretty(prettyPrint, result);
|
||||||
if (genericResultSet) {
|
} else {
|
||||||
json = this.toApiJsonSerializer.serializePretty(
|
json = this.genericDataService.generateJsonFromGenericResultsetData(result);
|
||||||
prettyPrint, result);
|
}
|
||||||
} else {
|
} else {
|
||||||
json = this.genericDataService
|
json = this.toApiJsonSerializer.serializePretty(prettyPrint, result);
|
||||||
.generateJsonFromGenericResultsetData(result);
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
json = this.toApiJsonSerializer.serializePretty(prettyPrint,
|
|
||||||
result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.ok().entity(json).type(MediaType.APPLICATION_JSON)
|
return Response.ok().entity(json).type(MediaType.APPLICATION_JSON).build();
|
||||||
.build();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// CSV Export
|
// CSV Export
|
||||||
Map<String, String> reportParams = getReportParams(queryParams, false);
|
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||||
StreamingOutput result = this.readExtraDataAndReportingService
|
StreamingOutput result = this.readExtraDataAndReportingService.retrieveReportCSV(reportName, parameterTypeValue, reportParams);
|
||||||
.retrieveReportCSV(reportName, parameterTypeValue, reportParams);
|
|
||||||
|
|
||||||
return Response
|
return Response.ok().entity(result).type("application/x-msdownload")
|
||||||
.ok()
|
.header("Content-Disposition", "attachment;filename=" + reportName.replaceAll(" ", "") + ".csv").build();
|
||||||
.entity(result)
|
}
|
||||||
.type("application/x-msdownload")
|
|
||||||
.header("Content-Disposition",
|
|
||||||
"attachment;filename=" + reportName.replaceAll(" ", "")
|
|
||||||
+ ".csv").build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkUserPermissionForReport(final String reportName,
|
private void checkUserPermissionForReport(final String reportName, final boolean parameterType) {
|
||||||
final boolean parameterType) {
|
|
||||||
|
|
||||||
// Anyone can run a 'report' that is simply getting possible parameter
|
// Anyone can run a 'report' that is simply getting possible parameter
|
||||||
// (dropdown listbox) values.
|
// (dropdown listbox) values.
|
||||||
if (!parameterType) {
|
if (!parameterType) {
|
||||||
AppUser currentUser = context.authenticatedUser();
|
AppUser currentUser = context.authenticatedUser();
|
||||||
if (currentUser.hasNotPermissionForReport(reportName)) {
|
if (currentUser.hasNotPermissionForReport(reportName)) { throw new NoAuthorizationException("Not authorised to run report: "
|
||||||
throw new NoAuthorizationException(
|
+ reportName); }
|
||||||
"Not authorised to run report: " + reportName);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> getReportParams(
|
private Map<String, String> getReportParams(final MultivaluedMap<String, String> queryParams, final Boolean isPentaho) {
|
||||||
final MultivaluedMap<String, String> queryParams,
|
|
||||||
final Boolean isPentaho) {
|
|
||||||
|
|
||||||
Map<String, String> reportParams = new HashMap<String, String>();
|
Map<String, String> reportParams = new HashMap<String, String>();
|
||||||
Set<String> keys = queryParams.keySet();
|
Set<String> keys = queryParams.keySet();
|
||||||
String pKey;
|
String pKey;
|
||||||
String pValue;
|
String pValue;
|
||||||
for (String k : keys) {
|
for (String k : keys) {
|
||||||
|
|
||||||
if (k.startsWith("R_")) {
|
if (k.startsWith("R_")) {
|
||||||
if (isPentaho)
|
if (isPentaho)
|
||||||
pKey = k.substring(2);
|
pKey = k.substring(2);
|
||||||
else
|
else
|
||||||
pKey = "${" + k.substring(2) + "}";
|
pKey = "${" + k.substring(2) + "}";
|
||||||
|
|
||||||
pValue = queryParams.get(k).get(0);
|
pValue = queryParams.get(k).get(0);
|
||||||
reportParams.put(pKey, pValue);
|
reportParams.put(pKey, pValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reportParams;
|
return reportParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-12
@@ -6,6 +6,7 @@
|
|||||||
package org.mifosplatform.infrastructure.dataqueries.service;
|
package org.mifosplatform.infrastructure.dataqueries.service;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@@ -17,23 +18,19 @@ import org.mifosplatform.infrastructure.dataqueries.data.ReportParameterData;
|
|||||||
|
|
||||||
public interface ReadReportingService {
|
public interface ReadReportingService {
|
||||||
|
|
||||||
StreamingOutput retrieveReportCSV(String name, String type,
|
StreamingOutput retrieveReportCSV(String name, String type, Map<String, String> extractedQueryParams);
|
||||||
Map<String, String> extractedQueryParams);
|
|
||||||
|
|
||||||
GenericResultsetData retrieveGenericResultset(String name, String type,
|
GenericResultsetData retrieveGenericResultset(String name, String type, Map<String, String> extractedQueryParams);
|
||||||
Map<String, String> extractedQueryParams);
|
|
||||||
|
|
||||||
Response processPentahoRequest(String reportName, String outputType,
|
Response processPentahoRequest(String reportName, String outputType, Map<String, String> queryParams, Locale locale);
|
||||||
Map<String, String> queryParams);
|
|
||||||
|
|
||||||
String retrieveReportPDF(String name, String type,
|
String retrieveReportPDF(String name, String type, Map<String, String> extractedQueryParams);
|
||||||
Map<String, String> extractedQueryParams);
|
|
||||||
|
|
||||||
String getReportType(String reportName);
|
String getReportType(String reportName);
|
||||||
|
|
||||||
Collection<ReportData> retrieveReportList();
|
Collection<ReportData> retrieveReportList();
|
||||||
|
|
||||||
Collection<ReportParameterData> getAllowedParameters();
|
Collection<ReportParameterData> getAllowedParameters();
|
||||||
|
|
||||||
ReportData retrieveReport(final Long id);
|
ReportData retrieveReport(final Long id);
|
||||||
}
|
}
|
||||||
+20
-18
@@ -19,6 +19,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ import org.mifosplatform.infrastructure.documentmanagement.contentrepository.Fil
|
|||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.useradministration.domain.AppUser;
|
import org.mifosplatform.useradministration.domain.AppUser;
|
||||||
import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
|
import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
|
||||||
|
import org.pentaho.reporting.engine.classic.core.DefaultReportEnvironment;
|
||||||
import org.pentaho.reporting.engine.classic.core.MasterReport;
|
import org.pentaho.reporting.engine.classic.core.MasterReport;
|
||||||
import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
|
import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
|
||||||
import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil;
|
import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil;
|
||||||
@@ -231,7 +233,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response processPentahoRequest(final String reportName, final String outputTypeParam, final Map<String, String> queryParams) {
|
public Response processPentahoRequest(final String reportName, final String outputTypeParam, final Map<String, String> queryParams,
|
||||||
|
final Locale locale) {
|
||||||
|
|
||||||
String outputType = "HTML";
|
String outputType = "HTML";
|
||||||
if (StringUtils.isNotBlank(outputTypeParam)) outputType = outputTypeParam;
|
if (StringUtils.isNotBlank(outputTypeParam)) outputType = outputTypeParam;
|
||||||
@@ -243,7 +246,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
if (noPentaho) { throw new PlatformDataIntegrityException("error.msg.no.pentaho", "Pentaho is not enabled",
|
if (noPentaho) { throw new PlatformDataIntegrityException("error.msg.no.pentaho", "Pentaho is not enabled",
|
||||||
"Pentaho is not enabled"); }
|
"Pentaho is not enabled"); }
|
||||||
|
|
||||||
final String reportPath = FileSystemContentRepository.MIFOSX_BASE_DIR + File.separator + "pentahoReports" + File.separator + reportName + ".prpt";
|
final String reportPath = FileSystemContentRepository.MIFOSX_BASE_DIR + File.separator + "pentahoReports" + File.separator
|
||||||
|
+ reportName + ".prpt";
|
||||||
logger.info("Report path: " + reportPath);
|
logger.info("Report path: " + reportPath);
|
||||||
|
|
||||||
// load report definition
|
// load report definition
|
||||||
@@ -254,7 +258,10 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
try {
|
try {
|
||||||
res = manager.createDirectly(reportPath, MasterReport.class);
|
res = manager.createDirectly(reportPath, MasterReport.class);
|
||||||
MasterReport masterReport = (MasterReport) res.getResource();
|
MasterReport masterReport = (MasterReport) res.getResource();
|
||||||
|
DefaultReportEnvironment reportEnvironment = (DefaultReportEnvironment) masterReport.getReportEnvironment();
|
||||||
|
if (locale != null) {
|
||||||
|
reportEnvironment.setLocale(locale);
|
||||||
|
}
|
||||||
addParametersToReport(masterReport, queryParams);
|
addParametersToReport(masterReport, queryParams);
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
@@ -336,12 +343,9 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
// data scoping
|
// data scoping
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
String tenantdb;
|
String tenantdb;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
tenantdb = connection.getCatalog();
|
tenantdb = connection.getCatalog();
|
||||||
}
|
} finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
String userhierarchy = currentUser.getOffice().getHierarchy();
|
String userhierarchy = currentUser.getOffice().getHierarchy();
|
||||||
@@ -467,8 +471,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
if (reportParameters == null) {
|
if (reportParameters == null) {
|
||||||
reportParameters = new ArrayList<ReportParameterData>();
|
reportParameters = new ArrayList<ReportParameterData>();
|
||||||
}
|
}
|
||||||
reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getParameterId(), rpJoin.getReportParameterName(), rpJoin
|
reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getParameterId(), rpJoin
|
||||||
.getParameterName()));
|
.getReportParameterName(), rpJoin.getParameterName()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (firstReport) {
|
if (firstReport) {
|
||||||
@@ -494,8 +498,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
if (rpJoin.getReportParameterId() != null) {
|
if (rpJoin.getReportParameterId() != null) {
|
||||||
// report has at least one parameter
|
// report has at least one parameter
|
||||||
reportParameters = new ArrayList<ReportParameterData>();
|
reportParameters = new ArrayList<ReportParameterData>();
|
||||||
reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(),rpJoin.getParameterId(), rpJoin.getReportParameterName(), rpJoin
|
reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getParameterId(), rpJoin
|
||||||
.getParameterName()));
|
.getReportParameterName(), rpJoin.getParameterName()));
|
||||||
} else {
|
} else {
|
||||||
reportParameters = null;
|
reportParameters = null;
|
||||||
}
|
}
|
||||||
@@ -509,17 +513,15 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
return reportList;
|
return reportList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ReportParameterData> getAllowedParameters() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ReportParameterData> getAllowedParameters() {
|
|
||||||
|
|
||||||
ReportParameterMapper rm = new ReportParameterMapper();
|
ReportParameterMapper rm = new ReportParameterMapper();
|
||||||
String sql = rm.schema();
|
String sql = rm.schema();
|
||||||
Collection<ReportParameterData> parameters = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
Collection<ReportParameterData> parameters = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final class ReportParameterJoinMapper implements RowMapper<ReportParameterJoinData> {
|
private static final class ReportParameterJoinMapper implements RowMapper<ReportParameterJoinData> {
|
||||||
|
|
||||||
public String schema(final Long reportId) {
|
public String schema(final Long reportId) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,6 +11,3 @@ totalEquities=Total Equities :
|
|||||||
branchName=Branch :
|
branchName=Branch :
|
||||||
asOn=As On :
|
asOn=As On :
|
||||||
retainedEarnings=Retained Earnings
|
retainedEarnings=Retained Earnings
|
||||||
PrintedBy\:=Printed by:
|
|
||||||
On\:=On:
|
|
||||||
Page=Page
|
|
||||||
@@ -8,8 +8,8 @@ expenses=Expenses
|
|||||||
totalExpenses=Total Expenses :
|
totalExpenses=Total Expenses :
|
||||||
netIncome=Net Income :
|
netIncome=Net Income :
|
||||||
branchName=Branch :
|
branchName=Branch :
|
||||||
from=From :
|
period=Period:
|
||||||
to=To :
|
to=To
|
||||||
PrintedBy\:=Printed by:
|
PrintedBy\:=Printed by:
|
||||||
On\:=On:
|
On\:=On:
|
||||||
Page=Page
|
Page=Page
|
||||||
@@ -9,4 +9,6 @@ name=Name
|
|||||||
total=Total :
|
total=Total :
|
||||||
PrintedBy\:=Printed by:
|
PrintedBy\:=Printed by:
|
||||||
On\:=On:
|
On\:=On:
|
||||||
Page=Page
|
Page=Page
|
||||||
|
period=Period:
|
||||||
|
to=To
|
||||||
Reference in New Issue
Block a user