From 64be6be168f5ae7acae3e2f79326fd70049d2ca8 Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Fri, 24 Jun 2016 15:05:17 +0400 Subject: [PATCH] PL-7417 Application properties screen does not support Date values with custom @Factory and @Stringify --- .../cuba/core/config/AppPropertiesLocator.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/global/src/com/haulmont/cuba/core/config/AppPropertiesLocator.java b/modules/global/src/com/haulmont/cuba/core/config/AppPropertiesLocator.java index 3d21d9bcf1..d7aba3398b 100644 --- a/modules/global/src/com/haulmont/cuba/core/config/AppPropertiesLocator.java +++ b/modules/global/src/com/haulmont/cuba/core/config/AppPropertiesLocator.java @@ -44,6 +44,7 @@ import javax.inject.Inject; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.ParseException; import java.util.*; import java.util.stream.Collectors; @@ -340,5 +341,20 @@ public class AppPropertiesLocator { else entity.setDataTypeName(Datatypes.getNN(String.class).getName()); } + + String dataTypeName = entity.getDataTypeName(); + if (!dataTypeName.equals("enum")) { + Datatype datatype = Datatypes.get(dataTypeName); + String v = null; + try { + v = entity.getDefaultValue(); + datatype.parse(v); + v = entity.getCurrentValue(); + datatype.parse(v); + } catch (ParseException e) { + log.debug("Cannot parse '{}' with {} datatype, using StringDatatype for property {}", v, datatype, entity.getName()); + entity.setDataTypeName(Datatypes.getNN(String.class).getName()); + } + } } } \ No newline at end of file