Skip to content

Commit

Permalink
- Fixed error with page and record count
Browse files Browse the repository at this point in the history
- Fixed error with value for String inside export to XLSX
  • Loading branch information
yamelsenih committed Jul 30, 2024
1 parent bf54f54 commit 08d0efb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/spin/report_engine/data/ReportInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ private Comparator<Row> getSortingValue(boolean summaryAtEnd) {
}

public ReportInfo completeInfo() {
recordCount = rows.size();
groupedRows = summaryHandler.getAsRows();
List<Row> completeRows = Stream.concat(getRows().stream(), groupedRows.stream())
.sorted(getSortingValue(false))
Expand Down Expand Up @@ -285,7 +284,6 @@ private void processAllChildren(Row parent) {
return row.getLevel() > parent.getLevel() && compareRows(parent, row, groupLevels.size());
}).forEach(row -> {
children.add(row);
System.err.println(row);
});
}

Expand Down Expand Up @@ -317,6 +315,11 @@ public int getReportViewId() {
public long getRecordCount() {
return recordCount;
}

public ReportInfo withRecordCount(int recordCount) {
this.recordCount = recordCount;
return this;
}

public ReportInfo withReportViewId(int reportViewId) {
this.reportViewId = reportViewId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ public String export(ReportInfo reportInfo) {
String value = Util.stripDiacritics(cell.getDisplayValue());
sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value));
} else {
String value = Util.stripDiacritics(cell.getDisplayValue());
String value = cell.getDisplayValue();
if(Util.isEmpty(value)) {
value = (String) obj;
}
value = Util.stripDiacritics(value);
sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.spin.report_engine.mapper.DefaultMapping;
import org.spin.report_engine.mapper.IColumnMapping;
import org.spin.report_engine.util.ClassLoaderMapping;
import org.spin.service.grpc.util.db.CountUtil;
import org.spin.service.grpc.util.db.ParameterUtil;
import org.spin.service.grpc.util.query.Filter;

Expand Down Expand Up @@ -172,7 +173,8 @@ private ReportInfo get(String transactionName) {
MPrintFormat printFormat = new MPrintFormat(Env.getCtx(), getPrintFormatId(), null);
PrintFormat format = PrintFormat.newInstance(printFormat);
QueryDefinition queryDefinition = format.getQuery().withConditions(conditions).withInstanceId(getInstanceId()).withLimit(limit, offset).buildQuery();
ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition).withReportViewId(getReportViewId()).withInstanceId(getInstanceId());
int count = CountUtil.countRecords(queryDefinition.getCompleteQuery(), format.getTableName(), queryDefinition.getParameters());
ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition).withReportViewId(getReportViewId()).withInstanceId(getInstanceId()).withRecordCount(count);
DB.runResultSet(transactionName, queryDefinition.getCompleteQuery(), queryDefinition.getParameters(), resulset -> {
while (resulset.next()) {
format.getItems().forEach(item -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/spin/report_engine/service/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private static Report.Builder convertReport(ReportInfo reportInfo, int limit, in
// Set page token
String nexPageToken = null;
if(LimitUtil.isValidNextPageToken((int) reportInfo.getRecordCount(), offset, limit)) {
nexPageToken = LimitUtil.getPagePrefix(SessionManager.getSessionUuid()) + (pageNumber + 1);
nexPageToken = LimitUtil.getPagePrefix("") + String.valueOf(pageNumber + 1);
}
builder.setNextPageToken(
ValueManager.validateNull(nexPageToken)
Expand Down

0 comments on commit 08d0efb

Please sign in to comment.