Skip to content

Commit

Permalink
gh-4560 Stop the UI sorting the pipeline references
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Oct 28, 2024
1 parent f139105 commit d28d77a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import com.gwtplatform.mvp.client.MyPresenterWidget;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -155,18 +154,19 @@ private void addColumns() {

private void addPipelineColumn() {
// Pipeline.
final Column<PipelineReference, DocRefProvider<PipelineReference>> pipelineCol = DataGridUtil.docRefColumnBuilder(
(PipelineReference pipelineReference) -> {
if (pipelineReference.getPipeline() == null) {
return null;
} else {
return new DocRefProvider<>(pipelineReference, PipelineReference::getPipeline);
}
},
getEventBus(),
false,
this::getStateCssClass)
.build();
final Column<PipelineReference, DocRefProvider<PipelineReference>> pipelineCol =
DataGridUtil.docRefColumnBuilder(
(PipelineReference pipelineReference) -> {
if (pipelineReference.getPipeline() == null) {
return null;
} else {
return new DocRefProvider<>(pipelineReference, PipelineReference::getPipeline);
}
},
getEventBus(),
false,
this::getStateCssClass)
.build();
dataGrid.addResizableColumn(pipelineCol, "Pipeline", 200);
}

Expand Down Expand Up @@ -402,6 +402,18 @@ private void onRemove() {
}
}

private void addReference(final PipelineReference reference, State state) {
// It is important that the pipe references are displayed in the order in which
// they appear in the pipe doc (with inherited ones first)
// Order is important as the ref lookup will try each loader in this o
if (reference != null) {
referenceStateMap.put(reference, state);
// The most recent one trumps existing ones
references.remove(reference);
references.add(reference);
}
}

private void refresh() {
referenceStateMap.clear();
references.clear();
Expand All @@ -415,31 +427,28 @@ private void refresh() {
if (baseReferences != null) {
for (final List<PipelineReference> list : baseReferences.values()) {
for (final PipelineReference reference : list) {
referenceStateMap.put(reference, State.INHERITED);
addReference(reference, State.INHERITED);
}
}
}
for (final PipelineReference reference : pipelineModel.getPipelineData().getAddedPipelineReferences()) {
if (id.equals(reference.getElement())) {
referenceStateMap.put(reference, State.ADDED);
addReference(reference, State.ADDED);
}
}
for (final PipelineReference reference : pipelineModel.getPipelineData()
.getRemovedPipelineReferences()) {
if (id.equals(reference.getElement())) {
referenceStateMap.put(reference, State.REMOVED);
addReference(reference, State.REMOVED);
}
}

references.addAll(referenceStateMap.keySet());
Collections.sort(this.references);
}
}

// See if we need to load accurate doc refs (we do this to get correct entity names for display)
final Set<DocRef> docRefs = new HashSet<>();
references.forEach(ref -> addPipelineReference(docRefs, ref));
if (docRefs.size() > 0) {
if (!docRefs.isEmpty()) {
// Load entities.
restFactory
.create(EXPLORER_RESOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ public static <T_ROW> ColumnBuilder<T_ROW, Number, Number, Cell<Number>> percent
* @param <T_ROW> The row type
*/
@SuppressWarnings("checkstyle:LineLength")
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<DocRef>, DocRefProvider<DocRef>, Cell<DocRefProvider<DocRef>>>
docRefColumnBuilder(
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<DocRef>, DocRefProvider<DocRef>, Cell<DocRefProvider<DocRef>>> docRefColumnBuilder(
final Function<T_ROW, DocRef> cellExtractor,
final EventBus eventBus,
final boolean allowLinkByName) {
Expand All @@ -567,8 +566,7 @@ public static <T_ROW> ColumnBuilder<T_ROW, Number, Number, Cell<Number>> percent
* @param <T_ROW> The row type
*/
@SuppressWarnings("checkstyle:LineLength")
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<T_ROW>, DocRefProvider<T_ROW>, Cell<DocRefProvider<T_ROW>>>
docRefColumnBuilder(
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<T_ROW>, DocRefProvider<T_ROW>, Cell<DocRefProvider<T_ROW>>> docRefColumnBuilder(
final Function<T_ROW, DocRefProvider<T_ROW>> cellExtractor,
final EventBus eventBus,
final boolean allowLinkByName,
Expand All @@ -588,8 +586,7 @@ public static <T_ROW> ColumnBuilder<T_ROW, Number, Number, Cell<Number>> percent
* @param <T_ROW> The row type
*/
@SuppressWarnings("checkstyle:LineLength")
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<T_ROW>, DocRefProvider<T_ROW>, Cell<DocRefProvider<T_ROW>>>
docRefColumnBuilder(
public static <T_ROW> ColumnBuilder<T_ROW, DocRefProvider<T_ROW>, DocRefProvider<T_ROW>, Cell<DocRefProvider<T_ROW>>> docRefColumnBuilder(
final Function<T_ROW, DocRefProvider<T_ROW>> cellExtractor,
final EventBus eventBus,
final boolean allowLinkByName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import stroom.pipeline.shared.data.PipelineLink;
import stroom.pipeline.shared.data.PipelineProperty;
import stroom.pipeline.shared.data.PipelineReference;
import stroom.util.shared.GwtNullSafe;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -69,7 +70,7 @@ public PipelineDataMerger merge(final PipelineData... configStack) throws Pipeli
}

public PipelineDataMerger merge(final List<PipelineData> configStack) throws PipelineModelException {
if (configStack != null && configStack.size() > 0) {
if (GwtNullSafe.hasItems(configStack)) {
final Map<String, PipelineElement> allElementMap = new HashMap<>();
boolean sourceProvided = false;

Expand Down Expand Up @@ -147,7 +148,7 @@ private void mergeProperties(final List<PipelineData> configStack) {
propertyMap.compute(property.getElement(), (elementId, map) -> {
if (map != null) {
map.remove(property.getName());
if (map.size() == 0) {
if (map.isEmpty()) {
return null;
}
}
Expand Down Expand Up @@ -185,13 +186,13 @@ private void mergePipelineReferences(final List<PipelineData> configStack) {
map.compute(reference.getName(), (name, list) -> {
if (list != null) {
list.remove(reference);
if (list.size() == 0) {
if (list.isEmpty()) {
return null;
}
}
return list;
});
if (map.size() == 0) {
if (map.isEmpty()) {
return null;
}
}
Expand Down
24 changes: 24 additions & 0 deletions unreleased_changes/20241028_153230_559__4560.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Issue **#4560** : Don't sort the list of Pipeline References (reference loaders). Instead display them in the order they will get used in the lookup.


```sh
# ********************************************************************************
# Issue title: UI is sorting Ref Loader entries (by name?)
# Issue link: https://github.com/gchq/stroom/issues/4560
# ********************************************************************************

# ONLY the top line will be included as a change entry in the CHANGELOG.
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
# 'Fixed nasty bug'.
#
# Examples of acceptable entries are:
#
#
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
#
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
#
# * Fix bug with no associated GitHub issue.
```

0 comments on commit d28d77a

Please sign in to comment.