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