SEBSERV-569 fixed, regression due to code cleanup

This commit is contained in:
anhefti 2024-07-18 14:18:10 +02:00
parent 3166152c90
commit b0e8e11d26
2 changed files with 16 additions and 2 deletions

View file

@ -253,7 +253,9 @@ public final class QuizData implements GrantEntity {
}
public static Comparator<QuizData> getComparator(final String sort) {
final boolean descending = PageSortOrder.getSortOrder(sort) == PageSortOrder.DESCENDING;
System.out.println("**************** sort: " + sort + " descending " + descending);
final String sortParam = PageSortOrder.decode(sort);
if (QUIZ_ATTR_NAME.equals(sortParam)) {
return (qd1, qd2) -> StringUtils.compare(qd1.name, qd2.name) * ((descending) ? -1 : 1);

View file

@ -857,11 +857,23 @@ public final class Utils {
}
public static int compareDateTime(final DateTime dt1, final DateTime dt2, final boolean descending) {
return Objects.compare(dt1, dt1, DateTime::compareTo ) * ((descending) ? -1 : 1);
return ((dt1 == dt2)
? 0
: (dt1 == null || dt1 == null)
? 1
: (dt2 == null || dt2 == null)
? -1
: dt1.compareTo(dt2)) * ((descending) ? -1 : 1);
}
public static int compareIds(final Long id1, final Long id2, final boolean descending) {
return Objects.compare(id1, id2, Long::compareTo ) * ((descending) ? -1 : 1);
return ((Objects.equals(id1, id2))
? 0
: (id1 == null || id1 == null)
? 1
: (id2 == null || id2 == null)
? -1
: id1.compareTo(id2)) * ((descending) ? -1 : 1);
}
public static String toFileName(final String name) {