use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class JSONLookupValue method stringLookupValueFromJsonMap.
public static final StringLookupValue stringLookupValueFromJsonMap(final Map<String, Object> map) {
final Object keyObj = map.get(PROPERTY_Key);
final String key = keyObj != null ? keyObj.toString() : null;
final Object captionObj = map.get(PROPERTY_Caption);
final String caption = captionObj != null ? captionObj.toString() : "";
final ITranslatableString displayName = ImmutableTranslatableString.anyLanguage(caption);
@SuppressWarnings("unchecked") final Map<String, Object> attributes = (Map<String, Object>) map.get(PROPERTY_Attributes);
if (attributes == null || attributes.isEmpty()) {
return StringLookupValue.of(key, displayName);
}
return StringLookupValue.builder().id(key).displayName(displayName).attributes(attributes).build();
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class JSONLookupValue method ofLookupValue.
public static final JSONLookupValue ofLookupValue(final LookupValue lookupValue) {
final String id = lookupValue.getIdAsString();
final ITranslatableString displayNameTrl = lookupValue.getDisplayNameTrl();
// FIXME add it as parameter!
final String adLanguage = Env.getAD_Language(Env.getCtx());
final String displayName = displayNameTrl.translate(adLanguage);
return new JSONLookupValue(id, displayName, lookupValue.getAttributes());
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_Create_M_Source_HUs method checkPreconditionsApplicable.
@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTopLevel());
if (anyHuMatches) {
return ProcessPreconditionsResolution.accept();
}
final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
return ProcessPreconditionsResolution.reject(reason);
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_IssueTUs method checkPreconditionsApplicable.
@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!getSelectedRowIds().isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTU() || huRow.isTopLevel());
if (anyHuMatches) {
return ProcessPreconditionsResolution.accept();
}
final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
return ProcessPreconditionsResolution.reject(reason);
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_IssueTopLevelHUs method checkPreconditionsApplicable.
@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTopLevel());
if (anyHuMatches) {
return ProcessPreconditionsResolution.accept();
}
final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
return ProcessPreconditionsResolution.reject(reason);
}
Aggregations