use of de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier in project metasfresh-webui-api by metasfresh.
the class DocumentFieldDescriptor_convertToValueClass_Test method test_FromBigDecimalString_ToInteger.
@Test
public void test_FromBigDecimalString_ToInteger() {
final String fieldName = "MyInteger";
final Object value = "12345.00000000000";
final DocumentFieldWidgetType widgetType = DocumentFieldWidgetType.Integer;
final Class<?> targetType = widgetType.getValueClass();
final LookupValueByIdSupplier lookupDataSource = null;
final Object valueConverted = DocumentFieldDescriptor.convertToValueClass(fieldName, value, widgetType, targetType, lookupDataSource);
Assert.assertEquals(12345, valueConverted);
}
use of de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier in project metasfresh-webui-api by metasfresh.
the class GridTabVOBasedDocumentEntityDescriptorFactory method extractAutoFilterInitialValue.
private Object extractAutoFilterInitialValue(final GridFieldDefaultFilterDescriptor gridFieldDefaultFilterInfo, final String fieldName, final DocumentFieldWidgetType widgetType) {
final String autoFilterInitialValueStr = gridFieldDefaultFilterInfo.getDefaultValue();
if (Check.isEmpty(autoFilterInitialValueStr, true)) {
return null;
} else if (widgetType.isDateOrTime() && DocumentFieldDefaultFilterDescriptor.AUTOFILTER_INITIALVALUE_DATE_NOW.equalsIgnoreCase(autoFilterInitialValueStr.trim())) {
return DocumentFieldDefaultFilterDescriptor.AUTOFILTER_INITIALVALUE_DATE_NOW;
} else if (// no default value class are not supported
widgetType.getValueClassOrNull() == null) {
return null;
} else if (// lookups are not supported
widgetType == DocumentFieldWidgetType.Lookup) {
return null;
} else if (widgetType == DocumentFieldWidgetType.List) {
return autoFilterInitialValueStr.trim();
} else {
final Class<?> valueClass = widgetType.getValueClass();
// does not matter, we already excluded Lookups above
final LookupValueByIdSupplier lookupDataSource = null;
return DocumentFieldDescriptor.convertToValueClass(fieldName, autoFilterInitialValueStr, widgetType, valueClass, lookupDataSource);
}
}
use of de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier in project metasfresh-webui-api by metasfresh.
the class ADProcessParametersRepository method extractParameterValue.
private static Object extractParameterValue(final Map<String, ProcessInfoParameter> processInfoParameters, final DocumentFieldDescriptor parameterDescriptor) {
final String fieldName = parameterDescriptor.getFieldName();
final ProcessInfoParameter processInfoParameter = processInfoParameters.get(fieldName);
if (processInfoParameter == null) {
return null;
}
final Object parameterValue = processInfoParameter.getParameter();
final String parameterDisplay = processInfoParameter.getInfo();
final Object parameterValueConv = parameterDescriptor.convertToValueClass(parameterValue, new LookupValueByIdSupplier() {
@Override
public DocumentZoomIntoInfo getDocumentZoomInto(final int id) {
throw new UnsupportedOperationException();
}
@Override
public LookupValue findById(final Object id) {
return LookupValue.fromObject(id, parameterDisplay);
}
});
return parameterValueConv;
}
Aggregations