Skip to content

Commit 8e79895

Browse files
committed
Merge branch '7.8'
2 parents 76a339c + 2f9e7bb commit 8e79895

File tree

6 files changed

+177
-83
lines changed

6 files changed

+177
-83
lines changed

Diff for: stroom-core-client/src/main/java/stroom/receive/rules/client/presenter/DataRetentionImpactPresenter.java

+25-8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import stroom.svg.client.Preset;
3838
import stroom.svg.client.SvgPresets;
3939
import stroom.util.client.DataGridUtil;
40+
import stroom.util.shared.GwtNullSafe;
4041
import stroom.widget.button.client.ButtonView;
4142
import stroom.widget.button.client.ToggleButtonView;
4243
import stroom.widget.popup.client.event.ShowPopupEvent;
@@ -351,48 +352,64 @@ private void initColumns() {
351352
ExpanderCell.getColumnWidth(3)); // Need space for three expander levels
352353

353354
dataGrid.addResizableColumn(
354-
DataGridUtil.textColumnBuilder((DataRetentionImpactRow dataRetentionImpactRow) ->
355-
dataRetentionImpactRow.getRuleNumber().toString())
355+
DataGridUtil.textColumnBuilder((DataRetentionImpactRow row) ->
356+
GwtNullSafe.toString(row.getRuleNumber()))
356357
.rightAligned()
357358
.withSorting(DataRetentionImpactRow.FIELD_NAME_RULE_NO)
358359
.build(),
359-
DataGridUtil.createRightAlignedHeader(DataRetentionImpactRow.FIELD_NAME_RULE_NO),
360+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_RULE_NO)
361+
.rightAligned()
362+
.withToolTip("The lower the rule number, the higher priority when matching streams. " +
363+
"A stream's retention will be governed by the matching rule with the " +
364+
"highest priority.")
365+
.build(),
360366
ColumnSizeConstants.SMALL_COL);
361367

362368
dataGrid.addResizableColumn(
363369
DataGridUtil.textColumnBuilder(DataRetentionImpactRow::getRuleName)
364370
.withSorting(DataRetentionImpactRow.FIELD_NAME_RULE_NAME)
365371
.build(),
366-
DataRetentionImpactRow.FIELD_NAME_RULE_NAME,
372+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_RULE_NAME)
373+
.withToolTip("The name of the rule.")
374+
.build(),
367375
200);
368376

369377
dataGrid.addResizableColumn(
370378
DataGridUtil.textColumnBuilder(DataRetentionImpactRow::getRuleAgeStr)
371379
.withSorting(DataRetentionImpactRow.FIELD_NAME_RULE_AGE)
372380
.build(),
373-
DataRetentionImpactRow.FIELD_NAME_RULE_AGE,
381+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_RULE_AGE)
382+
.withToolTip("The retention age of this rule.")
383+
.build(),
374384
ColumnSizeConstants.MEDIUM_COL);
375385

376386
dataGrid.addResizableColumn(
377387
DataGridUtil.textColumnBuilder(DataRetentionImpactRow::getType)
378388
.withSorting(DataRetentionImpactRow.FIELD_NAME_TYPE)
379389
.build(),
380-
DataRetentionImpactRow.FIELD_NAME_TYPE,
390+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_TYPE)
391+
.withToolTip("The stream type.")
392+
.build(),
381393
ColumnSizeConstants.MEDIUM_COL);
382394

383395
dataGrid.addResizableColumn(
384396
DataGridUtil.textColumnBuilder(DataRetentionImpactRow::getFeed)
385397
.withSorting(DataRetentionImpactRow.FIELD_NAME_FEED)
386398
.build(),
387-
DataRetentionImpactRow.FIELD_NAME_FEED,
399+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_FEED)
400+
.withToolTip("The feed name.")
401+
.build(),
388402
ColumnSizeConstants.BIG_COL);
389403

390404
dataGrid.addResizableColumn(
391405
DataGridUtil.htmlColumnBuilder(this::getIndentedCountCellText)
392406
.rightAligned()
393407
.withSorting(DataRetentionImpactRow.FIELD_NAME_DELETE_COUNT)
394408
.build(),
395-
DataGridUtil.createRightAlignedHeader(DataRetentionImpactRow.FIELD_NAME_DELETE_COUNT),
409+
DataGridUtil.headingBuilder(DataRetentionImpactRow.FIELD_NAME_DELETE_COUNT)
410+
.rightAligned()
411+
.withToolTip("The number of streams that would be deleted by this rule.")
412+
.build(),
396413
150);
397414

398415
DataGridUtil.addEndColumn(dataGrid);

Diff for: stroom-core-client/src/main/java/stroom/receive/rules/client/presenter/DataRetentionImpactRow.java

+40-58
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import stroom.data.retention.shared.DataRetentionDeleteSummary;
44
import stroom.data.retention.shared.DataRetentionRule;
55
import stroom.data.retention.shared.FindDataRetentionImpactCriteria;
6+
import stroom.util.shared.CompareUtil;
7+
import stroom.util.shared.CriteriaFieldSort;
68
import stroom.util.shared.Expander;
9+
import stroom.util.shared.GwtNullSafe;
710
import stroom.util.shared.time.TimeUnit;
811

912
import java.util.ArrayList;
@@ -15,7 +18,6 @@
1518
import java.util.Objects;
1619
import java.util.Optional;
1720
import java.util.Set;
18-
import java.util.concurrent.atomic.AtomicLong;
1921
import java.util.function.Function;
2022
import java.util.stream.Collectors;
2123

@@ -28,15 +30,15 @@ public class DataRetentionImpactRow {
2830
public static final String FIELD_NAME_TYPE = "Type";
2931
public static final String FIELD_NAME_DELETE_COUNT = "Stream Delete Count";
3032

31-
public static final Comparator<DataRetentionImpactRow> FEED_COMPARATOR = Comparator.comparing(
33+
public static final Comparator<DataRetentionImpactRow> FEED_COMPARATOR = CompareUtil.getNullSafeComparator(
3234
DataRetentionImpactRow::getFeed);
33-
public static final Comparator<DataRetentionImpactRow> TYPE_COMPARATOR = Comparator.comparing(
35+
public static final Comparator<DataRetentionImpactRow> TYPE_COMPARATOR = CompareUtil.getNullSafeComparator(
3436
DataRetentionImpactRow::getType);
3537
public static final Comparator<DataRetentionImpactRow> COUNT_COMPARATOR = Comparator.comparingInt(
3638
DataRetentionImpactRow::getCount);
37-
public static final Comparator<DataRetentionImpactRow> RULE_NO_COMPARATOR = Comparator.comparingInt(
39+
public static final Comparator<DataRetentionImpactRow> RULE_NO_COMPARATOR = CompareUtil.getNullSafeComparator(
3840
DataRetentionImpactRow::getRuleNumber);
39-
public static final Comparator<DataRetentionImpactRow> RULE_NAME_COMPARATOR = Comparator.comparing(
41+
public static final Comparator<DataRetentionImpactRow> RULE_NAME_COMPARATOR = CompareUtil.getNullSafeComparator(
4042
DataRetentionImpactRow::getRuleName);
4143
public static final Comparator<DataRetentionImpactRow> RULE_AGE_COMPARATOR =
4244
Comparator.comparingLong(row ->
@@ -136,21 +138,12 @@ public void setExpander(final Expander expander) {
136138
this.expander = expander;
137139
}
138140

139-
private Comparator<DataRetentionImpactRow> chainComparators(
140-
final Comparator<DataRetentionImpactRow> first,
141-
final Comparator<DataRetentionImpactRow> second) {
142-
143-
if (first == null) {
144-
return second;
145-
} else {
146-
return first.thenComparing(second);
147-
}
148-
}
149-
150141
private static Comparator<DataRetentionImpactRow> buildComparator(final FindDataRetentionImpactCriteria criteria) {
151142

152-
if (criteria != null && criteria.getSortList() != null) {
153-
List<Comparator<DataRetentionImpactRow>> comparators = criteria.getSortList().stream()
143+
final List<CriteriaFieldSort> sortList = criteria.getSortList();
144+
if (GwtNullSafe.hasItems(sortList)) {
145+
//noinspection SimplifyStreamApiCallChains // Cos GWT
146+
List<Comparator<DataRetentionImpactRow>> comparators = sortList.stream()
154147
.filter(Objects::nonNull)
155148
.map(sort ->
156149
Optional.ofNullable(FIELD_TO_COMPARATOR_MAP.get(sort.getId()))
@@ -186,10 +179,9 @@ public static List<DataRetentionImpactRow> buildFlatTable(final List<DataRetenti
186179

187180
Map<Integer, DataRetentionRule> ruleNoToRuleMap = rules.stream()
188181
.collect(Collectors.toMap(
189-
rule -> Integer.valueOf(rule.getRuleNumber()), // Manual boxing to keep GWT happy
182+
DataRetentionRule::getRuleNumber, // Manual boxing to keep GWT happy
190183
Function.identity()));
191184

192-
final AtomicLong rowNumber = new AtomicLong(1);
193185
return summaries.stream()
194186
.map(summary -> {
195187
final DataRetentionRule rule = ruleNoToRuleMap.get(summary.getRuleNumber());
@@ -224,8 +216,6 @@ public static List<DataRetentionImpactRow> buildNestedTable(final List<DataReten
224216
DataRetentionDeleteSummary::getRuleNumber,
225217
Collectors.toSet()));
226218

227-
final AtomicLong rowNumber = new AtomicLong(1);
228-
229219
rules.stream()
230220
.map(rule ->
231221
buildRuleRow(
@@ -274,14 +264,15 @@ public static List<DataRetentionImpactRow> buildNestedTable(final List<DataReten
274264
summariesByRuleAndType.get(metaTypeRow.getType());
275265

276266
if (isExpanded(treeAction, metaTypeRow, 1)
277-
&& summariesForRuleAndType != null) {
267+
&& summariesForRuleAndType != null) {
278268

279269
Comparator<DataRetentionImpactRow> feedRowComparator = getComparator(
280270
criteria,
281271
FEED_COMPARATOR,
282272
FIELD_NAME_FEED,
283273
FIELD_NAME_DELETE_COUNT);
284274

275+
//noinspection SimplifyStreamApiCallChains // Cos GWT
285276
rows.addAll(summariesForRuleAndType.stream()
286277
.map(summaryForRuleTypeAndFeed ->
287278
buildFeedRow(
@@ -305,8 +296,9 @@ private static Comparator<DataRetentionImpactRow> getComparator(
305296
// If the sort list contains any of the sortableFieldNames then create a
306297
// comparator for it. Assumes only one sort in the sort list
307298

308-
if (criteria.getSortList() != null && !criteria.getSortList().isEmpty()) {
309-
return criteria.getSortList().stream()
299+
final List<CriteriaFieldSort> sortList = criteria.getSortList();
300+
if (GwtNullSafe.hasItems(sortList)) {
301+
return sortList.stream()
310302
.filter(sort ->
311303
Arrays.stream(sortableFieldNames)
312304
.anyMatch(fieldName ->
@@ -327,14 +319,9 @@ private static Comparator<DataRetentionImpactRow> getComparator(
327319
private static DataRetentionImpactRow buildRuleRow(final DataRetentionRule rule,
328320
final DataRetentionImpactTreeAction treeAction,
329321
final Set<DataRetentionDeleteSummary> summaries) {
330-
final int totalCount;
331-
if (summaries != null) {
332-
totalCount = summaries.stream()
333-
.mapToInt(DataRetentionDeleteSummary::getCount)
334-
.sum();
335-
} else {
336-
totalCount = 0;
337-
}
322+
final int totalCount = GwtNullSafe.stream(summaries)
323+
.mapToInt(DataRetentionDeleteSummary::getCount)
324+
.sum();
338325

339326
// TODO once we have built all the rows we will still have all the source data in memory.
340327
// We could change this class so it holds a ref to the source summary object and then
@@ -359,7 +346,7 @@ private static DataRetentionImpactRow buildRuleRow(final DataRetentionRule rule,
359346
totalCount);
360347

361348
final int depth = 0;
362-
final boolean isLeaf = summaries == null || summaries.isEmpty();
349+
final boolean isLeaf = GwtNullSafe.isEmptyCollection(summaries);
363350

364351
setExpander(treeAction, row, depth, isLeaf);
365352

@@ -372,14 +359,9 @@ private static DataRetentionImpactRow buildMetaTypeRow(final int ruleNumber,
372359
final Set<DataRetentionDeleteSummary> summaries,
373360
final DataRetentionImpactTreeAction treeAction) {
374361

375-
final int countByRuleAndFeed;
376-
if (summaries != null) {
377-
countByRuleAndFeed = summaries.stream()
378-
.mapToInt(DataRetentionDeleteSummary::getCount)
379-
.sum();
380-
} else {
381-
countByRuleAndFeed = 0;
382-
}
362+
final int countByRuleAndFeed = GwtNullSafe.stream(summaries)
363+
.mapToInt(DataRetentionDeleteSummary::getCount)
364+
.sum();
383365

384366
final DataRetentionImpactRow row = new DataRetentionImpactRow(
385367
buildRowKey(ruleNumber, metaType, null),
@@ -393,7 +375,7 @@ private static DataRetentionImpactRow buildMetaTypeRow(final int ruleNumber,
393375
countByRuleAndFeed);
394376

395377
final int depth = 1;
396-
final boolean isLeaf = summaries == null || summaries.isEmpty();
378+
final boolean isLeaf = GwtNullSafe.isEmptyCollection(summaries);
397379

398380
setExpander(treeAction, row, depth, isLeaf);
399381

@@ -464,12 +446,12 @@ public boolean equals(final Object o) {
464446
}
465447
final DataRetentionImpactRow that = (DataRetentionImpactRow) o;
466448
return count == that.count &&
467-
Objects.equals(rowKey, that.rowKey) &&
468-
Objects.equals(ruleNumber, that.ruleNumber) &&
469-
Objects.equals(ruleName, that.ruleName) &&
470-
Objects.equals(ruleAgeStr, that.ruleAgeStr) &&
471-
Objects.equals(feed, that.feed) &&
472-
Objects.equals(type, that.type);
449+
Objects.equals(rowKey, that.rowKey) &&
450+
Objects.equals(ruleNumber, that.ruleNumber) &&
451+
Objects.equals(ruleName, that.ruleName) &&
452+
Objects.equals(ruleAgeStr, that.ruleAgeStr) &&
453+
Objects.equals(feed, that.feed) &&
454+
Objects.equals(type, that.type);
473455
}
474456

475457
@Override
@@ -480,15 +462,15 @@ public int hashCode() {
480462
@Override
481463
public String toString() {
482464
return "DataRetentionImpactRow{" +
483-
"rowKey=" + rowKey +
484-
", ruleNumber=" + ruleNumber +
485-
", ruleName='" + ruleName + '\'' +
486-
", ruleAge='" + ruleAgeStr + '\'' +
487-
", feedName='" + feed + '\'' +
488-
", metaType='" + type + '\'' +
489-
", count=" + count +
490-
", expander=" + expander +
491-
'}';
465+
"rowKey=" + rowKey +
466+
", ruleNumber=" + ruleNumber +
467+
", ruleName='" + ruleName + '\'' +
468+
", ruleAge='" + ruleAgeStr + '\'' +
469+
", feedName='" + feed + '\'' +
470+
", metaType='" + type + '\'' +
471+
", count=" + count +
472+
", expander=" + expander +
473+
'}';
492474
}
493475

494476
/**

0 commit comments

Comments
 (0)