Search in sources :

Example 1 with BarcodeScannerType

use of de.metas.process.BarcodeScannerType in project metasfresh-webui-api by metasfresh.

the class ADProcessDescriptorsFactory method createProcessParaDescriptor.

private DocumentFieldDescriptor.Builder createProcessParaDescriptor(final WebuiProcessClassInfo webuiProcesClassInfo, @NonNull final I_AD_Process_Para adProcessParam) {
    final String parameterName = adProcessParam.getColumnName();
    // 
    // Ask the provider if it has some custom lookup descriptor
    LookupDescriptorProvider lookupDescriptorProvider = webuiProcesClassInfo.getLookupDescriptorProviderOrNull(parameterName);
    // Fallback: create an SQL lookup descriptor based on adProcessParam
    if (lookupDescriptorProvider == null) {
        lookupDescriptorProvider = SqlLookupDescriptor.builder().setCtxTableName(null).setCtxColumnName(parameterName).setDisplayType(adProcessParam.getAD_Reference_ID()).setAD_Reference_Value_ID(adProcessParam.getAD_Reference_Value_ID()).setAD_Val_Rule_ID(adProcessParam.getAD_Val_Rule_ID()).setReadOnlyAccess().buildProvider();
    }
    // 
    final Optional<LookupDescriptor> lookupDescriptor = lookupDescriptorProvider.provide();
    final DocumentFieldWidgetType widgetType = extractWidgetType(parameterName, adProcessParam.getAD_Reference_ID(), lookupDescriptor, adProcessParam.isRange());
    final Class<?> valueClass = DescriptorsFactoryHelper.getValueClass(widgetType, lookupDescriptor);
    // process parameters shall always allow displaying the password
    final boolean allowShowPassword = widgetType == DocumentFieldWidgetType.Password ? true : false;
    final BarcodeScannerType barcodeScannerType = extractBarcodeScannerTypeOrNull(adProcessParam, webuiProcesClassInfo);
    final ILogicExpression readonlyLogic = expressionFactory.compileOrDefault(adProcessParam.getReadOnlyLogic(), ConstantLogicExpression.FALSE, ILogicExpression.class);
    final ILogicExpression displayLogic = expressionFactory.compileOrDefault(adProcessParam.getDisplayLogic(), ConstantLogicExpression.TRUE, ILogicExpression.class);
    final ILogicExpression mandatoryLogic = adProcessParam.isMandatory() ? displayLogic : ConstantLogicExpression.FALSE;
    final Optional<IExpression<?>> defaultValueExpr = defaultValueExpressions.extractDefaultValueExpression(adProcessParam.getDefaultValue(), parameterName, widgetType, valueClass, mandatoryLogic.isConstantTrue(), // don't allow using auto sequence
    false);
    final DocumentFieldDescriptor.Builder paramDescriptorBuilder = DocumentFieldDescriptor.builder(parameterName);
    extractAndSetTranslatableValues(adProcessParam, paramDescriptorBuilder);
    final DocumentFieldDescriptor.Builder paramDescriptor = paramDescriptorBuilder.setValueClass(valueClass).setWidgetType(widgetType).setAllowShowPassword(allowShowPassword).barcodeScannerType(barcodeScannerType).setLookupDescriptorProvider(lookupDescriptorProvider).setDefaultValueExpression(defaultValueExpr).setReadonlyLogic(readonlyLogic).setDisplayLogic(displayLogic).setMandatoryLogic(mandatoryLogic).addCharacteristic(Characteristic.PublicField);
    // Add a callout to forward process parameter value (UI) to current process instance
    if (webuiProcesClassInfo.isForwardValueToJavaProcessInstance(parameterName)) {
        paramDescriptor.addCallout(ProcessParametersCallout::forwardValueToCurrentProcessInstance);
    }
    return paramDescriptor;
}
Also used : IExpression(org.adempiere.ad.expression.api.IExpression) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) BarcodeScannerType(de.metas.process.BarcodeScannerType) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 2 with BarcodeScannerType

use of de.metas.process.BarcodeScannerType in project metasfresh-webui-api by metasfresh.

the class ADProcessDescriptorsFactory method extractBarcodeScannerTypeOrNull.

private static BarcodeScannerType extractBarcodeScannerTypeOrNull(@NonNull final I_AD_Process_Para adProcessParamRecord, final WebuiProcessClassInfo webuiProcesClassInfo) {
    final String parameterName = adProcessParamRecord.getColumnName();
    BarcodeScannerType barcodeScannerType = webuiProcesClassInfo.getBarcodeScannerTypeOrNull(parameterName);
    if (barcodeScannerType != null) {
        return barcodeScannerType;
    }
    final String barcodeScannerTypeCode = adProcessParamRecord.getBarcodeScannerType();
    return !Check.isEmpty(barcodeScannerTypeCode, true) ? BarcodeScannerType.ofCode(barcodeScannerTypeCode) : null;
}
Also used : BarcodeScannerType(de.metas.process.BarcodeScannerType)

Aggregations

BarcodeScannerType (de.metas.process.BarcodeScannerType)2 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)1 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)1 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)1 LookupDescriptorProvider (de.metas.ui.web.window.descriptor.LookupDescriptorProvider)1 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)1 IExpression (org.adempiere.ad.expression.api.IExpression)1 ILogicExpression (org.adempiere.ad.expression.api.ILogicExpression)1