Search in sources :

Example 1 with LookupValueByIdSupplier

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);
}
Also used : LookupValueByIdSupplier(de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier) Test(org.junit.Test)

Example 2 with LookupValueByIdSupplier

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);
    }
}
Also used : LookupValueByIdSupplier(de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier)

Example 3 with LookupValueByIdSupplier

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;
}
Also used : ProcessInfoParameter(de.metas.process.ProcessInfoParameter) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) LookupValueByIdSupplier(de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Aggregations

LookupValueByIdSupplier (de.metas.ui.web.window.model.lookup.LookupValueByIdSupplier)3 ProcessInfoParameter (de.metas.process.ProcessInfoParameter)1 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)1 DocumentZoomIntoInfo (de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo)1 Test (org.junit.Test)1