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;
}
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;
}
Aggregations