Search in sources :

Example 21 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class BoardDescriptorRepository method buildDescription.

private static final ITranslatableString buildDescription(final Map<String, Object> cardValues, final BoardDescriptor board) {
    final List<ITranslatableString> fieldDescriptions = cardValues.entrySet().stream().map(fieldNameAndValue -> {
        final String fieldName = fieldNameAndValue.getKey();
        final Object fieldValue = fieldNameAndValue.getValue();
        final BoardCardFieldDescriptor cardField = board.getCardFieldByName(fieldName);
        return buildDescription(fieldValue, cardField);
    }).filter(fieldDescription -> fieldDescription != null).collect(ImmutableList.toImmutableList());
    return ITranslatableString.compose("\n", fieldDescriptions);
}
Also used : CCache(org.compiere.util.CCache) DBUniqueConstraintException(org.adempiere.exceptions.DBUniqueConstraintException) I_WEBUI_Board_CardField(de.metas.ui.web.base.model.I_WEBUI_Board_CardField) JSONBoardChangedEventsList(de.metas.ui.web.board.json.events.JSONBoardChangedEventsList) ITrx(org.adempiere.ad.trx.api.ITrx) Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) JSONBoardChangedEventsListBuilder(de.metas.ui.web.board.json.events.JSONBoardChangedEventsList.JSONBoardChangedEventsListBuilder) BigDecimal(java.math.BigDecimal) IStringExpression(org.adempiere.ad.expression.api.IStringExpression) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) ResultSet(java.sql.ResultSet) Map(java.util.Map) ToString(lombok.ToString) Repository(org.springframework.stereotype.Repository) RecordZoomWindowFinder(org.adempiere.model.RecordZoomWindowFinder) ImmutableSet(com.google.common.collect.ImmutableSet) WindowConstants(de.metas.ui.web.window.WindowConstants) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) PreparedStatement(java.sql.PreparedStatement) I_WEBUI_Board_RecordAssignment(de.metas.ui.web.base.model.I_WEBUI_Board_RecordAssignment) EqualsAndHashCode(lombok.EqualsAndHashCode) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) DBException(org.adempiere.exceptions.DBException) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) DateTimeTranslatableString(de.metas.i18n.DateTimeTranslatableString) WebsocketSender(de.metas.ui.web.websocket.WebsocketSender) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) LookupScope(de.metas.ui.web.window.descriptor.LookupDescriptorProvider.LookupScope) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) Joiner(com.google.common.base.Joiner) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) LogManager(de.metas.logging.LogManager) I_WEBUI_Board_Lane(de.metas.ui.web.base.model.I_WEBUI_Board_Lane) BoardDescriptorBuilder(de.metas.ui.web.board.BoardDescriptor.BoardDescriptorBuilder) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) SqlDocumentFieldDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) JSONBoardLaneChangedEvent(de.metas.ui.web.board.json.events.JSONBoardLaneChangedEvent) I_WEBUI_Board(de.metas.ui.web.base.model.I_WEBUI_Board) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SQLException(java.sql.SQLException) DB(org.compiere.util.DB) ICurrencyDAO(de.metas.currency.ICurrencyDAO) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) ImmutableList(com.google.common.collect.ImmutableList) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) DisplayType(org.compiere.util.DisplayType) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) I_AD_User(org.compiere.model.I_AD_User) DocumentFieldValueLoader(de.metas.ui.web.window.descriptor.sql.DocumentFieldValueLoader) LinkedHashSet(java.util.LinkedHashSet) OnVariableNotFound(org.adempiere.ad.expression.api.IExpressionEvaluator.OnVariableNotFound) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) Logger(org.slf4j.Logger) BoardFieldLoader(de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader) Evaluatees(org.compiere.util.Evaluatees) DocumentDescriptorFactory(de.metas.ui.web.window.descriptor.factory.DocumentDescriptorFactory) DocumentFilterParam(de.metas.ui.web.document.filter.DocumentFilterParam) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) WindowId(de.metas.ui.web.window.datatypes.WindowId) IQueryBL(org.adempiere.ad.dao.IQueryBL) Amount(de.metas.currency.Amount) Consumer(java.util.function.Consumer) NumberUtils(org.adempiere.util.NumberUtils) AdempiereException(org.adempiere.exceptions.AdempiereException) ListUtils(org.adempiere.util.collections.ListUtils) IValidationRuleFactory(org.adempiere.ad.validationRule.IValidationRuleFactory) Preconditions(com.google.common.base.Preconditions) IValidationRule(org.adempiere.ad.validationRule.IValidationRule) WebSocketConfig(de.metas.ui.web.websocket.WebSocketConfig) CompositeStringExpression(org.adempiere.ad.expression.api.impl.CompositeStringExpression) ITranslatableString(de.metas.i18n.ITranslatableString) ToString(lombok.ToString) ITranslatableString(de.metas.i18n.ITranslatableString) DateTimeTranslatableString(de.metas.i18n.DateTimeTranslatableString) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString)

Example 22 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class WEBUI_HUsToPick_PickCU method checkPreconditionsApplicable.

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
    if (selectedRowIds.isEmpty()) {
        return ProcessPreconditionsResolution.rejectBecauseNoSelection();
    } else if (selectedRowIds.isMoreThanOneDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final HUEditorRow huRow = getSingleSelectedRow();
    if (!isEligible(huRow)) {
        final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
        return ProcessPreconditionsResolution.reject(reason);
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ITranslatableString(de.metas.i18n.ITranslatableString) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 23 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class MQueryDocumentFilterHelper method createDocumentFilterFromMQuery.

public static DocumentFilter createDocumentFilterFromMQuery(final MQuery mquery, final ITranslatableString caption) {
    final List<DocumentFilterParam> parameters = new ArrayList<>();
    for (int restrictionIdx = 0, restrictionsCount = mquery.getRestrictionCount(); restrictionIdx < restrictionsCount; restrictionIdx++) {
        final DocumentFilterParam param = createDocumentFilterParamFromMQueryRestriction(mquery, restrictionIdx);
        parameters.add(param);
    }
    final String filterId;
    if (parameters.size() == 1 && !parameters.get(0).isSqlFilter()) {
        filterId = parameters.get(0).getFieldName();
    } else {
        // FIXME: find a better filterId
        filterId = "MQuery-" + UUID.randomUUID();
    }
    return DocumentFilter.builder().setFilterId(filterId).setCaption(caption).setParameters(parameters).build();
}
Also used : ArrayList(java.util.ArrayList) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 24 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class UserQueryDocumentFilterDescriptorsProvider method createFilterDescriptor0.

private static final DocumentFilterDescriptor createFilterDescriptor0(@NonNull final IUserQuery userQuery) {
    final DocumentFilterDescriptor.Builder filter = DocumentFilterDescriptor.builder().setFilterId("userquery-" + userQuery.getId()).setDisplayName(userQuery.getCaption()).setFrequentUsed(false);
    if (WindowConstants.isProtocolDebugging()) {
        filter.putDebugProperty("userQuery", userQuery.toString());
    }
    for (final IUserQueryRestriction queryRestriction : userQuery.getRestrictions()) {
        final Join join = queryRestriction.getJoin();
        final UserQueryField searchField = UserQueryField.cast(queryRestriction.getSearchField());
        final String fieldName = searchField.getColumnName();
        final Operator operator = MQueryDocumentFilterHelper.fromMQueryOperator(queryRestriction.getOperator());
        final Object value = queryRestriction.getValue();
        final Object valueTo = queryRestriction.getValueTo();
        final boolean isParameter;
        if (operator.isRangeOperator()) {
            isParameter = value == null || valueTo == null;
        } else {
            isParameter = value == null;
        }
        if (isParameter) {
            final ITranslatableString displayName = searchField.getDisplayName();
            final DocumentFieldWidgetType widgetType = searchField.getWidgetType();
            final LookupDescriptor lookupDescriptor = searchField.getLookupDescriptor();
            filter.addParameter(DocumentFilterParamDescriptor.builder().setJoinAnd(join == Join.AND).setDisplayName(displayName).setFieldName(fieldName).setWidgetType(widgetType).setOperator(operator).setDefaultValue(value).setDefaultValueTo(valueTo).setMandatory(// mandatory if there is no default value
            value == null).setLookupDescriptor(lookupDescriptor));
        } else {
            filter.addInternalParameter(DocumentFilterParam.builder().setJoinAnd(join == Join.AND).setFieldName(fieldName).setOperator(operator).setValue(value).setValueTo(valueTo).build());
        }
    }
    return filter.build();
}
Also used : Operator(de.metas.ui.web.document.filter.DocumentFilterParam.Operator) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ITranslatableString(de.metas.i18n.ITranslatableString) Join(org.compiere.apps.search.IUserQueryRestriction.Join) IUserQueryField(org.compiere.apps.search.IUserQueryField) ITranslatableString(de.metas.i18n.ITranslatableString) IUserQueryRestriction(org.compiere.apps.search.IUserQueryRestriction) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 25 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributesHelper method createLayoutElement.

private static final DocumentLayoutElementDescriptor createLayoutElement(final IAttributeValue attributeValue, final int warehouseId) {
    final I_M_Attribute attribute = attributeValue.getM_Attribute();
    final IModelTranslationMap attributeTrlMap = InterfaceWrapperHelper.getModelTranslationMap(attribute);
    final ITranslatableString caption = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Name, attribute.getName());
    final ITranslatableString description = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Description, attribute.getDescription());
    final String attributeName = HUEditorRowAttributesHelper.extractAttributeName(attributeValue);
    final DocumentFieldWidgetType widgetType = HUEditorRowAttributesHelper.extractWidgetType(attributeValue);
    return DocumentLayoutElementDescriptor.builder().setCaption(caption).setDescription(description).setWidgetType(widgetType).addField(DocumentLayoutElementFieldDescriptor.builder(attributeName).setPublicField(true).addDevices(createDevices(attribute.getValue(), warehouseId))).build();
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ITranslatableString(de.metas.i18n.ITranslatableString) I_M_Attribute(org.compiere.model.I_M_Attribute) ITranslatableString(de.metas.i18n.ITranslatableString)

Aggregations

ITranslatableString (de.metas.i18n.ITranslatableString)26 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)9 IMsgBL (de.metas.i18n.IMsgBL)8 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)5 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)4 NumberTranslatableString (de.metas.i18n.NumberTranslatableString)3 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)3 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DateTimeTranslatableString (de.metas.i18n.DateTimeTranslatableString)2 BoardFieldLoader (de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader)2 WindowConstants (de.metas.ui.web.window.WindowConstants)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)2 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)2