use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.
the class LayoutFactory method layoutSection.
/**
* Single row layout: section
*/
private DocumentLayoutSectionDescriptor.Builder layoutSection(final I_AD_UI_Section uiSection) {
final IModelTranslationMap uiSectionTrls = InterfaceWrapperHelper.getModelTranslationMap(uiSection);
final DocumentLayoutSectionDescriptor.Builder layoutSectionBuilder = DocumentLayoutSectionDescriptor.builder().setInternalName(uiSection.toString()).setCaption(uiSectionTrls.getColumnTrl(I_AD_UI_Section.COLUMNNAME_Name, uiSection.getName())).setDescription(uiSectionTrls.getColumnTrl(I_AD_UI_Section.COLUMNNAME_Description, uiSection.getDescription()));
if (!uiSection.isActive()) {
return layoutSectionBuilder.setInvalid("UI section not active: " + uiSection);
}
// UI Columns
for (final I_AD_UI_Column uiColumn : getUIProvider().getUIColumns(uiSection)) {
final DocumentLayoutColumnDescriptor.Builder layoutColumnBuilder = layoutColumn(uiColumn);
if (layoutColumnBuilder == null) {
continue;
}
layoutSectionBuilder.addColumn(layoutColumnBuilder);
}
return layoutSectionBuilder;
}
use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.
the class GridTabVOBasedDocumentEntityDescriptorFactory method createAndAddLabelsDocumentField.
private final void createAndAddLabelsDocumentField(final DocumentEntityDescriptor.Builder entityDescriptor, final I_AD_UI_Element labelsUIElement) {
final String labelsFieldName = getLabelsFieldName(labelsUIElement);
final String tablename = entityDescriptor.getTableName().get();
final LabelsLookup lookupDescriptor = createLabelsLookup(labelsUIElement, tablename);
final SqlDocumentEntityDataBindingDescriptor.Builder entityBindings = entityDescriptor.getDataBindingBuilder(SqlDocumentEntityDataBindingDescriptor.Builder.class);
final SqlDocumentFieldDataBindingDescriptor fieldBinding = SqlDocumentFieldDataBindingDescriptor.builder().setFieldName(labelsFieldName).setVirtualColumn(false).setMandatory(false).setWidgetType(DocumentFieldWidgetType.Labels).setValueClass(DocumentFieldWidgetType.Labels.getValueClass()).setSqlValueClass(DocumentFieldWidgetType.Labels.getValueClass()).setLookupDescriptor(lookupDescriptor).build();
entityBindings.addField(fieldBinding);
final IModelTranslationMap trlMap = InterfaceWrapperHelper.getModelTranslationMap(labelsUIElement);
final DocumentFieldDescriptor.Builder fieldBuilder = DocumentFieldDescriptor.builder(labelsFieldName).setCaption(trlMap.getColumnTrl(I_AD_UI_Element.COLUMNNAME_Name, labelsUIElement.getName())).setDescription(trlMap.getColumnTrl(I_AD_UI_Element.COLUMNNAME_Description, labelsUIElement.getDescription())).setKey(false).setParentLink(false).setWidgetType(DocumentFieldWidgetType.Labels).setValueClass(fieldBinding.getValueClass()).setLookupDescriptorProvider(lookupDescriptor).setDefaultFilterInfo(createLabelsDefaultFilterInfo(labelsUIElement)).setDataBinding(fieldBinding);
//
// Add Field builder to document entity
entityDescriptor.addField(fieldBuilder);
//
// Collect special field
collectSpecialField(fieldBuilder);
}
use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.
the class ADProcessDescriptorsFactory method createProcessParaDescriptor.
private DocumentFieldDescriptor.Builder createProcessParaDescriptor(final WebuiProcessClassInfo webuiProcesClassInfo, final I_AD_Process_Para adProcessParam) {
final IModelTranslationMap adProcessParaTrlsMap = InterfaceWrapperHelper.getModelTranslationMap(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 LookupDescriptor lookupDescriptor = lookupDescriptorProvider.provideForScope(LookupDescriptorProvider.LookupScope.DocumentField);
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 ILogicExpression readonlyLogic = expressionFactory.compileOrDefault(adProcessParam.getReadOnlyLogic(), ConstantLogicExpression.FALSE, ILogicExpression.class);
final ILogicExpression displayLogic = expressionFactory.compileOrDefault(adProcessParam.getDisplayLogic(), ConstantLogicExpression.TRUE, ILogicExpression.class);
final ILogicExpression mandatoryLogic = ConstantLogicExpression.of(adProcessParam.isMandatory());
final Optional<IExpression<?>> defaultValueExpr = defaultValueExpressions.extractDefaultValueExpression(adProcessParam.getDefaultValue(), parameterName, widgetType, valueClass, mandatoryLogic.isConstantTrue(), // don't allow using auto sequence
false);
final DocumentFieldDescriptor.Builder paramDescriptor = DocumentFieldDescriptor.builder(parameterName).setCaption(adProcessParaTrlsMap.getColumnTrl(I_AD_Process_Para.COLUMNNAME_Name, adProcessParam.getName())).setDescription(adProcessParaTrlsMap.getColumnTrl(I_AD_Process_Para.COLUMNNAME_Description, adProcessParam.getDescription())).setValueClass(valueClass).setWidgetType(widgetType).setAllowShowPassword(allowShowPassword).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.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.
the class PPOrderLinesLoader method extractDescription.
private static final ITranslatableString extractDescription(final I_PP_Order ppOrder) {
final ITranslatableString docTypeStr;
final I_C_DocType docType = ppOrder.getC_DocType();
if (docType != null) {
final IModelTranslationMap docTypeTrlMap = InterfaceWrapperHelper.getModelTranslationMap(docType);
docTypeStr = docTypeTrlMap.getColumnTrl(I_C_DocType.COLUMNNAME_Name, docType.getName());
} else {
docTypeStr = ImmutableTranslatableString.empty();
}
final ITranslatableString documentNoStr = ImmutableTranslatableString.constant(ppOrder.getDocumentNo());
return ITranslatableString.compose(" ", docTypeStr, documentNoStr);
}
use of de.metas.i18n.IModelTranslationMap in project metasfresh-webui-api by metasfresh.
the class BoardDescriptorRepository method createBoardDescriptor.
private BoardDescriptor createBoardDescriptor(final int boardId) {
//
// Retrieve the board PO
final IQueryBL queryBL = Services.get(IQueryBL.class);
final I_WEBUI_Board boardPO = queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board.class).addEqualsFilter(I_WEBUI_Board.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().create().firstOnly(I_WEBUI_Board.class);
if (boardPO == null) {
throw new EntityNotFoundException("No board found for ID=" + boardId);
}
//
// Board document mappings
final String tableName = Services.get(IADTableDAO.class).retrieveTableName(boardPO.getAD_Table_ID());
final String keyColumnName = InterfaceWrapperHelper.getKeyColumnName(tableName);
// TODO: hardcoded
final String userIdColumnName = "UpdatedBy";
//
// Board document info
// TODO boardPO.getAD_Window_ID();
int adWindowId = 0;
if (adWindowId <= 0) {
adWindowId = RecordZoomWindowFinder.findAD_Window_ID(tableName);
}
final WindowId documentWindowId = WindowId.of(adWindowId);
final DocumentEntityDescriptor documentEntityDescriptor = documentDescriptors.getDocumentEntityDescriptor(documentWindowId);
final SqlDocumentEntityDataBindingDescriptor documentBinding = documentEntityDescriptor.getDataBinding(SqlDocumentEntityDataBindingDescriptor.class);
final String tableAlias = documentBinding.getTableAlias();
//
// Board document lookup provider
final int adValRuleId = boardPO.getAD_Val_Rule_ID();
final LookupDescriptorProvider documentLookupDescriptorProvider = SqlLookupDescriptor.builder().setCtxTableName(null).setCtxColumnName(keyColumnName).setDisplayType(DisplayType.Search).setWidgetType(DocumentFieldWidgetType.Lookup).setAD_Val_Rule_ID(adValRuleId).buildProvider();
//
// Board descriptor
final IModelTranslationMap boardTrlMap = InterfaceWrapperHelper.getModelTranslationMap(boardPO);
final BoardDescriptorBuilder boardDescriptor = BoardDescriptor.builder().boardId(boardPO.getWEBUI_Board_ID()).caption(boardTrlMap.getColumnTrl(I_WEBUI_Board.COLUMNNAME_Name, boardPO.getName())).documentWindowId(documentWindowId).documentLookupDescriptorProvider(documentLookupDescriptorProvider).tableName(tableName).tableAlias(tableAlias).keyColumnName(keyColumnName).userIdColumnName(userIdColumnName).websocketEndpoint(WebSocketConfig.buildBoardTopicName(boardId));
// Source document filters: AD_Val_Rule_ID
if (adValRuleId > 0) {
final IValidationRule validationRule = Services.get(IValidationRuleFactory.class).create(tableName, adValRuleId, // ctx table name
null, // ctx column name
null);
final String sqlWhereClause = validationRule.getPrefilterWhereClause().evaluate(Evaluatees.ofCtx(Env.getCtx()), OnVariableNotFound.Fail);
final DocumentFilter adValRuleFilter = DocumentFilter.builder().setFilterId("AD_Val_Rule_" + adValRuleId).addParameter(DocumentFilterParam.ofSqlWhereClause(true, sqlWhereClause)).build();
boardDescriptor.documentFilter(adValRuleFilter);
}
//
// Lanes
{
queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board_Lane.class).addEqualsFilter(I_WEBUI_Board_Lane.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().orderBy().addColumn(I_WEBUI_Board_Lane.COLUMN_SeqNo).addColumn(// just have a predictable order
I_WEBUI_Board_Lane.COLUMN_WEBUI_Board_Lane_ID).endOrderBy().create().stream(I_WEBUI_Board_Lane.class).map(this::createBoardLaneDescriptor).forEach(lane -> boardDescriptor.lane(lane.getLaneId(), lane));
}
//
// Board card fields
{
queryBL.createQueryBuilderOutOfTrx(I_WEBUI_Board_CardField.class).addEqualsFilter(I_WEBUI_Board_CardField.COLUMN_WEBUI_Board_ID, boardId).addOnlyActiveRecordsFilter().orderBy().addColumn(I_WEBUI_Board_CardField.COLUMN_SeqNo).addColumn(I_WEBUI_Board_CardField.COLUMN_WEBUI_Board_CardField_ID).endOrderBy().create().stream(I_WEBUI_Board_CardField.class).map(cardFieldPO -> createBoardCardFieldDescriptor(cardFieldPO, documentEntityDescriptor)).forEach(cardField -> boardDescriptor.cardFieldByFieldName(cardField.getFieldName(), cardField));
}
//
return boardDescriptor.build();
}
Aggregations