ilgrosso commented on code in PR #972:
URL: https://github.com/apache/syncope/pull/972#discussion_r1937322970
##########
client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java:
##########
@@ -278,46 +280,58 @@ protected List<Comparator> load() {
private static final long serialVersionUID = 5275935387613157437L;
@Override
- protected List<String> load() {
+ protected List<Pair<String, String>> load() {
if (field.getModel().getObject() == null ||
field.getModel().getObject().getType() == null) {
return List.of();
}
switch (field.getModel().getObject().getType()) {
case ATTRIBUTE:
- List<String> names = new
ArrayList<>(dnames.getObject().keySet());
+ List<Pair<String, String>> names =
dnames.getObject().entrySet().stream()
+ .map(item -> Pair.of(item.getKey(),
StringUtils.isNotBlank(
+
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale()))
+ ?
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale())
+ :
item.getKey())).collect(Collectors.toList());
if (anames != null && anames.getObject() != null &&
!anames.getObject().isEmpty()) {
- names.addAll(anames.getObject().keySet());
+
names.addAll(anames.getObject().entrySet().stream().map(item ->
Pair.of(item.getKey(),
+ StringUtils.isNotBlank(
+
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale()))
+ ?
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale())
+ :
item.getKey())).collect(Collectors.toList()));
}
- return
names.stream().sorted().collect(Collectors.toList());
+ return names.stream().
+ sorted(java.util.Comparator.comparing(
+ entry ->
entry.getValue().toLowerCase())).collect(Collectors.toList());
case GROUP_MEMBERSHIP:
- return groupInfo.getLeft().getObject();
+ return
groupInfo.getLeft().getObject().stream().map(item -> Pair.of(item, item))
+ .collect(Collectors.toList());
case ROLE_MEMBERSHIP:
- return Optional.ofNullable(roleNames).
- map(r ->
r.getObject().stream().sorted().collect(Collectors.toList())).
- orElse(List.of());
+ return Optional.ofNullable(roleNames)
+ .map(r ->
r.getObject().stream().sorted().map(item -> Pair.of(item, item))
+
.collect(Collectors.toList())).orElse(List.of());
case PRIVILEGE:
- return Optional.ofNullable(privilegeNames).
- map(p ->
p.getObject().stream().sorted().collect(Collectors.toList())).
- orElse(List.of());
+ return Optional.ofNullable(privilegeNames)
+ .map(p ->
p.getObject().stream().sorted().map(item -> Pair.of(item, item))
+
.collect(Collectors.toList())).orElse(List.of());
case AUX_CLASS:
- return auxClassNames.getObject().stream().
- sorted().collect(Collectors.toList());
+ return
auxClassNames.getObject().stream().sorted().map(item -> Pair.of(item, item))
Review Comment:
`sorted()` shall be moved down the pipeline, e.g.
```java
auxClassNames.getObject().stream().
map(item -> Pair.of(item, item)).
sorted(Comparator.comparing(Pair::getKey)).collect(Collectors.toList());
```
##########
client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java:
##########
@@ -278,46 +280,58 @@ protected List<Comparator> load() {
private static final long serialVersionUID = 5275935387613157437L;
@Override
- protected List<String> load() {
+ protected List<Pair<String, String>> load() {
if (field.getModel().getObject() == null ||
field.getModel().getObject().getType() == null) {
return List.of();
}
switch (field.getModel().getObject().getType()) {
case ATTRIBUTE:
- List<String> names = new
ArrayList<>(dnames.getObject().keySet());
+ List<Pair<String, String>> names =
dnames.getObject().entrySet().stream()
+ .map(item -> Pair.of(item.getKey(),
StringUtils.isNotBlank(
+
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale()))
+ ?
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale())
+ :
item.getKey())).collect(Collectors.toList());
if (anames != null && anames.getObject() != null &&
!anames.getObject().isEmpty()) {
- names.addAll(anames.getObject().keySet());
+
names.addAll(anames.getObject().entrySet().stream().map(item ->
Pair.of(item.getKey(),
+ StringUtils.isNotBlank(
+
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale()))
+ ?
item.getValue().getLabel(SyncopeConsoleSession.get().getLocale())
+ :
item.getKey())).collect(Collectors.toList()));
}
- return
names.stream().sorted().collect(Collectors.toList());
+ return names.stream().
+ sorted(java.util.Comparator.comparing(
+ entry ->
entry.getValue().toLowerCase())).collect(Collectors.toList());
case GROUP_MEMBERSHIP:
- return groupInfo.getLeft().getObject();
+ return
groupInfo.getLeft().getObject().stream().map(item -> Pair.of(item, item))
+ .collect(Collectors.toList());
case ROLE_MEMBERSHIP:
- return Optional.ofNullable(roleNames).
- map(r ->
r.getObject().stream().sorted().collect(Collectors.toList())).
- orElse(List.of());
+ return Optional.ofNullable(roleNames)
+ .map(r ->
r.getObject().stream().sorted().map(item -> Pair.of(item, item))
+
.collect(Collectors.toList())).orElse(List.of());
case PRIVILEGE:
- return Optional.ofNullable(privilegeNames).
- map(p ->
p.getObject().stream().sorted().collect(Collectors.toList())).
- orElse(List.of());
+ return Optional.ofNullable(privilegeNames)
+ .map(p ->
p.getObject().stream().sorted().map(item -> Pair.of(item, item))
+
.collect(Collectors.toList())).orElse(List.of());
case AUX_CLASS:
- return auxClassNames.getObject().stream().
- sorted().collect(Collectors.toList());
+ return
auxClassNames.getObject().stream().sorted().map(item -> Pair.of(item, item))
Review Comment:
same for other occurrences in this class
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]