Class LlmQueryParameterNames

java.lang.Object
io.jmix.reports.llm.LlmQueryParameterNames

public final class LlmQueryParameterNames extends Object
Names under which an LLM data query may reference the values around it.

The rules live here because two sides must agree on them: the report designer tells query generation which names exist, and the loader binds values under the very same names at run time. A name invented on one side and not recognised on the other would fail the report instead of filtering a band.

  • Method Details

    • ofBandField

      public static String ofBandField(String bandName, String fieldName)
      Returns the name a field of a parent band row is referenced by. SQL and JPQL data sets use ${Band.field}, but a JPQL parameter name cannot contain a dot, so the name is flattened.
      Parameters:
      bandName - name of the band the field belongs to
      fieldName - name of the field within that band's row
      Returns:
      the parameter name, which still has to be checked with isValid(String)
    • ofCrossTabValue

      public static String ofCrossTabValue(String dataSetName, String fieldName)
      Returns the name the values of one cross-tab axis field are referenced by. The form matches what SqlCrosstabPreprocessor produces out of the <dataSet>@<field> reference SQL and JPQL data sets use, so the same query reads the same for either type.
      Parameters:
      dataSetName - name of the axis data set, i.e. <band>_dynamic_header or <band>_master_data
      fieldName - name of the field within that axis' rows
      Returns:
      the parameter name, which still has to be checked with isValid(String)
    • ofCrossTabAxisPrefix

      public static String ofCrossTabAxisPrefix(String dataSetName)
      Returns what every name of one cross-tab axis starts with. CrossTabExtractionController links a cell to its axis by the first result column starting with the axis data set's name, so both sides of the seam — the loader that builds the dictionary from real rows and the designer that builds one from stored queries — decide by this prefix which axis a name belongs to.
      Parameters:
      dataSetName - name of the axis data set
      Returns:
      the prefix the axis's names share
    • isCrossTabAxis

      public static boolean isCrossTabAxis(String name)
      Tells an axis of a cross-tab band from an ordinary run parameter by the suffix CrossTabExtractionController recognises its data sets by.
      Parameters:
      name - name of a run parameter, which for an axis is the axis data set's own name
      Returns:
      true if the parameter holds the rows of a cross-tab axis
    • isCrossTabAxisOf

      public static boolean isCrossTabAxisOf(String name, String bandName)
      Returns whether this is the name of an axis of that very band. Compared whole: a band named revenue would otherwise recognise revenue_extra_master_data — the axis of a band named revenue_extra — as its own.
      Parameters:
      name - candidate axis name
      bandName - name of the band the axis would belong to
    • referencedIn

      public static Set<String> referencedIn(String jpql)
      Returns the parameters a query text references, in the order it references them. This is what a query declares by being written, and what the parameters of a stored document are derived from every time a query is stored. It must read a query the same way the add-on's validator does (JpqlValidatorSupport.referencedParameters), so a document the designer wrote and a document the designer validated agree; a parity test enforces that. It lives here, rather than delegating to the add-on, so the derivation still works when the add-on is absent.
      Parameters:
      jpql - query text
      Returns:
      names of the referenced parameters
    • stripStringLiterals

      public static String stripStringLiterals(String jpql)
      Blanks out the string literals of a query, so that like 'urn:isbn%' references no parameter named isbn — one nothing could ever bind. Every literal is replaced by spaces of the same length to leave the rest of the text where it was.
      Parameters:
      jpql - query text
      Returns:
      the same text with the content of its literals blanked out
    • isValid

      public static boolean isValid(String name)
      Parameters:
      name - candidate parameter name
      Returns:
      true if a generated query can reference this name