Class LlmCrossTabAxes

java.lang.Object
io.jmix.reports.libintegration.LlmCrossTabAxes

@NullMarked public final class LlmCrossTabAxes extends Object
What a cell of a cross-tab band has to know about the axes it sits between: which values the axes hold, which of them a query must return so that its rows find their place in the matrix, and when the matrix has no cells at all.

A cross-tab is assembled by CrossTabExtractionController, which links a cell to its column and to its row by the name of a returned column alone. The rules of that linking are what this class holds, so that the loader of the DataSetType.LLM data set type is left with reading a query, binding values and executing it.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addAxisValues(String axisName, List<?> rows, Map<String,Object> availableValues, List<String> requiredResultProperties, BiConsumer<String,Runnable> warnOnce)
    Offers the values of one cross-tab axis, one name per field of its rows, each bound as the whole list the axis holds for that field — which a query matches with IN.
    static boolean
    areReadBy(String dataSetName, @Nullable BandOrientation bandOrientation)
    Tells whether the axes a run put into its params are this data set's to read: only a cell of a cross-tab band sits between axes, and a data set named after an axis builds one instead of filling the matrix.
    static void
    checkAxesAreLinkable(String dataSetName, LlmDataQuery query, Map<String,Object> params, List<String> requiredResultProperties, @Nullable String bandName)
    Fails a query that cannot be placed into the matrix of a cross-tab band, because the controller drops every cell it cannot link and the band then renders empty with no error at all.
    static @Nullable String
    firstEmptyAxis(Map<String,Object> params, @Nullable String bandName)
    Returns the name of the first cross-tab axis of this band that produced no values, or null when every axis has some.
    static boolean
    isAxisOf(String name, @Nullable String bandName)
    Tells whether a params entry is an axis of this band rather than of another one.
    static boolean
    isAxisRows(@Nullable Object value)
    Tells the rows of a cross-tab axis from an ordinary parameter that merely happens to be named like one: an axis holds rows, so it is a list of maps, and an empty list is the axis that produced nothing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • firstEmptyAxis

      public static @Nullable String firstEmptyAxis(Map<String,Object> params, @Nullable String bandName)
      Returns the name of the first cross-tab axis of this band that produced no values, or null when every axis has some. An axis is put into the params by the controller whether it produced rows or not.
      Parameters:
      bandName - name of the band the data set belongs to, or null when it is unknown
    • isAxisOf

      public static boolean isAxisOf(String name, @Nullable String bandName)
      Tells whether a params entry is an axis of this band rather than of another one.

      The params of a run are one mutable map shared by every band of it: ExtractionContextImpl hands the same map to every band and CrossTabExtractionController adds its axes to it, so the axes of a cross-tab band stay in the params of every band extracted afterwards. An axis is named <band>_master_data or <band>_dynamic_header, which is what tells whose it is.

      A data set whose band is unknown claims every axis, as it did before the band name was published: without a name there is nothing to compare, and a cross-tab cell that stopped seeing its own axes would be worse than one seeing a foreign one.

      Parameters:
      name - params entry name
      bandName - name of the band the data set belongs to, or null when it is unknown
    • areReadBy

      public static boolean areReadBy(String dataSetName, @Nullable BandOrientation bandOrientation)
      Tells whether the axes a run put into its params are this data set's to read: only a cell of a cross-tab band sits between axes, and a data set named after an axis builds one instead of filling the matrix. Both halves matter because the params of a run are one map shared by every band — otherwise an ordinary band would read a parameter merely named like an axis, and an axis data set under a multi-row parent would find the axes of the previous row, its own among them.
      Parameters:
      dataSetName - name of the data set being loaded, which is what tells an axis from a cell
      bandOrientation - orientation of the band, or null when unknown, which claims the axes as before the orientation was published
    • isAxisRows

      public static boolean isAxisRows(@Nullable Object value)
      Tells the rows of a cross-tab axis from an ordinary parameter that merely happens to be named like one: an axis holds rows, so it is a list of maps, and an empty list is the axis that produced nothing. A list of anything else belongs to the report run and stays a parameter of its own.
      Parameters:
      value - value of a run parameter, which is null for a parameter left unfilled
    • addAxisValues

      public static void addAxisValues(String axisName, List<?> rows, Map<String,Object> availableValues, List<String> requiredResultProperties, BiConsumer<String,Runnable> warnOnce)
      Offers the values of one cross-tab axis, one name per field of its rows, each bound as the whole list the axis holds for that field — which a query matches with IN.

      Exactly one of those names is required back as a result column, the axis's first referenceable field: a cross-tab links a cell to its axis by the first returned column starting with the axis prefix, so requiring every field would let a caption column come first and the matrix link by caption text. A field with no values is required back all the same. Naming follows the band-field rules: a non-identifier name is skipped, and a name already taken is kept.

      Parameters:
      axisName - name of the axis data set, which its fields are named after
      rows - rows the axis produced
      availableValues - values a query may bind, added to under the axis field names
      requiredResultProperties - columns a query must return, added to for this axis
      warnOnce - says a thing once per report run, given a reason to tell repetitions by
    • checkAxesAreLinkable

      public static void checkAxesAreLinkable(String dataSetName, LlmDataQuery query, Map<String,Object> params, List<String> requiredResultProperties, @Nullable String bandName)
      Fails a query that cannot be placed into the matrix of a cross-tab band, because the controller drops every cell it cannot link and the band then renders empty with no error at all. Failing here turns that silence into a message.

      An axis holding rows is checked whether or not it holds any value: a field that is empty in every row offers nothing to bind, but the matrix still has that column, and a cell query that cannot be linked would otherwise render an empty matrix with nothing said.

      Parameters:
      dataSetName - data set the query belongs to, named in a failure
      query - query whose columns are read
      params - parameters of the run, which is where the axes arrive
      requiredResultProperties - columns the axes require the query to return
      bandName - name of the band the data set belongs to, or null when unknown