Gilad Chaplik has uploaded a new change for review.

Change subject: webadmin: sort cluster policy list
......................................................................

webadmin: sort cluster policy list

first order cluster policies by pre-defined then lexicographically.

Change-Id: I46c5de299ea7d4d0cd53dc6538d25b8f7337d0e6
Bug-Url: https://bugzilla.redhat.com/994719
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/ClusterPolicyListModel.java
1 file changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/18307/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/ClusterPolicyListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/ClusterPolicyListModel.java
index 9443461..66f3a5b 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/ClusterPolicyListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/ClusterPolicyListModel.java
@@ -1,9 +1,12 @@
 package org.ovirt.engine.ui.uicommonweb.models.configure.scheduling;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.ovirt.engine.core.common.action.VdcActionType;
+import 
org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -126,6 +129,7 @@
                 ClusterPolicyListModel clusterPolicyListModel = 
(ClusterPolicyListModel) model;
                 ArrayList<ClusterPolicy> list =
                         (ArrayList<ClusterPolicy>) ((VdcQueryReturnValue) 
returnValue).getReturnValue();
+                sortClusterPolicyList(list);
                 clusterPolicyListModel.setItems(list);
             }
         });
@@ -136,6 +140,24 @@
         setIsQueryFirstTime(false);
     }
 
+    /**
+     * pre-defined cluster policies should be ordered first, then order 
lexicographically
+     * @param list - cluster policy list
+     */
+    private void sortClusterPolicyList(ArrayList<ClusterPolicy> list) {
+        final LexoNumericComparator lexoNumeric = new LexoNumericComparator();
+        Collections.sort(list, new Comparator<ClusterPolicy>() {
+
+            @Override
+            public int compare(ClusterPolicy cp1, ClusterPolicy cp2) {
+                if (cp1.isLocked() != cp2.isLocked()) {
+                    return cp1.isLocked() ? -1 : 1;
+                }
+                return lexoNumeric.compare(cp1.getName(), cp2.getName());
+            }
+        });
+    }
+
     public ArrayList<PolicyUnit> getPolicyUnits() {
         return policyUnits;
     }


-- 
To view, visit http://gerrit.ovirt.org/18307
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46c5de299ea7d4d0cd53dc6538d25b8f7337d0e6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to