diff --git a/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java b/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java index 7e6cd31..c960176 100644 --- a/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java +++ b/src/main/java/gov/cabinetoffice/gap/applybackend/service/OdtService.java @@ -232,6 +232,10 @@ private static void populateQuestionResponseTable(AtomicInteger count, AtomicInteger questionIndex = new AtomicInteger(0); OdfTable table = OdfTable.newTable(odt, section.getQuestions().size(), 2); + long firstColumnWidth = table.getWidth() / 3; + long secondColumnWidth = 2 * table.getWidth() / 3; + table.getColumnByIndex(0).setWidth(firstColumnWidth); + table.getColumnByIndex(1).setWidth(secondColumnWidth); section.getQuestions().forEach(question -> { populateDocumentFromQuestionResponse(question, documentText, questionIndex, table); @@ -246,7 +250,7 @@ private static void populateDocumentFromQuestionResponse(SubmissionQuestion ques AtomicInteger questionIndex, OdfTable table) { switch (question.getResponseType()) { - case AddressInput, MultipleSelection -> { + case AddressInput -> { table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); if (question.getMultiResponse() != null) { table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue(String.join(",\n", @@ -255,6 +259,15 @@ private static void populateDocumentFromQuestionResponse(SubmissionQuestion ques table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue("Not provided"); } } + case MultipleSelection -> { + table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); + if (question.getMultiResponse() != null && !Arrays.stream(question.getMultiResponse()).allMatch(String::isEmpty)) { + table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue(String.join(",\n", + question.getMultiResponse()) + "\n"); + } else { + table.getRowByIndex(questionIndex.get()).getCellByIndex(1).setStringValue("Not provided"); + } + } case SingleFileUpload -> { table.getRowByIndex(questionIndex.get()).getCellByIndex(0).setStringValue(question.getFieldTitle()); if (question.getResponse() != null) {