RSS-115: Write Firstline for rss only once
This commit is contained in:
parent
060861e7c3
commit
af1dfa6bc6
@ -26,5 +26,8 @@ public class ExcelModel {
|
|||||||
private List<Integer> writtenRows = new ArrayList<>();
|
private List<Integer> writtenRows = new ArrayList<>();
|
||||||
private boolean rowsBeforeRedactionEntryRowsAdded;
|
private boolean rowsBeforeRedactionEntryRowsAdded;
|
||||||
private boolean hasRssPlaceHolders;
|
private boolean hasRssPlaceHolders;
|
||||||
|
private boolean placeholderInFirstRow;
|
||||||
|
private boolean firstRowWritten;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,9 +123,15 @@ public class ExcelReportGenerationService {
|
|||||||
String filename, ExcelModel excelModel) {
|
String filename, ExcelModel excelModel) {
|
||||||
|
|
||||||
Set<Integer> createdCopyRows = new HashSet<>();
|
Set<Integer> createdCopyRows = new HashSet<>();
|
||||||
|
|
||||||
|
int skipRows = excelModel.isHasRssPlaceHolders() && excelModel.isFirstRowWritten() && !excelModel.isPlaceholderInFirstRow() ? 1 : 0;
|
||||||
for (Map.Entry<CellIdentifier, Cell> cellsToCopyEntry : copiedCells.entrySet()) {
|
for (Map.Entry<CellIdentifier, Cell> cellsToCopyEntry : copiedCells.entrySet()) {
|
||||||
|
|
||||||
int indexToAddRow = cellsToCopyEntry.getKey().getRowIndex() + numberOfRowsToShift;
|
if(excelModel.isHasRssPlaceHolders() && cellsToCopyEntry.getKey().getRowIndex() == 0 && excelModel.isFirstRowWritten() && !excelModel.isPlaceholderInFirstRow()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int indexToAddRow = cellsToCopyEntry.getKey().getRowIndex() + numberOfRowsToShift - skipRows;
|
||||||
|
|
||||||
if (!createdCopyRows.contains(indexToAddRow)) {
|
if (!createdCopyRows.contains(indexToAddRow)) {
|
||||||
sheet.createRow(indexToAddRow);
|
sheet.createRow(indexToAddRow);
|
||||||
@ -146,6 +152,8 @@ public class ExcelReportGenerationService {
|
|||||||
replacePlaceholders(createdCell, placeholderModel, dossierName, filename);
|
replacePlaceholders(createdCell, placeholderModel, dossierName, filename);
|
||||||
replacePlaceholdersForImagePlaceholder(workbook, sheet, createdCell, placeholderModel);
|
replacePlaceholdersForImagePlaceholder(workbook, sheet, createdCell, placeholderModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
excelModel.setFirstRowWritten(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,6 +179,7 @@ public class ExcelReportGenerationService {
|
|||||||
Map<CellIdentifier, Cell> cellsToCopyInPlaceholderRow = new HashMap<>();
|
Map<CellIdentifier, Cell> cellsToCopyInPlaceholderRow = new HashMap<>();
|
||||||
boolean hasRssPlaceHolders = false;
|
boolean hasRssPlaceHolders = false;
|
||||||
int placeholderRow = -1;
|
int placeholderRow = -1;
|
||||||
|
boolean placeholderInFirstRow = false;
|
||||||
for (int j = 0; j < sheet.getLastRowNum() + 1; j++) {
|
for (int j = 0; j < sheet.getLastRowNum() + 1; j++) {
|
||||||
Row actualRow = sheet.getRow(j);
|
Row actualRow = sheet.getRow(j);
|
||||||
if (actualRow != null) {
|
if (actualRow != null) {
|
||||||
@ -181,6 +190,10 @@ public class ExcelReportGenerationService {
|
|||||||
columnWidths.put(i, columnWidth);
|
columnWidths.put(i, columnWidth);
|
||||||
String cellStringValue = cell.getStringCellValue();
|
String cellStringValue = cell.getStringCellValue();
|
||||||
|
|
||||||
|
if(j == 0 && cellStringValue.contains("{{")){
|
||||||
|
placeholderInFirstRow = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(cellStringValue.contains(RSS_PLACEHOLDER_BASE)){
|
if(cellStringValue.contains(RSS_PLACEHOLDER_BASE)){
|
||||||
hasRssPlaceHolders = true;
|
hasRssPlaceHolders = true;
|
||||||
}
|
}
|
||||||
@ -208,7 +221,7 @@ public class ExcelReportGenerationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Calculate Placeholder Cells took: {}", System.currentTimeMillis() - start);
|
log.debug("Calculate Placeholder Cells took: {}", System.currentTimeMillis() - start);
|
||||||
return new ExcelModel(placeholderCellPos, placeholderRow, columnWidths, cellsToCopyBeforePlaceholderRow, cellsToCopyAfterPlaceholderRow, new ArrayList<>(), false, hasRssPlaceHolders);
|
return new ExcelModel(placeholderCellPos, placeholderRow, columnWidths, cellsToCopyBeforePlaceholderRow, cellsToCopyAfterPlaceholderRow, new ArrayList<>(), false, hasRssPlaceHolders, placeholderInFirstRow, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user