ISIS-1493: changed the way reversing order applies for null values

Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f36c3429
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f36c3429
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f36c3429

Branch: refs/heads/master
Commit: f36c34298d0669490c26fe194245ff98ad651c1e
Parents: 019b692
Author: Erik de Hair <e.deh...@pocos.nl>
Authored: Wed Sep 21 12:36:30 2016 +0200
Committer: Erik de Hair <e.deh...@pocos.nl>
Committed: Wed Sep 21 14:16:05 2016 +0200

----------------------------------------------------------------------
 .../CollectionContentsSortableDataProvider.java | 28 ++++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/f36c3429/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java
----------------------------------------------------------------------
diff --git 
a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java
 
b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java
index 0c2b36e..c032e58 100644
--- 
a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java
+++ 
b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collectioncontents/ajaxtable/CollectionContentsSortableDataProvider.java
@@ -19,19 +19,10 @@
 
 package 
org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable;
 
-import java.util.Iterator;
-import java.util.List;
-
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Ordering;
-
-import 
org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
-import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
-import 
org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
-import org.apache.wicket.model.IModel;
-
 import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
@@ -44,6 +35,13 @@ import 
org.apache.isis.core.metamodel.spec.ObjectSpecificationException;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
 import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import 
org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import 
org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.model.IModel;
+
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * Part of the {@link AjaxFallbackDefaultDataTable} API.
@@ -160,14 +158,16 @@ public class CollectionContentsSortableDataProvider 
extends SortableDataProvider
             public int compare(final ObjectAdapter p, final ObjectAdapter q) {
                 final ObjectAdapter pSort = sortProperty.get(p, 
InteractionInitiatedBy.FRAMEWORK);
                 final ObjectAdapter qSort = sortProperty.get(q, 
InteractionInitiatedBy.FRAMEWORK);
-                Ordering<ObjectAdapter> naturalOrdering = 
-                        ascending 
-                            ? ORDERING_BY_NATURAL.nullsFirst() 
-                            : ORDERING_BY_NATURAL.nullsLast();
+                Ordering<ObjectAdapter> naturalOrdering;
+                if(ascending){
+                    naturalOrdering = ORDERING_BY_NATURAL.nullsFirst();
+                } else {
+                    naturalOrdering = 
ORDERING_BY_NATURAL.reverse().nullsLast();
+                }
                 return naturalOrdering.compare(pSort, qSort);
             }
         };
-        return ascending?ordering:ordering.reverse();
+        return ordering;
     }
 
     private static Ordering<ObjectAdapter> ORDERING_BY_NATURAL = new 
Ordering<ObjectAdapter>(){

Reply via email to