Skip to content

Commit

Permalink
Merge pull request #74 from axonivy-market/73-ivy-12-sortingordering-…
Browse files Browse the repository at this point in the history
…not-working

APS-231 GitHub 73: fixed handling of desc order in search filters
  • Loading branch information
peters-axon authored Jan 7, 2025
2 parents 55ff012 + f945023 commit a59cee5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -193,6 +194,24 @@ private List<MaritalStatus> uniqueMaritalStatus(Collection<Tuple> tuples) {
return tuples.stream().map(t -> (MaritalStatus)t.get(0)).distinct().sorted().toList();
}

@Test
public void testSortingAsc() {
var ascIvyUserFilter = SearchFilter.create()
.add(PersonSearchField.IVY_USER_NAME)
.addSort(PersonSearchField.IVY_USER_NAME, true);
var asc = PersonDAO.getInstance().findBySearchFilter(ascIvyUserFilter);
assertThat(asc.stream().map(t -> t.get(0, String.class))).isSorted();
}

@Test
public void testSortingDesc() {
var descIvyUserFilter = SearchFilter.create()
.add(PersonSearchField.IVY_USER_NAME)
.addSort(PersonSearchField.IVY_USER_NAME, false);
var desc = PersonDAO.getInstance().findBySearchFilter(descIvyUserFilter);
assertThat(desc.stream().map(t -> t.get(0, String.class))).isSortedAccordingTo(Comparator.reverseOrder());
}

@Test
public void testEnumList() {
var filter = SearchFilter.create()
Expand Down
5 changes: 5 additions & 0 deletions persistence-utils-product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Axon Ivy's JPA Persistence Lib utility helps you accelerate process automation i

## Release Notes

### 11.3.2-SNAPSHOT
*Changes*

- [APS-232](https://1ivy.atlassian.net/browse/APS-232) Fix GitHub issue 73 (SearchFilter descending sort)

### 10.0.8
*Changes*

Expand Down
5 changes: 5 additions & 0 deletions persistence-utils-product/README_DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Axon Ivy's JPA Persistence Lib unterstützt dich dabei, Prozessautomatisierungsi

## Release Notes

### 11.3.2-SNAPSHOT
*Änderungen*

- [APS-231](https://1ivy.atlassian.net/browse/APS-231) Fix GitHub issue 73 (SearchFilter descending sort)

### 10.0.8
*Änderungen*
- [APS-224](https://1ivy.atlassian.net/browse/APS-224) Behebung des Handlings von leeren Listen oder Null-Werten in Enum-Suchfiltern.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ protected AttributePredicates searchFilterToAttributePredicates(SearchFilter sea
}

// Add all needed orders.
for (FilterOrder filterOrder : searchFilter.getFilterOrders()) {
for (var filterOrder : searchFilter.getFilterOrders()) {
var orders = orderMap.get(filterOrder.getSearchEnum());

if(orders == null) {
Expand All @@ -1518,7 +1518,7 @@ protected AttributePredicates searchFilterToAttributePredicates(SearchFilter sea
// whether multi-select filters will even be used, will be seen.
// At the moment all filters produce a single selection, so this all
// does not really matter.
orders.stream().forEach(o -> o.reverse());
orders = orders.stream().map(Order::reverse).toList();
}
// Add all orders.
attributePredicates.addOrders(orders);
Expand Down

0 comments on commit a59cee5

Please sign in to comment.