Add additional checks when generating world documents

This commit is contained in:
George Kalampokis 2022-01-24 11:30:03 +02:00
parent f95a704787
commit 01d32427c3
1 changed files with 12 additions and 6 deletions

View File

@ -248,7 +248,7 @@ public class WordBuilder {
if (field.getValue() != null && !field.getValue().toString().isEmpty()) { if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
this.indent = indent; this.indent = indent;
String format = this.formatter(field); String format = this.formatter(field);
if(format != null){ if(format != null && !format.isEmpty()){
if(format.charAt(0) == '['){ if(format.charAt(0) == '['){
format = format.substring(1, format.length() - 1).replaceAll(",", ", "); format = format.substring(1, format.length() - 1).replaceAll(",", ", ");
} }
@ -310,6 +310,9 @@ public class WordBuilder {
private String formatter(Field field) throws IOException { private String formatter(Field field) throws IOException {
String comboboxType = null; String comboboxType = null;
if (field.getValue() == null) {
return null;
}
switch (field.getViewStyle().getRenderStyle()) { switch (field.getViewStyle().getRenderStyle()) {
case "researchers": case "researchers":
case "projects": case "projects":
@ -383,6 +386,7 @@ public class WordBuilder {
case "datepicker": case "datepicker":
case "datePicker":{ case "datePicker":{
Instant instant; Instant instant;
if (!((String)field.getValue()).isEmpty()) {
try { try {
instant = Instant.parse((String) field.getValue()); instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) { } catch (DateTimeParseException ex) {
@ -390,6 +394,8 @@ public class WordBuilder {
} }
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : ""; return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
} }
return (String) field.getValue();
}
case "freetext": case "freetext":
case "textarea": case "textarea":
case "richTextarea": case "richTextarea":