To make the list dynamic (not having to restart Alfresco for each entry added in the database) I added
public List<String> getAllowedValues(){
this.loadDB();
return super.getAllowedValues();
}
to my contraint.
This made the getDisplayLabel method from my first post to trigger a loadDB for each label.
So I had to change to way a value is translated into a label.
public String getDisplayLabel(String constraintAllowableValue)
{
if (!super.getAllowedValues().contains(constraintAllowableValue))
{
return null;
}
String message = this.getAllowedLabels().get(super.getAllowedValues().indexOf(constraintAllowableValue));
return message == null ? constraintAllowableValue : message;
}