Search in sources :

Example 26 with ITranslatableString

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

the class KPIRepository method createKPIField.

private static final KPIField createKPIField(final I_WEBUI_KPI_Field kpiFieldDef, final boolean isComputeOffset) {
    final I_AD_Element adElement = kpiFieldDef.getAD_Element();
    final String elementColumnName = adElement.getColumnName();
    Check.assumeNotNull(elementColumnName, "The element {} does not have a column name set", adElement);
    final String fieldName = elementColumnName;
    // 
    // Extract field caption and description
    final IModelTranslationMap kpiFieldDefTrl = InterfaceWrapperHelper.getModelTranslationMap(kpiFieldDef);
    final ITranslatableString caption;
    final ITranslatableString description;
    if (Check.isEmpty(kpiFieldDef.getName(), true)) {
        final IModelTranslationMap adElementTrl = InterfaceWrapperHelper.getModelTranslationMap(adElement);
        caption = adElementTrl.getColumnTrl(I_AD_Element.COLUMNNAME_Name, adElement.getName());
        description = adElementTrl.getColumnTrl(I_AD_Element.COLUMNNAME_Description, adElement.getDescription());
    } else {
        caption = kpiFieldDefTrl.getColumnTrl(I_WEBUI_KPI_Field.COLUMNNAME_Name, kpiFieldDef.getName());
        description = ImmutableTranslatableString.empty();
    }
    // 
    // Extract offset field's caption and description
    final ITranslatableString offsetCaption;
    if (!isComputeOffset) {
        offsetCaption = ImmutableTranslatableString.empty();
    } else if (Check.isEmpty(kpiFieldDef.getOffsetName(), true)) {
        offsetCaption = caption;
    } else {
        offsetCaption = kpiFieldDefTrl.getColumnTrl(I_WEBUI_KPI_Field.COLUMNNAME_OffsetName, kpiFieldDef.getOffsetName());
    }
    return KPIField.builder().setFieldName(fieldName).setGroupBy(kpiFieldDef.isGroupBy()).setCaption(caption).setOffsetCaption(offsetCaption).setDescription(description).setUnit(kpiFieldDef.getUOMSymbol()).setValueType(KPIFieldValueType.fromDisplayType(kpiFieldDef.getAD_Reference_ID())).setNumberPrecision(extractNumberPrecision(kpiFieldDef.getAD_Reference_ID())).setColor(kpiFieldDef.getColor()).setESPath(kpiFieldDef.getES_FieldPath()).build();
}
Also used : I_AD_Element(org.compiere.model.I_AD_Element) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString)

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