From 3f95c9a5e2ce757c85c80d43a8201aca08c4cbb1 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Wed, 17 Jul 2024 11:58:17 +0200 Subject: [PATCH] [Fix kbss-cvut/record-manager-ui#185] Avoid adding null numbers to excel as it throws NullPointerException --- .../java/cz/cvut/kbss/study/service/ExcelRecordConverter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cz/cvut/kbss/study/service/ExcelRecordConverter.java b/src/main/java/cz/cvut/kbss/study/service/ExcelRecordConverter.java index f23e01f7..bc62f0db 100644 --- a/src/main/java/cz/cvut/kbss/study/service/ExcelRecordConverter.java +++ b/src/main/java/cz/cvut/kbss/study/service/ExcelRecordConverter.java @@ -127,7 +127,7 @@ private void addDataToExcel(XSSFWorkbook workbook, List data) thro r.createCell(10).setCellValue(rec.getFuselage()); r.createCell(11).setCellValue(rec.getFailDate()); r.createCell(12).setCellValue(rec.getFlightHours()); - r.createCell(13).setCellValue(rec.getNumberOfAirframeOverhauls()); + Optional.ofNullable(rec.getNumberOfAirframeOverhauls()).ifPresent( i -> r.createCell(13).setCellValue(i)); r.createCell(14).setCellValue(rec.getClassificationOfOccurrence()); r.createCell(15).setCellValue(rec.getFailureAscertainmentCircumstances()); r.createCell(16).setCellValue(rec.getRepeatedFailure()); @@ -136,7 +136,7 @@ private void addDataToExcel(XSSFWorkbook workbook, List data) thro r.createCell(19).setCellValue(rec.getMission()); r.createCell(20).setCellValue(rec.getRepair()); r.createCell(21).setCellValue(rec.getRepairDuration()); - r.createCell(22).setCellValue(rec.getAverageNumberOfMenDuringRepairment()); + Optional.ofNullable(rec.getAverageNumberOfMenDuringRepairment()).ifPresent( i -> r.createCell(22).setCellValue(i)); r.createCell(23).setCellValue(rec.getFailureDescription()); r.createCell(24).setCellValue(rec.getDescriptionOfCorrectiveAction()); r.createCell(25).setCellValue(rec.getAc_compName());