use of com.rebuild.core.metadata.easymeta.EasyField in project rebuild by getrebuild.
the class DataListWrapper method wrapFieldValue.
/**
* @param value
* @param field
* @return
*/
protected Object wrapFieldValue(Object value, Field field) {
EasyField easyField = EasyMetaFactory.valueOf(field);
if (easyField.getDisplayType() == DisplayType.ID) {
return FieldValueHelper.wrapMixValue((ID) value, null);
}
boolean unpack = easyField.getDisplayType() == DisplayType.CLASSIFICATION || easyField.getDisplayType() == DisplayType.PICKLIST || easyField.getDisplayType() == DisplayType.STATE || easyField.getDisplayType() == DisplayType.BOOL;
value = FieldValueHelper.wrapFieldValue(value, easyField, unpack);
if (value != null && isUseDesensitized(easyField)) {
value = FieldValueHelper.desensitized(easyField, value);
}
return value;
}
use of com.rebuild.core.metadata.easymeta.EasyField in project rebuild by getrebuild.
the class FieldValueHelperTest method testWrapFieldValue.
@Test
public void testWrapFieldValue() {
Entity useEntity = MetadataHelper.getEntity(TestAllFields);
for (Field field : useEntity.getFields()) {
Object value = RandomStringUtils.randomNumeric(10);
if (field.getType() == FieldType.REFERENCE) {
value = ID.newId(field.getReferenceEntity().getEntityCode());
} else if (field.getType() == FieldType.DATE || field.getType() == FieldType.TIMESTAMP) {
value = CalendarUtils.now();
} else if (field.getType() == FieldType.LONG || field.getType() == FieldType.DECIMAL) {
value = null;
}
EasyField easyField = EasyMetaFactory.valueOf(field);
if (easyField.getDisplayType() == DisplayType.IMAGE || easyField.getDisplayType() == DisplayType.FILE || easyField.getDisplayType() == DisplayType.N2NREFERENCE || easyField.getDisplayType() == DisplayType.BOOL || easyField.getDisplayType() == DisplayType.STATE || easyField.getDisplayType() == DisplayType.MULTISELECT) {
value = easyField.exprDefaultValue();
} else if (easyField.getDisplayType() == DisplayType.BARCODE || easyField.getDisplayType() == DisplayType.ID) {
value = ID.newId(0);
}
Object wrappedValue = FieldValueHelper.wrapFieldValue(value, easyField, false);
System.out.println(field.getName() + " > " + wrappedValue + " > " + easyField.isBuiltin());
if (wrappedValue != null) {
System.out.println(" TYPE > " + wrappedValue.getClass().getSimpleName());
System.out.println(" UNPACK > " + FieldValueHelper.wrapFieldValue(value, easyField, true));
}
}
}
Aggregations