Package su.onno.ui

Class ListGroups

java.lang.Object
su.onno.ui.ListGroups

public final class ListGroups extends Object
Shared helpers for the list grouping query (see CatalogQueryService#groups / DocumentQueryService#groups). Grouping is backend GROUP BY: one header row per distinct value of the group column — or, for a date/time column, per day/month/year bucket (via DATE_TRUNC, a syntax both H2 and PostgreSQL share).

Each group carries an expand descriptor: the filter params the client appends to the normal list feed to load that group's rows. A discrete value expands with eq; a date bucket expands with a ge/le range covering the period. A null group is shown (count + subtotals) but not expandable — its expand list is empty.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    One aggregate to compute per group: an aggregate fn over a numeric column.
    static final record 
    The result of a grouping query: the group headers, and whether the cap truncated them.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Cap on the number of group headers returned, so a high-cardinality group can't stream forever.
  • Method Summary

    Modifier and Type
    Method
    Description
    bucketExpand(String column, Object truncated, String granularity)
    The expand filter for a date bucket: a ge/le range from the bucket start to one millisecond before the next bucket, so the rows the client loads are exactly the group's.
    static String
    bucketLabel(Object truncated, String granularity)
    The display label for a group value: a formatted period for a date bucket, else the raw value.
    buildGroups(List<Map<String,Object>> rows, String groupColumn, boolean date, String granularity, List<ListGroups.Agg> aggregates)
    Turn the raw grouped result rows (each aliased {groupColumn}, _count, and a0..aN for the aggregates) into the client group headers: label (resolved ref/enum label or formatted date bucket), optional color (enum pill), count, the aggregate values (aligned with the requested aggregates), and the expand filter to load the group's rows.
    discreteExpand(String column, Object value)
    The expand filter for a discrete value: eq, or empty for a null group (not expandable).
    static String
    groupExpression(String column, boolean date, String granularity)
    The SQL the GROUP BY runs on: the bare column for a discrete group, or a DATE_TRUNC('unit', col) bucket for a date column.
    static boolean
    Whether a Java type is a date/time — so grouping buckets it by period rather than exact value.
    static String
    safeGranularity(String granularity)
    Restrict a client-supplied granularity to a known DATE_TRUNC unit; default month.

    Methods inherited from class java.lang.Object

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

    • MAX_GROUPS

      public static final int MAX_GROUPS
      Cap on the number of group headers returned, so a high-cardinality group can't stream forever.
      See Also:
  • Method Details

    • isTemporalType

      public static boolean isTemporalType(Class<?> t)
      Whether a Java type is a date/time — so grouping buckets it by period rather than exact value.
    • safeGranularity

      public static String safeGranularity(String granularity)
      Restrict a client-supplied granularity to a known DATE_TRUNC unit; default month.
    • groupExpression

      public static String groupExpression(String column, boolean date, String granularity)
      The SQL the GROUP BY runs on: the bare column for a discrete group, or a DATE_TRUNC('unit', col) bucket for a date column. The unit is whitelisted and the column is a validated identifier, so neither carries arbitrary SQL.
    • bucketLabel

      public static String bucketLabel(Object truncated, String granularity)
      The display label for a group value: a formatted period for a date bucket, else the raw value.
    • bucketExpand

      public static List<Map<String,Object>> bucketExpand(String column, Object truncated, String granularity)
      The expand filter for a date bucket: a ge/le range from the bucket start to one millisecond before the next bucket, so the rows the client loads are exactly the group's.
    • discreteExpand

      public static List<Map<String,Object>> discreteExpand(String column, Object value)
      The expand filter for a discrete value: eq, or empty for a null group (not expandable).
    • buildGroups

      public static List<Map<String,Object>> buildGroups(List<Map<String,Object>> rows, String groupColumn, boolean date, String granularity, List<ListGroups.Agg> aggregates)
      Turn the raw grouped result rows (each aliased {groupColumn}, _count, and a0..aN for the aggregates) into the client group headers: label (resolved ref/enum label or formatted date bucket), optional color (enum pill), count, the aggregate values (aligned with the requested aggregates), and the expand filter to load the group's rows. rows must already be ref-resolved by the caller.