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 Details

    • messages

      @Autowired protected Messages messages
    • metadata

      @Autowired(required=false) protected Metadata metadata
    • queryTransformerFactory

      @Autowired(required=false) protected QueryTransformerFactory queryTransformerFactory
  • Constructor Details

    • EnumCaptionResultLocalizer

      public EnumCaptionResultLocalizer()
  • Method Details

    • localize

      public JpqlExecutionResult 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). All other fields and non-enum values are preserved.
      Parameters:
      result - execution result whose rows may contain enum values
      resultProperties - selected column names in select-clause order, used to map columns back to their enum type
      Returns:
      a localized copy of the result
    • resolveEnumColumns

      protected Map<String,Class<? extends Enum<?>>> resolveEnumColumns(String jpql, List<String> resultProperties)
    • resolveEnumType

      protected @Nullable Class<? extends Enum<?>> resolveEnumType(QueryParser.QueryPath path)
    • localizeRows

      protected List<Map<String,@Nullable Object>> localizeRows(List<Map<String,@Nullable Object>> rows, Map<String,Class<? extends Enum<?>>> enumColumns)
    • localizeValue

      protected @Nullable Object localizeValue(@Nullable Object value, @Nullable Class<? extends Enum<?>> enumType)
    • findConstantByStoredValue

      protected @Nullable Enum<?> findConstantByStoredValue(Class<? extends Enum<?>> enumType, Object storedValue)
      Finds the enum constant whose stored representation matches the given value: the EnumClass id for Jmix enums, otherwise the constant name or ordinal for plain enums.
      Parameters:
      enumType - enum type to search
      storedValue - raw value fetched for the column
      Returns:
      the matching constant, or null if none matches