From ada819fe4c03dceba68c1ef2cc974dcf2fe415d7 Mon Sep 17 00:00:00 2001 From: stroomdev66 Date: Tue, 15 Oct 2024 22:26:35 +0100 Subject: [PATCH] #4504 Add column value filters --- .../impl/ScheduledQueryAnalyticExecutor.java | 1 + .../src/main/resources/ui/css/dashboard.css | 9 +++- .../client/table/ColumnsManager.java | 2 +- .../client/table/TablePresenter.java | 20 ++++----- .../shared/TableComponentSettings.java | 35 ++++++++------- .../stroom/legacy/impex_6_1/MappingUtil.java | 2 +- .../stroom/query/api/v2/TableSettings.java | 44 +++++++++++++++---- .../v2/ConditionalFormattingRowCreator.java | 8 +++- .../query/common/v2/FilteredRowCreator.java | 7 ++- .../query/common/v2/TableResultCreator.java | 2 + 10 files changed, 86 insertions(+), 44 deletions(-) diff --git a/stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/ScheduledQueryAnalyticExecutor.java b/stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/ScheduledQueryAnalyticExecutor.java index ceda31893ab..76844b74c55 100644 --- a/stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/ScheduledQueryAnalyticExecutor.java +++ b/stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/ScheduledQueryAnalyticExecutor.java @@ -457,6 +457,7 @@ private boolean process(final AnalyticRuleDoc analytic, Optional> optionalRowCreator = FilteredRowCreator.create( dataStore.getColumns(), columns, + false, fieldFormatter, keyFactory, tableSettings.getAggregateFilter(), diff --git a/stroom-app/src/main/resources/ui/css/dashboard.css b/stroom-app/src/main/resources/ui/css/dashboard.css index b715fdf5047..531bd9a7a59 100644 --- a/stroom-app/src/main/resources/ui/css/dashboard.css +++ b/stroom-app/src/main/resources/ui/css/dashboard.css @@ -469,11 +469,16 @@ display: none; } -.TablePresenter.showValueFilter input { +.TablePresenter .dataGridHeader { + min-height: 16px; + vertical-align: top; +} + +.TablePresenter.applyValueFilters input { display: inline-block; } -.TablePresenter.showValueFilter .dataGridHeader { +.TablePresenter.applyValueFilters .dataGridHeader { padding: var(--row__padding--vertical) var(--row__padding--horizontal) var(--row__padding--vertical) var(--row__padding--horizontal); } diff --git a/stroom-core-client/src/main/java/stroom/dashboard/client/table/ColumnsManager.java b/stroom-core-client/src/main/java/stroom/dashboard/client/table/ColumnsManager.java index b3414c47a71..f49c93e5a56 100644 --- a/stroom-core-client/src/main/java/stroom/dashboard/client/table/ColumnsManager.java +++ b/stroom-core-client/src/main/java/stroom/dashboard/client/table/ColumnsManager.java @@ -349,7 +349,7 @@ private void replaceColumn(final Column oldColumn, final Column newColumn) { // public void setValueFilterVisible(final boolean visible) { // final List columns = new ArrayList<>(); // for (final Column column : getColumns()) { -// columns.add(column.copy().showValueFilter(visible).build()); +// columns.add(column.copy().applyValueFilters(visible).build()); // } // updateColumns(columns); // tablePresenter.setDirty(true); diff --git a/stroom-core-client/src/main/java/stroom/dashboard/client/table/TablePresenter.java b/stroom-core-client/src/main/java/stroom/dashboard/client/table/TablePresenter.java index 5512f9e1a4f..3f17af4a1c9 100644 --- a/stroom-core-client/src/main/java/stroom/dashboard/client/table/TablePresenter.java +++ b/stroom-core-client/src/main/java/stroom/dashboard/client/table/TablePresenter.java @@ -302,14 +302,14 @@ protected void onBind() { })); registerHandler(valueFilterButton.addClickHandler(event -> { - final boolean show = Boolean.TRUE != getTableSettings().getShowValueFilter(); + final boolean applyValueFilters = !getTableSettings().isApplyValueFilters(); setSettings(getTableSettings() .copy() - .showValueFilter(show) + .applyValueFilters(applyValueFilters) .build()); setDirty(true); - updateColumns(); - setShowValueFilter(show); + refresh(); + setApplyValueFilters(applyValueFilters); })); registerHandler(annotateButton.addClickHandler(event -> { @@ -325,12 +325,12 @@ protected void onBind() { })); } - private void setShowValueFilter(final boolean show) { - valueFilterButton.setState(show); - if (show) { - dataGrid.addStyleName("showValueFilter"); + private void setApplyValueFilters(final boolean applyValueFilters) { + valueFilterButton.setState(applyValueFilters); + if (applyValueFilters) { + dataGrid.addStyleName("applyValueFilters"); } else { - dataGrid.removeStyleName("showValueFilter"); + dataGrid.removeStyleName("applyValueFilters"); } } @@ -930,7 +930,7 @@ public void read(final ComponentConfig componentConfig) { } // Change value filter state. - setShowValueFilter(getTableSettings().getShowValueFilter() == Boolean.TRUE); + setApplyValueFilters(getTableSettings().isApplyValueFilters()); } public TableComponentSettings getTableSettings() { diff --git a/stroom-core-shared/src/main/java/stroom/dashboard/shared/TableComponentSettings.java b/stroom-core-shared/src/main/java/stroom/dashboard/shared/TableComponentSettings.java index 441ac2f0294..8d88ea77246 100644 --- a/stroom-core-shared/src/main/java/stroom/dashboard/shared/TableComponentSettings.java +++ b/stroom-core-shared/src/main/java/stroom/dashboard/shared/TableComponentSettings.java @@ -46,7 +46,7 @@ "showDetail", "conditionalFormattingRules", "modelVersion", - "showValueFilter"}) + "applyValueFilters"}) @JsonInclude(Include.NON_NULL) public class TableComponentSettings implements ComponentSettings { @@ -101,7 +101,7 @@ public class TableComponentSettings implements ComponentSettings { @JsonProperty("modelVersion") private final String modelVersion; @JsonProperty - private final Boolean showValueFilter; + private final boolean applyValueFilters; @JsonCreator public TableComponentSettings( @@ -117,7 +117,7 @@ public TableComponentSettings( @JsonProperty("conditionalFormattingRules") final List conditionalFormattingRules, @JsonProperty("modelVersion") final String modelVersion, - @JsonProperty("showValueFilter") final Boolean showValueFilter) { + @JsonProperty("applyValueFilters") final boolean applyValueFilters) { this.queryId = queryId; this.dataSourceRef = dataSourceRef; @@ -130,7 +130,7 @@ public TableComponentSettings( this.showDetail = showDetail; this.conditionalFormattingRules = conditionalFormattingRules; this.modelVersion = modelVersion; - this.showValueFilter = showValueFilter; + this.applyValueFilters = applyValueFilters; } public String getQueryId() { @@ -204,8 +204,8 @@ public String getModelVersion() { return modelVersion; } - public Boolean getShowValueFilter() { - return showValueFilter; + public boolean isApplyValueFilters() { + return applyValueFilters; } @Override @@ -217,7 +217,8 @@ public boolean equals(final Object o) { return false; } final TableComponentSettings that = (TableComponentSettings) o; - return Objects.equals(queryId, that.queryId) && + return applyValueFilters == that.applyValueFilters && + Objects.equals(queryId, that.queryId) && Objects.equals(dataSourceRef, that.dataSourceRef) && Objects.equals(fields, that.fields) && Objects.equals(extractValues, that.extractValues) && @@ -227,8 +228,7 @@ public boolean equals(final Object o) { Objects.equals(pageSize, that.pageSize) && Objects.equals(showDetail, that.showDetail) && Objects.equals(conditionalFormattingRules, that.conditionalFormattingRules) && - Objects.equals(modelVersion, that.modelVersion) && - Objects.equals(showValueFilter, that.showValueFilter); + Objects.equals(modelVersion, that.modelVersion); } @Override @@ -245,7 +245,7 @@ public int hashCode() { showDetail, conditionalFormattingRules, modelVersion, - showValueFilter); + applyValueFilters); } @Override @@ -262,7 +262,7 @@ public String toString() { ", showDetail=" + showDetail + ", conditionalFormattingRules=" + conditionalFormattingRules + ", modelVersion='" + modelVersion + '\'' + - ", showValueFilter='" + showValueFilter + '\'' + + ", applyValueFilters='" + applyValueFilters + '\'' + '}'; } @@ -292,7 +292,7 @@ public static final class Builder extends ComponentSettings private Boolean showDetail; private List conditionalFormattingRules; private String modelVersion; - private Boolean showValueFilter; + private boolean applyValueFilters; private Builder() { } @@ -315,7 +315,7 @@ private Builder(final TableComponentSettings tableSettings) { ? null : new ArrayList<>(tableSettings.conditionalFormattingRules); this.modelVersion = tableSettings.modelVersion; - this.showValueFilter = tableSettings.showValueFilter; + this.applyValueFilters = tableSettings.applyValueFilters; } /** @@ -437,8 +437,8 @@ public Builder modelVersion(final String modelVersion) { return self(); } - public Builder showValueFilter(final Boolean showValueFilter) { - this.showValueFilter = showValueFilter; + public Builder applyValueFilters(final boolean applyValueFilters) { + this.applyValueFilters = applyValueFilters; return self(); } @@ -461,7 +461,7 @@ public TableComponentSettings build() { showDetail, conditionalFormattingRules, modelVersion, - showValueFilter); + applyValueFilters); } public TableSettings buildTableSettings() { @@ -476,7 +476,8 @@ public TableSettings buildTableSettings() { maxResults, showDetail, conditionalFormattingRules, - null); + null, + applyValueFilters); } } } diff --git a/stroom-legacy/stroom-legacy-impex_6_1/src/main/java/stroom/legacy/impex_6_1/MappingUtil.java b/stroom-legacy/stroom-legacy-impex_6_1/src/main/java/stroom/legacy/impex_6_1/MappingUtil.java index db4b936c2f3..41c2ac23cd4 100644 --- a/stroom-legacy/stroom-legacy-impex_6_1/src/main/java/stroom/legacy/impex_6_1/MappingUtil.java +++ b/stroom-legacy/stroom-legacy-impex_6_1/src/main/java/stroom/legacy/impex_6_1/MappingUtil.java @@ -207,7 +207,7 @@ public static stroom.dashboard.shared.TableComponentSettings map(stroom.legacy.m value.getShowDetail(), mapList(value.getConditionalFormattingRules(), MappingUtil::map), value.getModelVersion(), - null); + false); } public static ConditionalFormattingRule map(stroom.legacy.model_6_1.ConditionalFormattingRule value) { diff --git a/stroom-query/stroom-query-api/src/main/java/stroom/query/api/v2/TableSettings.java b/stroom-query/stroom-query-api/src/main/java/stroom/query/api/v2/TableSettings.java index 808ce939a0a..d1d4f5b1e6b 100644 --- a/stroom-query/stroom-query-api/src/main/java/stroom/query/api/v2/TableSettings.java +++ b/stroom-query/stroom-query-api/src/main/java/stroom/query/api/v2/TableSettings.java @@ -42,7 +42,8 @@ "showDetail", "conditionalFormattingRules", "modelVersion", - "visSettings"}) + "visSettings", + "applyValueFilters"}) @JsonInclude(Include.NON_NULL) @Schema(description = "An object to describe how the query results should be returned, including which fields " + "should be included and what sorting, grouping, filtering, limiting, etc. should be applied") @@ -106,6 +107,8 @@ public final class TableSettings { @JsonProperty("visSettings") private final QLVisSettings visSettings; + @JsonProperty + private final boolean applyValueFilters; public TableSettings( final String queryId, @@ -118,7 +121,8 @@ public TableSettings( final List maxResults, final Boolean showDetail, final List conditionalFormattingRules, - final QLVisSettings visSettings) { + final QLVisSettings visSettings, + final boolean applyValueFilters) { this.queryId = queryId; this.fields = columns; this.window = window; @@ -130,6 +134,7 @@ public TableSettings( this.showDetail = showDetail; this.conditionalFormattingRules = conditionalFormattingRules; this.visSettings = visSettings; + this.applyValueFilters = applyValueFilters; } @SuppressWarnings("checkstyle:LineLength") @@ -144,10 +149,10 @@ public TableSettings( @JsonProperty("extractionPipeline") final DocRef extractionPipeline, @JsonProperty("maxResults") final List maxResults, @JsonProperty("showDetail") final Boolean showDetail, - @JsonProperty("conditionalFormattingRules") - final List conditionalFormattingRules, + @JsonProperty("conditionalFormattingRules") final List conditionalFormattingRules, @JsonProperty("modelVersion") final String modelVersion, // deprecated modelVersion. - @JsonProperty("visSettings") final QLVisSettings visSettings) { + @JsonProperty("visSettings") final QLVisSettings visSettings, + @JsonProperty("applyValueFilters") final Boolean applyValueFilters) { this.queryId = queryId; this.fields = fields; this.window = window; @@ -160,6 +165,7 @@ public TableSettings( this.conditionalFormattingRules = conditionalFormattingRules; this.modelVersion = modelVersion; this.visSettings = visSettings; + this.applyValueFilters = applyValueFilters; } public String getQueryId() { @@ -226,6 +232,10 @@ public QLVisSettings getVisSettings() { return visSettings; } + public boolean isApplyValueFilters() { + return applyValueFilters; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -235,30 +245,37 @@ public boolean equals(final Object o) { return false; } final TableSettings that = (TableSettings) o; - return Objects.equals(queryId, that.queryId) && + return applyValueFilters == that.applyValueFilters && + Objects.equals(queryId, that.queryId) && Objects.equals(fields, that.fields) && Objects.equals(window, that.window) && + Objects.equals(valueFilter, that.valueFilter) && Objects.equals(aggregateFilter, that.aggregateFilter) && Objects.equals(extractValues, that.extractValues) && Objects.equals(extractionPipeline, that.extractionPipeline) && Objects.equals(maxResults, that.maxResults) && Objects.equals(showDetail, that.showDetail) && Objects.equals(conditionalFormattingRules, that.conditionalFormattingRules) && + Objects.equals(modelVersion, that.modelVersion) && Objects.equals(visSettings, that.visSettings); } @Override public int hashCode() { - return Objects.hash(queryId, + return Objects.hash( + queryId, fields, window, + valueFilter, aggregateFilter, extractValues, extractionPipeline, maxResults, showDetail, conditionalFormattingRules, - visSettings); + modelVersion, + visSettings, + applyValueFilters); } @Override @@ -274,6 +291,7 @@ public String toString() { ", showDetail=" + showDetail + ", conditionalFormattingRules=" + conditionalFormattingRules + ", visSettings=" + visSettings + + ", applyValueFilters='" + applyValueFilters + '\'' + '}'; } @@ -301,6 +319,7 @@ public static final class Builder { private Boolean showDetail; private List conditionalFormattingRules; private QLVisSettings visSettings; + private boolean applyValueFilters; private Builder() { } @@ -323,6 +342,7 @@ private Builder(final TableSettings tableSettings) { ? null : new ArrayList<>(tableSettings.getConditionalFormattingRules()); this.visSettings = tableSettings.visSettings; + this.applyValueFilters = tableSettings.applyValueFilters; } /** @@ -462,6 +482,11 @@ public Builder visSettings(final QLVisSettings visSettings) { return this; } + public Builder applyValueFilters(final boolean applyValueFilters) { + this.applyValueFilters = applyValueFilters; + return this; + } + public TableSettings build() { return new TableSettings( queryId, @@ -474,7 +499,8 @@ public TableSettings build() { maxResults, showDetail, conditionalFormattingRules, - visSettings); + visSettings, + applyValueFilters); } } } diff --git a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/ConditionalFormattingRowCreator.java b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/ConditionalFormattingRowCreator.java index 3029fe2e475..730058fa2d2 100644 --- a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/ConditionalFormattingRowCreator.java +++ b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/ConditionalFormattingRowCreator.java @@ -5,6 +5,7 @@ import stroom.query.api.v2.ConditionalFormattingRule; import stroom.query.api.v2.ExpressionOperator; import stroom.query.api.v2.Row; +import stroom.query.api.v2.TableSettings; import stroom.query.common.v2.format.ColumnFormatter; import stroom.query.language.functions.ref.ErrorConsumer; import stroom.util.PredicateUtil; @@ -43,6 +44,7 @@ private ConditionalFormattingRowCreator(final List originalColumns, public static Optional> create(final List originalColumns, final List newColumns, + final boolean applyValueFilters, final ColumnFormatter columnFormatter, final KeyFactory keyFactory, final ExpressionOperator rowFilterExpression, @@ -58,8 +60,10 @@ public static Optional> create(final List originalColumn if (!activeRules.isEmpty()) { final Optional> optionalRowExpressionMatcher = RowFilter.create(newColumns, dateTimeSettings, rowFilterExpression, new HashMap<>()); - final Optional> optionalRowValueFilter = - RowValueFilter.create(newColumns, dateTimeSettings, new HashMap<>()); + Optional> optionalRowValueFilter = Optional.empty(); + if (applyValueFilters) { + optionalRowValueFilter = RowValueFilter.create(newColumns, dateTimeSettings, new HashMap<>()); + } Predicate rowFilter = Predicates.alwaysTrue(); if (optionalRowExpressionMatcher.isPresent() && optionalRowValueFilter.isPresent()) { diff --git a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/FilteredRowCreator.java b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/FilteredRowCreator.java index 9283d40b578..6e5f8fd7097 100644 --- a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/FilteredRowCreator.java +++ b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/FilteredRowCreator.java @@ -37,6 +37,7 @@ public class FilteredRowCreator extends SimpleRowCreator { public static Optional> create(final List originalColumns, final List newColumns, + final boolean applyValueFilters, final ColumnFormatter columnFormatter, final KeyFactory keyFactory, final ExpressionOperator rowFilterExpression, @@ -44,8 +45,10 @@ public static Optional> create(final List originalColumn final ErrorConsumer errorConsumer) { final Optional> optionalRowExpressionMatcher = RowFilter.create(newColumns, dateTimeSettings, rowFilterExpression, new HashMap<>()); - final Optional> optionalRowValueFilter = - RowValueFilter.create(newColumns, dateTimeSettings, new HashMap<>()); + Optional> optionalRowValueFilter = Optional.empty(); + if (applyValueFilters) { + optionalRowValueFilter = RowValueFilter.create(newColumns, dateTimeSettings, new HashMap<>()); + } Predicate rowFilter = Predicates.alwaysTrue(); if (optionalRowExpressionMatcher.isPresent() && optionalRowValueFilter.isPresent()) { diff --git a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/TableResultCreator.java b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/TableResultCreator.java index d0e17203288..add5d9e95f8 100644 --- a/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/TableResultCreator.java +++ b/stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/TableResultCreator.java @@ -89,6 +89,7 @@ public Result create(final DataStore dataStore, final ResultRequest resultReques optionalRowCreator = ConditionalFormattingRowCreator.create( dataStore.getColumns(), columns, + tableSettings.isApplyValueFilters(), columnFormatter, keyFactory, tableSettings.getAggregateFilter(), @@ -99,6 +100,7 @@ public Result create(final DataStore dataStore, final ResultRequest resultReques optionalRowCreator = FilteredRowCreator.create( dataStore.getColumns(), columns, + tableSettings.isApplyValueFilters(), columnFormatter, keyFactory, tableSettings.getAggregateFilter(),