Logger forms viewer

Viewer display of logger forms was throwing exceptions on Boolean values
which had been stored as a String or Integer 0 or 1 in some databases.
Now fixed to turn these into a sensible boolean value for the data table
This commit is contained in:
Douglas Gillespie 2023-12-19 15:54:38 +00:00
parent ea6caecc67
commit 0085215eff

View File

@ -208,7 +208,15 @@ public class FormsDataDisplayTable {
Object[] fd = pamDataUnit.getFormData();
int ctIndex = columnIndex-extraColumns.length;
ControlDescription ctrlDescription = formDescription.getInputControlDescriptions().get(ctIndex);
return ctrlDescription.formatDataItem(fd[ctIndex]);
Object value = ctrlDescription.formatDataItem(fd[ctIndex]);
if (value == null) return null;
if (getColumnClass(columnIndex) == Boolean.class) {
if (value instanceof Boolean == false) {
// System.out.println("Bad boolean value: " + value);
return interpretBadBoolean(value);
}
}
return value;
// return fd[ctIndex];
}
catch (Exception e) {
@ -252,6 +260,24 @@ public class FormsDataDisplayTable {
}
public Boolean interpretBadBoolean(Object value) {
if (value == null) {
return null;
}
if (value instanceof String) {
String str = (String) value;
str = str.strip();
return str.equals("1") || str.toLowerCase().equals("false");
}
if (value instanceof Integer) {
int val = (Integer) value;
return val != 0;
}
return null;
}
/**
* Called when data have changed in the datablock.
*/