Daniel Erez has uploaded a new change for review.

Change subject: webadmin,userportal: fix Events tabs sorting
......................................................................

webadmin,userportal: fix Events tabs sorting

As a result of commit 2c5d00aac4f588260bb36f7a28d7be5e856a8474
the webadmin gets stuck (must be refreshed) when trying to
navigate back from any events tab/sub-tab.

The problem is that the method setItems is updated with
null when switching tabs - causing a NPE in the sort method.
The method setItems is actually redundant in EventListModel
and should be added instead to UserPortalVmEventListModel
and UserPortalTemplateEventListModel.

EventListModel -> SyncSearch calls setItems with an empty list.
It uses the refreshModel method for fetching events and
UpdateItems for reverse sorting them; i.e. the sorting in setItems
is effective only for classes that override the refreshModel
method. Therefore, moved the sorting to these classes and
added the nullity check.

[ToDo: the reverse sorting in EventListModel -> UpdateItems
should probably be re-factored in a way that allows sorting
for all inherited classes without overrides...]

Change-Id: Ibefebeea4dd804f6f930ed61e5899fe460996a70
RelatedTo-Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=907421
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java
3 files changed, 27 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/67/12367/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
index 0cd4706..56e4fd4 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
@@ -283,14 +283,4 @@
         return "EventListModel"; //$NON-NLS-1$
     }
 
-    /**
-     * This method is called only when the list is initialized.
-     * @param value
-     */
-    @Override
-    public void setItems(Iterable value) {
-        List<AuditLog> list = (List<AuditLog>) value;
-        Collections.sort(list, Collections.reverseOrder(new 
Linq.AuditLogComparer()));
-        super.setItems(list);
-    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java
index e23666a..edc5402 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java
@@ -1,8 +1,13 @@
 package org.ovirt.engine.ui.uicommonweb.models.templates;
 
+import java.util.Collections;
+import java.util.List;
+
+import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import 
org.ovirt.engine.core.common.queries.GetAllAuditLogsByVMTemplateNameParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.ui.uicommonweb.Linq;
 
 public class UserPortalTemplateEventListModel extends TemplateEventListModel {
 
@@ -21,4 +26,13 @@
     protected void preSearchCalled(VmTemplate template) {
         // no search string for the userportal
     }
+
+    @Override
+    public void setItems(Iterable value) {
+        List<AuditLog> list = (List<AuditLog>) value;
+        if (list != null) {
+            Collections.sort(list, Collections.reverseOrder(new 
Linq.AuditLogComparer()));
+        }
+        super.setItems(list);
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java
index cd1fc58..f0abf48 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java
@@ -1,8 +1,13 @@
 package org.ovirt.engine.ui.uicommonweb.models.vms;
 
+import java.util.Collections;
+import java.util.List;
+
+import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.queries.GetAllAuditLogsByVMNameParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.ui.uicommonweb.Linq;
 
 public class UserPortalVmEventListModel extends VmEventListModel {
 
@@ -22,4 +27,12 @@
         // do nothing - only the webadmin sets the search string
     }
 
+    @Override
+    public void setItems(Iterable value) {
+        List<AuditLog> list = (List<AuditLog>) value;
+        if (list != null) {
+            Collections.sort(list, Collections.reverseOrder(new 
Linq.AuditLogComparer()));
+        }
+        super.setItems(list);
+    }
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibefebeea4dd804f6f930ed61e5899fe460996a70
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <de...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to