Class EnumCaptionResultLocalizer
java.lang.Object
io.jmix.aitools.dataload.execution.EnumCaptionResultLocalizer
@Component("aitls_EnumCaptionResultLocalizer")
public class EnumCaptionResultLocalizer
extends Object
Replaces enum values in the fetched rows of a
JpqlExecutionResult with their localized
captions, so a conversational response shows human-readable labels instead of raw enum ids or
constant names.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Messagesprotected Metadataprotected QueryTransformerFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable Enum<?> findConstantByStoredValue(Class<? extends Enum<?>> enumType, Object storedValue) Finds the enum constant whose stored representation matches the given value: theEnumClassid for Jmix enums, otherwise the constant name or ordinal for plain enums.localize(JpqlExecutionResult result, List<String> resultProperties) Returns a copy of the given result with enum values in its rows replaced by their localized captions (resolved for the current user locale).localizeRows(List<Map<String, @Nullable Object>> rows, Map<String, Class<? extends Enum<?>>> enumColumns) protected @Nullable ObjectlocalizeValue(@Nullable Object value, @Nullable Class<? extends Enum<?>> enumType) resolveEnumColumns(String jpql, List<String> resultProperties)
-
Field Details
-
messages
-
metadata
-
queryTransformerFactory
-
-
Constructor Details
-
EnumCaptionResultLocalizer
public EnumCaptionResultLocalizer()
-
-
Method Details
-
localize
Returns a copy of the given result with enum values in its rows replaced by their localized captions (resolved for the current user locale). All other fields and non-enum values are preserved.- Parameters:
result- execution result whose rows may contain enum valuesresultProperties- selected column names in select-clause order, used to map columns back to their enum type- Returns:
- a localized copy of the result
-
resolveEnumColumns
-
resolveEnumType
-
localizeRows
-
localizeValue
-
findConstantByStoredValue
protected @Nullable Enum<?> findConstantByStoredValue(Class<? extends Enum<?>> enumType, Object storedValue) Finds the enum constant whose stored representation matches the given value: theEnumClassid for Jmix enums, otherwise the constant name or ordinal for plain enums.- Parameters:
enumType- enum type to searchstoredValue- raw value fetched for the column- Returns:
- the matching constant, or
nullif none matches
-