Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODT Structure Changes #121

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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",
Expand All @@ -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) {
Expand Down
Loading