Class SupportedRelativeDateTimeConstantsValidator

java.lang.Object
io.jmix.aitools.dataload.validation.validator.SupportedRelativeDateTimeConstantsValidator
All Implemented Interfaces:
JpqlResultValidator, org.springframework.core.Ordered

@Component("aitls_SupportedRelativeDateTimeConstantsValidator") public class SupportedRelativeDateTimeConstantsValidator extends Object implements JpqlResultValidator, org.springframework.core.Ordered
Checks that only supported Jmix relative date-time constants (such as FIRST_DAY_OF_CURRENT_MONTH) are used, ignoring string literals and standard JPQL temporal keywords.
  • Field Details

    • RELATIVE_DATE_TIME_CONSTANT_PATTERN

      protected static final Pattern RELATIVE_DATE_TIME_CONSTANT_PATTERN
    • SUPPORTED_RELATIVE_DATE_TIME_CONSTANTS

      protected static final Set<String> SUPPORTED_RELATIVE_DATE_TIME_CONSTANTS
    • JPQL_TEMPORAL_KEYWORDS

      protected static final Set<String> JPQL_TEMPORAL_KEYWORDS
    • NON_OPERATION_KEYWORDS

      protected static final Set<String> NON_OPERATION_KEYWORDS
    • OPERATION_KEYWORDS

      protected static final Set<String> OPERATION_KEYWORDS
  • Constructor Details

    • SupportedRelativeDateTimeConstantsValidator

      public SupportedRelativeDateTimeConstantsValidator()
  • Method Details

    • validate

      public List<JpqlValidationIssue> validate(GeneratedJpqlResult result)
      Description copied from interface: JpqlResultValidator
      Validates the given query draft.
      Specified by:
      validate in interface JpqlResultValidator
      Parameters:
      result - generated query draft to validate
      Returns:
      issues found, or an empty list if the rule passed
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • isRelativeDateTimeConstantUsage

      protected boolean isRelativeDateTimeConstantUsage(String jpql, int start, int end)
    • previousNonWhitespaceIndex

      protected int previousNonWhitespaceIndex(String text, int fromIndex)
    • nextNonWhitespaceIndex

      protected int nextNonWhitespaceIndex(String text, int fromIndex)
    • previousWord

      protected String previousWord(String text, int tokenStart)