logoutdhaval commented on code in PR #2310:
URL: https://github.com/apache/fineract/pull/2310#discussion_r864036681
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadReportingServiceImpl.java:
##########
@@ -162,9 +181,33 @@ public GenericResultsetData retrieveGenericResultset(final
String name, final St
final long startTime = System.currentTimeMillis();
LOG.info("STARTING REPORT: {} Type: {}", name, type);
- final String sql = getSQLtoRun(name, type, queryParams,
isSelfServiceUserReport);
+ String sql = getSQLtoRun(name, type, queryParams,
isSelfServiceUserReport);
+ final GenericResultsetData result;
+ Boolean paginationAllowed =
BooleanUtil.parseBoolean(queryParams.get(ReportingConstants.isPaginationAllowed));
- final GenericResultsetData result =
this.genericDataService.fillGenericResultSet(sql);
+ if (paginationAllowed) {
+ final List<ApiParameterError> dataValidationErrors = new
ArrayList<>();
+
+ final DataValidatorBuilder baseDataValidator = new
DataValidatorBuilder(dataValidationErrors);
+
baseDataValidator.reset().parameter(pageNo).value(queryParams.get(pageNo)).notNull().throwValidationErrors();
+
+
baseDataValidator.reset().parameter(paginationOrderBy).value(queryParams.get(paginationOrderBy)).ignoreIfNull()
+
.matchesRegularExpression(ORDER_BY_REGEX_PATTERN).throwValidationErrors();
+ Integer pageSize =
this.configurationDomainService.reportsPaginationNumberOfItemsPerPage();
+
+ Page<GenericResultsetData> reportData =
this.paginationHelper.fetchPage(this.jdbcTemplate, sql, null, new
ReportMapper(sql));
+ Integer pageNo =
Integer.parseInt(queryParams.get(ReportingConstants.pageNo));
+
+ pageNo = pageNo * pageSize;
+ sql = sql + " order by " + queryParams.get(paginationOrderBy) + "
limit " + pageSize + " offset " + pageNo;
Review Comment:
changed the implementation to your suggested one.
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadReportingServiceImpl.java:
##########
@@ -162,9 +181,33 @@ public GenericResultsetData retrieveGenericResultset(final
String name, final St
final long startTime = System.currentTimeMillis();
LOG.info("STARTING REPORT: {} Type: {}", name, type);
- final String sql = getSQLtoRun(name, type, queryParams,
isSelfServiceUserReport);
+ String sql = getSQLtoRun(name, type, queryParams,
isSelfServiceUserReport);
+ final GenericResultsetData result;
+ Boolean paginationAllowed =
BooleanUtil.parseBoolean(queryParams.get(ReportingConstants.isPaginationAllowed));
- final GenericResultsetData result =
this.genericDataService.fillGenericResultSet(sql);
+ if (paginationAllowed) {
+ final List<ApiParameterError> dataValidationErrors = new
ArrayList<>();
+
+ final DataValidatorBuilder baseDataValidator = new
DataValidatorBuilder(dataValidationErrors);
+
baseDataValidator.reset().parameter(pageNo).value(queryParams.get(pageNo)).notNull().throwValidationErrors();
+
+
baseDataValidator.reset().parameter(paginationOrderBy).value(queryParams.get(paginationOrderBy)).ignoreIfNull()
+
.matchesRegularExpression(ORDER_BY_REGEX_PATTERN).throwValidationErrors();
+ Integer pageSize =
this.configurationDomainService.reportsPaginationNumberOfItemsPerPage();
+
+ Page<GenericResultsetData> reportData =
this.paginationHelper.fetchPage(this.jdbcTemplate, sql, null, new
ReportMapper(sql));
+ Integer pageNo =
Integer.parseInt(queryParams.get(ReportingConstants.pageNo));
+
+ pageNo = pageNo * pageSize;
+ sql = sql + " order by " + queryParams.get(paginationOrderBy) + "
limit " + pageSize + " offset " + pageNo;
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]