Package su.onno.ui
Class ListGroups
java.lang.Object
su.onno.ui.ListGroups
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 ClassesModifier and TypeClassDescriptionstatic final recordOne aggregate to compute per group: an aggregatefnover a numericcolumn.static final recordThe result of a grouping query: the group headers, and whether the cap truncated them. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCap on the number of group headers returned, so a high-cardinality group can't stream forever. -
Method Summary
Modifier and TypeMethodDescriptionbucketExpand(String column, Object truncated, String granularity) The expand filter for a date bucket: age/lerange from the bucket start to one millisecond before the next bucket, so the rows the client loads are exactly the group's.static StringbucketLabel(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, anda0..aNfor the aggregates) into the client group headers:label(resolved ref/enum label or formatted date bucket), optionalcolor(enum pill),count, the aggregatevalues(aligned with the requested aggregates), and theexpandfilter 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 StringgroupExpression(String column, boolean date, String granularity) The SQL theGROUP BYruns on: the bare column for a discrete group, or aDATE_TRUNC('unit', col)bucket for a date column.static booleanisTemporalType(Class<?> t) Whether a Java type is a date/time — so grouping buckets it by period rather than exact value.static StringsafeGranularity(String granularity) Restrict a client-supplied granularity to a knownDATE_TRUNCunit; default month.
-
Field Details
-
MAX_GROUPS
public static final int MAX_GROUPSCap on the number of group headers returned, so a high-cardinality group can't stream forever.- See Also:
-
-
Method Details
-
isTemporalType
Whether a Java type is a date/time — so grouping buckets it by period rather than exact value. -
safeGranularity
Restrict a client-supplied granularity to a knownDATE_TRUNCunit; default month. -
groupExpression
The SQL theGROUP BYruns on: the bare column for a discrete group, or aDATE_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
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: age/lerange from the bucket start to one millisecond before the next bucket, so the rows the client loads are exactly the group's. -
discreteExpand
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, anda0..aNfor the aggregates) into the client group headers:label(resolved ref/enum label or formatted date bucket), optionalcolor(enum pill),count, the aggregatevalues(aligned with the requested aggregates), and theexpandfilter to load the group's rows.rowsmust already be ref-resolved by the caller.
-