EntityLog failed if there is no formatter for date. #PL-2244

This commit is contained in:
Konstantin Krivopustov 2013-09-23 11:35:23 +00:00
parent 90db824ae1
commit 53db6ab82c
2 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,7 @@
*/ */
package com.haulmont.cuba.security.app; package com.haulmont.cuba.security.app;
import com.haulmont.chile.core.datatypes.Datatype;
import com.haulmont.chile.core.datatypes.Datatypes; import com.haulmont.chile.core.datatypes.Datatypes;
import com.haulmont.chile.core.model.Instance; import com.haulmont.chile.core.model.Instance;
import com.haulmont.chile.core.model.MetaClass; import com.haulmont.chile.core.model.MetaClass;
@ -58,7 +59,7 @@ public class EntityLog implements EntityLogAPI {
protected Metadata metadata; protected Metadata metadata;
@Inject @Inject
private UserSessionSource userSessionSource; protected UserSessionSource userSessionSource;
@Inject @Inject
public EntityLog(Configuration configuration) { public EntityLog(Configuration configuration) {
@ -324,15 +325,15 @@ public class EntityLog implements EntityLogAPI {
} }
} }
private String stringify(Object value) { protected String stringify(Object value) {
if (value == null) if (value == null)
return ""; return "";
else if (value instanceof Instance) { else if (value instanceof Instance) {
return ((Instance) value).getInstanceName(); return ((Instance) value).getInstanceName();
} else if (value instanceof Date) { } else if (value instanceof Date) {
SimpleDateFormat df = new SimpleDateFormat( Datatype datatype = Datatypes.getNN(value.getClass());
Datatypes.getFormatStrings(userSessionSource.getLocale()).getDateTimeFormat()); //noinspection unchecked
return df.format(value); return datatype.format(value);
} else if (value instanceof Iterable) { } else if (value instanceof Iterable) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("["); sb.append("[");

View File

@ -22,7 +22,7 @@
<datatype class="com.haulmont.chile.core.datatypes.impl.StringDatatype"/> <datatype class="com.haulmont.chile.core.datatypes.impl.StringDatatype"/>
<datatype class="com.haulmont.chile.core.datatypes.impl.DateTimeDatatype" <datatype class="com.haulmont.chile.core.datatypes.impl.DateTimeDatatype"
format="yyyy-MM-dd'T'HH:mm:ss.SSS"/> format="yyyy-MM-dd HH:mm:ss.SSS"/>
<datatype class="com.haulmont.chile.core.datatypes.impl.DateDatatype" <datatype class="com.haulmont.chile.core.datatypes.impl.DateDatatype"
format="yyyy-MM-dd"/> format="yyyy-MM-dd"/>