Search in sources :

Example 1 with I_AD_Element

use of org.compiere.model.I_AD_Element 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

IModelTranslationMap (de.metas.i18n.IModelTranslationMap)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)1 I_AD_Element (org.compiere.model.I_AD_Element)1