CE-781 Get fields using getFields().containsKey/get, rather than getField(String) - to avoid it throwing, to cut down on exceptions (and warn if we get a real exception, vs., we'll expect non-fields sometimes, so be okay with that)

This commit is contained in:
2024-01-10 19:58:26 -06:00
parent c27a2a986a
commit 8d668d12ec

View File

@ -334,24 +334,34 @@ public class QValueFormatter
if(exposedJoin.getJoinTable().equals(nameParts[0])) if(exposedJoin.getJoinTable().equals(nameParts[0]))
{ {
QTableMetaData joinTable = QContext.getQInstance().getTable(nameParts[0]); QTableMetaData joinTable = QContext.getQInstance().getTable(nameParts[0]);
if(joinTable.getFields().containsKey(nameParts[1]))
{
fieldMap.put(fieldName, joinTable.getField(nameParts[1])); fieldMap.put(fieldName, joinTable.getField(nameParts[1]));
} }
} }
} }
}
else else
{
if(table.getFields().containsKey(fieldName))
{ {
fieldMap.put(fieldName, table.getField(fieldName)); fieldMap.put(fieldName, table.getField(fieldName));
} }
} }
}
catch(Exception e) catch(Exception e)
{ {
/////////////////////////////////////////////////////////// LOG.warn("Error getting field for setting display value", e, logPair("fieldName", fieldName), logPair("tableName", table.getName()));
// put an empty field in - so no formatting will be done //
///////////////////////////////////////////////////////////
LOG.info("Error getting field for setting display value", e, logPair("fieldName", fieldName), logPair("tableName", table.getName()));
fieldMap.put(fieldName, new QFieldMetaData());
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// if we didn't find the field definition, put an empty field in the map, so no formatting will be done //
//////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!fieldMap.containsKey(fieldName))
{
fieldMap.put(fieldName, new QFieldMetaData());
}
} }
setDisplayValuesInRecord(fieldMap, record); setDisplayValuesInRecord(fieldMap, record);