Merge branch 'DM-578-npe' into 'master'

DM-578 - Fix NPE in excel reports

Closes DM-578

See merge request redactmanager/redaction-report-service!29
This commit is contained in:
Andrei Isvoran 2023-11-17 10:50:38 +01:00
commit 7cac75e0a4

View File

@ -42,6 +42,12 @@ public class ScmReportService {
var firstRow = sheet.getRow(0);
int firstRowIndex = 1;
while (firstRow == null) {
firstRow = sheet.getRow(firstRowIndex);
firstRowIndex++;
}
int fileColumnIndex = 0;
int textColumnIndex = firstRow.getLastCellNum() - 1;
int valueIndexColumn = firstRow.getLastCellNum() - 2;
@ -55,6 +61,8 @@ public class ScmReportService {
Map<String, Integer> componentIndexMap = new HashMap<>();
Row finalFirstRow = firstRow;
componentLog.getComponentLogEntries().forEach(componentLogEntry -> {
if (componentLogEntry.getComponentValues().isEmpty()) {
@ -71,7 +79,7 @@ public class ScmReportService {
CellUtil.setVerticalAlignment(fileNameCell, VerticalAlignment.TOP);
// Component, file attributes and index cell
addOtherCells(sheet, excelModel, rowIndex, componentIndexMap, componentLogEntry, row, fileModel, firstRow, componentColumnIndex, textColumnIndex, valueIndexColumn);
addOtherCells(sheet, excelModel, rowIndex, componentIndexMap, componentLogEntry, row, fileModel, finalFirstRow, componentColumnIndex, textColumnIndex, valueIndexColumn);
});