Jakub Niedermertl has uploaded a new change for review.

Change subject: core, webadmin: Dismissible events
......................................................................

core, webadmin: Dismissible events

* Events in bottom tab can be dismissed and restored similarly to
  alerts.
* EventListModel is not 'append-only' but rather 'full refresh' model.

Bug-Url: https://bugzilla.redhat.com/1120670
Change-Id: Ibae6686f24dcf6afc1fb0db48d803176dd318d88
Signed-off-by: Jakub Niedermertl <[email protected]>
---
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearDismissedAuditLogsBySeverityCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ClearDismissedAuditLogsBySeverityParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendEventsResourceTest.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/EventListModel.java
A 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/HasDismissCommand.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/EventModelProvider.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
M packaging/dbscripts/audit_log_sp.sql
15 files changed, 209 insertions(+), 136 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/41382/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearDismissedAuditLogsBySeverityCommand.java
similarity index 67%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearDismissedAuditLogsBySeverityCommand.java
index f3752dc..03d35ef 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearDismissedAuditLogsBySeverityCommand.java
@@ -1,9 +1,10 @@
 package org.ovirt.engine.core.bll;
 
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.AuditLogSeverity;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import 
org.ovirt.engine.core.common.action.ClearDismissedAuditLogsBySeverityParameters;
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
@@ -11,8 +12,10 @@
 import java.util.Collections;
 import java.util.List;
 
-public class ClearAllDismissedAuditLogsCommand<T extends 
VdcActionParametersBase> extends CommandBase<T> {
-    public ClearAllDismissedAuditLogsCommand(T parameters) {
+public class ClearDismissedAuditLogsBySeverityCommand<T extends 
ClearDismissedAuditLogsBySeverityParameters>
+        extends CommandBase<T> {
+
+    public ClearDismissedAuditLogsBySeverityCommand(T parameters) {
         super(parameters);
     }
 
@@ -23,7 +26,9 @@
 
     @Override
     protected void executeCommand() {
-        DbFacade.getInstance().getAuditLogDao().clearAllDismissed();
+        for (AuditLogSeverity severity : getParameters().getSeverities()) {
+            
DbFacade.getInstance().getAuditLogDao().clearDismissedBySeverity(severity);
+        }
         setSucceeded(true);
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java
index 91c7ac8..d77090f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java
@@ -30,10 +30,6 @@
             return 
failCanDoAction(VdcBllMessages.AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST);
         }
 
-        if (!AuditLogSeverity.ALERT.equals(event.getSeverity()) && 
OVIRT.equalsIgnoreCase(event.getOrigin())) {
-            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN);
-        }
-
         return true;
     }
 
@@ -59,6 +55,6 @@
     @Override
     public AuditLogType getAuditLogTypeValue() {
         addCustomValue("AuditLogId", 
String.valueOf(getParameters().getAuditLogId()));
-        return getSucceeded() ? AuditLogType.USER_REMOVE_AUDIT_LOG : 
AuditLogType.USER_REMOVE_AUDIT_LOG_FAILED;
+        return getSucceeded() ? AuditLogType.UNASSIGNED : 
AuditLogType.USER_REMOVE_AUDIT_LOG_FAILED;
     }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ClearDismissedAuditLogsBySeverityParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ClearDismissedAuditLogsBySeverityParameters.java
new file mode 100644
index 0000000..c8c4f6a
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ClearDismissedAuditLogsBySeverityParameters.java
@@ -0,0 +1,20 @@
+package org.ovirt.engine.core.common.action;
+
+import org.ovirt.engine.core.common.AuditLogSeverity;
+
+import java.util.List;
+
+public class ClearDismissedAuditLogsBySeverityParameters extends 
VdcActionParametersBase {
+
+    private List<AuditLogSeverity> severities;
+
+    public ClearDismissedAuditLogsBySeverityParameters() {}
+
+    public ClearDismissedAuditLogsBySeverityParameters(List<AuditLogSeverity> 
severities) {
+        this.severities = severities;
+    }
+
+    public List<AuditLogSeverity> getSeverities() {
+        return severities;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
index 845d419..e384e4f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
@@ -434,7 +434,7 @@
 
     // Audit Log
     RemoveAuditLogById(2100, false, QuotaDependency.NONE),
-    ClearAllDismissedAuditLogs(2101, false, QuotaDependency.NONE),
+    ClearDismissedAuditLogsBySeverity(2101, false, QuotaDependency.NONE),
 
     SetDataOnSession(3000, false, QuotaDependency.NONE),
 
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
index e5410ea..1f59f1b 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
@@ -3,6 +3,7 @@
 import java.util.Date;
 import java.util.List;
 
+import org.ovirt.engine.core.common.AuditLogSeverity;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.compat.Guid;
 
@@ -171,10 +172,10 @@
     public int getTimeToWaitForNextPmOp(String vdsName, String event);
 
     /**
-     * Clears all previously dismissed audit log entries. All audit logs
+     * Clears all previously dismissed audit log entries that has given 
severity. Audit logs
      * delete flag will be set back to false.
      */
-    void clearAllDismissed();
+    void clearDismissedBySeverity(AuditLogSeverity severity);
 
     /**
      * Clears all backup related alerts (no backup alert or old backup alert)
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
index 8272cf4..083d6da 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
@@ -232,8 +232,9 @@
     }
 
     @Override
-    public void clearAllDismissed() {
-        getCallsHandler().executeModification("ClearAllDismissedAuditLogs", 
getCustomMapSqlParameterSource());
+    public void clearDismissedBySeverity(AuditLogSeverity severity) {
+        getCallsHandler().executeModification("ClearDismissedAuditLogsBy", 
getCustomMapSqlParameterSource()
+                .addValue("severity", severity.getValue()));
     }
 
     @Override
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
index 708f510..ee8d3bd 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
@@ -1,5 +1,6 @@
 package org.ovirt.engine.api.restapi.resource;
 
+import java.util.Arrays;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
@@ -9,9 +10,10 @@
 import org.ovirt.engine.api.model.Events;
 import org.ovirt.engine.api.resource.EventResource;
 import org.ovirt.engine.api.resource.EventsResource;
+import org.ovirt.engine.core.common.AuditLogSeverity;
 import org.ovirt.engine.core.common.action.AddExternalEventParameters;
+import 
org.ovirt.engine.core.common.action.ClearDismissedAuditLogsBySeverityParameters;
 import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters;
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.interfaces.SearchType;
@@ -41,7 +43,13 @@
 
     @Override
     public Response undelete(Action action) {
-        return performAction(VdcActionType.ClearAllDismissedAuditLogs, new 
VdcActionParametersBase(), action, false);
+        return performAction(VdcActionType.ClearDismissedAuditLogsBySeverity,
+                new ClearDismissedAuditLogsBySeverityParameters(Arrays.asList(
+                        AuditLogSeverity.ERROR,
+                        AuditLogSeverity.WARNING,
+                        AuditLogSeverity.NORMAL,
+                        AuditLogSeverity.ALERT
+                )), action, false);
     }
 
     @Override
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendEventsResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendEventsResourceTest.java
index 5c2202d..db9cf41 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendEventsResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendEventsResourceTest.java
@@ -2,6 +2,7 @@
 
 import static org.easymock.EasyMock.expect;
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -15,8 +16,8 @@
 import org.ovirt.engine.core.common.AuditLogSeverity;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.AddExternalEventParameters;
+import 
org.ovirt.engine.core.common.action.ClearDismissedAuditLogsBySeverityParameters;
 import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters;
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.interfaces.SearchType;
@@ -110,10 +111,15 @@
     @Test
     public void testUndelete() throws Exception {
 
-        
setUriInfo(setUpActionExpectations(VdcActionType.ClearAllDismissedAuditLogs,
-                VdcActionParametersBase.class,
-                new String[] {},
-                new Object[] {},
+        
setUriInfo(setUpActionExpectations(VdcActionType.ClearDismissedAuditLogsBySeverity,
+                ClearDismissedAuditLogsBySeverityParameters.class,
+                new String[] {"Severities"},
+                new Object[] { Arrays.asList(
+                        AuditLogSeverity.ERROR,
+                        AuditLogSeverity.WARNING,
+                        AuditLogSeverity.NORMAL,
+                        AuditLogSeverity.ALERT
+                ) },
                 true,
                 true));
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java
index 59bdf97..2d31ae6 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java
@@ -1,9 +1,11 @@
 package org.ovirt.engine.ui.uicommonweb.models.events;
 
 import java.util.ArrayList;
+import java.util.Collections;
 
+import org.ovirt.engine.core.common.AuditLogSeverity;
+import 
org.ovirt.engine.core.common.action.ClearDismissedAuditLogsBySeverityParameters;
 import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters;
-import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.interfaces.SearchType;
@@ -18,7 +20,7 @@
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 
 @SuppressWarnings("unused")
-public class AlertListModel extends SearchableListModel
+public class AlertListModel extends SearchableListModel<Void, AuditLog> 
implements HasDismissCommand
 {
     private UICommand dismissCommand;
 
@@ -92,8 +94,9 @@
     }
 
     public void clearAllDismissedAlerts() {
-        VdcActionParametersBase params = new VdcActionParametersBase();
-        
Frontend.getInstance().runAction(VdcActionType.ClearAllDismissedAuditLogs, 
params);
+        ClearDismissedAuditLogsBySeverityParameters params = new 
ClearDismissedAuditLogsBySeverityParameters(
+                Collections.singletonList(AuditLogSeverity.ALERT));
+        
Frontend.getInstance().runAction(VdcActionType.ClearDismissedAuditLogsBySeverity,
 params);
     }
 
     @Override
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 32b6e1b..1d65d42 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
@@ -1,10 +1,9 @@
 package org.ovirt.engine.ui.uicommonweb.models.events;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.ovirt.engine.ui.frontend.communication.RefreshActiveModelEvent;
+import org.ovirt.engine.core.common.AuditLogSeverity;
+import 
org.ovirt.engine.core.common.action.ClearDismissedAuditLogsBySeverityParameters;
+import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters;
+import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.businessentities.IVdcQueryable;
 import org.ovirt.engine.core.common.interfaces.SearchType;
@@ -22,11 +21,12 @@
 import org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel;
 import org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
-import org.ovirt.engine.ui.uicompat.EventArgs;
-import org.ovirt.engine.ui.uicompat.ObservableCollection;
 import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs;
 
-public class EventListModel<E> extends ListWithSimpleDetailsModel<E, AuditLog> 
{
+import java.util.Arrays;
+import java.util.List;
+
+public class EventListModel<E> extends ListWithSimpleDetailsModel<E, AuditLog> 
implements HasDismissCommand {
     private UICommand privateRefreshCommand;
 
     public UICommand getRefreshCommand()
@@ -43,6 +43,19 @@
 
     public UICommand getDetailsCommand() {
         return detailsCommand;
+    }
+
+    private UICommand dismissCommand;
+
+    @Override
+    public UICommand getDismissCommand() {
+        return dismissCommand;
+    }
+
+    private UICommand clearAllCommand;
+
+    public UICommand getClearAllCommand() {
+        return clearAllCommand;
     }
 
     private void setDetailsCommand(UICommand value) {
@@ -81,12 +94,6 @@
         }
     }
 
-    private boolean requestingData;
-
-    public boolean isRequestingData() {
-        return requestingData;
-    }
-
     public EventListModel()
     {
         setTitle(ConstantsManager.getInstance().getConstants().eventsTitle());
@@ -96,6 +103,8 @@
 
         setRefreshCommand(new UICommand("Refresh", this)); //$NON-NLS-1$
         setDetailsCommand(new UICommand("Details", this)); //$NON-NLS-1$
+        dismissCommand = new UICommand("Dismiss", this); //$NON-NLS-1$
+        clearAllCommand = new UICommand("ClearAll", this); //$NON-NLS-1$
 
         setDefaultSearchString("Events:"); //$NON-NLS-1$
         setSearchString(getDefaultSearchString());
@@ -117,32 +126,12 @@
     }
 
     @Override
-    protected void syncSearch()
-    {
-        super.syncSearch();
-
-        requestingData = true;
-        setItems(new ObservableCollection<AuditLog>());
-        setLastEvent(null);
-    }
-
-    @Override
-    public void search() {
-        super.search();
-
-        // Force refresh of the event list when the event tab is shown
-        // without waiting to the timer. This is invoked only the first
-        // time the Events tab is shown - than the timer takes care of this.
-        forceRefreshWithoutTimers();
+    protected void syncSearch() {
+        refreshModel();
     }
 
     protected void forceRefreshWithoutTimers() {
         getRefreshCommand().execute();
-    }
-
-    @Override
-    protected boolean handleRefreshActiveModel(RefreshActiveModelEvent event) {
-        return false;
     }
 
     @Override
@@ -154,26 +143,16 @@
     {
         AsyncQuery query = new AsyncQuery(this, new INewAsyncCallback() {
             @Override
-            public void onSuccess(Object model, Object returnValue) {
-                EventListModel eventListModel = (EventListModel) model;
-                ArrayList<AuditLog> list = ((VdcQueryReturnValue) 
returnValue).getReturnValue();
-                requestingData = false;
-                for (AuditLog auditLog : list) {
-                    // in case the corr_id is created in client,
-                    // remove unnecessary data (leave only the corr_id).
-                    if (auditLog.getCorrelationId() != null
-                        && 
auditLog.getCorrelationId().startsWith(TaskListModel._WEBADMIN_)) {
-                        
auditLog.setCorrelationId(auditLog.getCorrelationId().split("_")[2]); 
//$NON-NLS-1$
-                    }
-                }
-                eventListModel.updateItems(list);
+            public void onSuccess(Object outerObject, Object returnValue) {
+                List<AuditLog> list = ((VdcQueryReturnValue) 
returnValue).getReturnValue();
+                EventListModel.this.setItems(list);
+                EventListModel.this.setLastEvent(Linq.firstOrDefault(list));
             }
         });
 
         SearchParameters params = new 
SearchParameters(applySortOptions(getSearchString()), SearchType.AuditLog,
                 isCaseSensitiveSearch());
         params.setMaxCount(getSearchPageSize());
-        params.setSearchFrom(getLastEvent() != null ? 
getLastEvent().getAuditLogId() : 0);
         params.setRefresh(false);
 
         Frontend.getInstance().runQuery(VdcQueryType.Search, params, query);
@@ -209,55 +188,37 @@
         super.executeCommand(command);
 
         if (command == getRefreshCommand()) {
-            refreshModel();
-            updatePagingAvailability();
+            syncSearch();
         } else if (command == getDetailsCommand()) {
             details();
         } else if ("Cancel".equals(command.getName())) { //$NON-NLS-1$
             cancel();
+        } else if (command == getDismissCommand()) {
+            dismissEvent();
+        } else if (command == getClearAllCommand()) {
+            clearAllDismissedEvents();
         }
+    }
+
+    public void dismissEvent() {
+        AuditLog auditLog = getSelectedItem();
+        RemoveAuditLogByIdParameters params = new 
RemoveAuditLogByIdParameters(auditLog.getAuditLogId());
+        Frontend.getInstance().runAction(VdcActionType.RemoveAuditLogById, 
params);
+    }
+
+    public void clearAllDismissedEvents() {
+        ClearDismissedAuditLogsBySeverityParameters params = new 
ClearDismissedAuditLogsBySeverityParameters(
+                Arrays.asList(
+                        AuditLogSeverity.ERROR,
+                        AuditLogSeverity.WARNING,
+                        AuditLogSeverity.NORMAL
+                ));
+        
Frontend.getInstance().runAction(VdcActionType.ClearDismissedAuditLogsBySeverity,
 params);
     }
 
     @Override
     public UICommand getDoubleClickCommand() {
         return getDetailsCommand();
-    }
-
-    private void updateItems(ArrayList<AuditLog> source)
-    {
-        if (getItems() == null)
-        {
-            return;
-        }
-
-        List<AuditLog> list = (List<AuditLog>) getItems();
-
-        Collections.sort(source, new Linq.AuditLogComparer());
-        if (!source.isEmpty() && !list.contains(source.get(source.size() - 
1))) {
-            //We received some new events, tell the active models to update.
-            RefreshActiveModelEvent.fire(this, false);
-        }
-
-        for (AuditLog item : source)
-        {
-            if (list.size() == getSearchPageSize())
-            {
-                list.remove(list.size() - 1);
-            }
-            // This check is for an issue in FF where somehow the event lists 
gets items twice. This
-            // simply checks if the event is already there and only adds it if 
it is not there.
-            if (!list.contains(item)) {
-                list.add(0, item);
-            }
-        }
-        getItemsChangedEvent().raise(this, EventArgs.EMPTY);
-        setLastEvent(Linq.firstOrDefault(list));
-
-        // If there are no data for this entity, the LastEvent has to be fired 
in order
-        // to stop the progress animation (SearchableTabModelProvider).
-        if (Linq.firstOrDefault(list) == null) {
-            onPropertyChanged(new PropertyChangedEventArgs("LastEvent")); 
//$NON-NLS-1$
-        }
     }
 
     private boolean entitiesChanged = true;
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/HasDismissCommand.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/HasDismissCommand.java
new file mode 100644
index 0000000..61d90c5
--- /dev/null
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/HasDismissCommand.java
@@ -0,0 +1,7 @@
+package org.ovirt.engine.ui.uicommonweb.models.events;
+
+import org.ovirt.engine.ui.uicommonweb.UICommand;
+
+public interface HasDismissCommand {
+    UICommand getDismissCommand();
+}
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index fb00788..6a126e3 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -2617,9 +2617,15 @@
     @DefaultStringValue("Clear All")
     String clearAllDismissedAlerts();
 
+    @DefaultStringValue("Clear All")
+    String clearAllDismissedEvents();
+
     @DefaultStringValue("Dismiss Alert")
     String dismissAlert();
 
+    @DefaultStringValue("Dismiss Event")
+    String dismissEvent();
+
     // Network popup
 
     // Header
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/EventModelProvider.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/EventModelProvider.java
index 3a979f5..1bbcb2d 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/EventModelProvider.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/uicommon/model/EventModelProvider.java
@@ -30,13 +30,7 @@
             public void eventRaised(Event<? extends PropertyChangedEventArgs> 
ev, Object sender, PropertyChangedEventArgs args) {
                 // For EventListModel classes: update data whenever the last 
event changes
                 if ("LastEvent".equals(args.propertyName)) { //$NON-NLS-1$
-                    if (model.getLastEvent() == null && 
model.isRequestingData()) {
-                        // Tell data provider we await further data
-                        clearData();
-                    } else {
-                        // Data has arrived, update data provider
-                        updateData();
-                    }
+                    updateData();
                 }
             }
         });
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
index a23d25c..a1e9a8a 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
@@ -7,6 +7,7 @@
 import org.ovirt.engine.core.common.businessentities.IVdcQueryable;
 import org.ovirt.engine.core.common.job.Job;
 import org.ovirt.engine.ui.common.system.ClientStorage;
+import org.ovirt.engine.ui.common.uicommon.model.ModelProvider;
 import org.ovirt.engine.ui.common.uicommon.model.SearchableTabModelProvider;
 import org.ovirt.engine.ui.common.widget.action.CommandLocation;
 import org.ovirt.engine.ui.common.widget.table.SimpleActionTable;
@@ -18,6 +19,9 @@
 import org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
+import org.ovirt.engine.ui.uicommonweb.models.HasEntity;
+import org.ovirt.engine.ui.uicommonweb.models.ListModel;
+import org.ovirt.engine.ui.uicommonweb.models.events.HasDismissCommand;
 import org.ovirt.engine.ui.webadmin.ApplicationConstants;
 import org.ovirt.engine.ui.webadmin.ApplicationResources;
 import org.ovirt.engine.ui.webadmin.ApplicationTemplates;
@@ -96,8 +100,20 @@
     SimpleActionTable<AuditLog> alertsTable;
     SimpleActionTable<AuditLog> eventsTable;
     TasksTree tasksTree;
+
+    /**
+     * single row table
+     */
     SimpleActionTable<AuditLog> _alertsTable;
+
+    /**
+     * single row table
+     */
     SimpleActionTable<AuditLog> _eventsTable;
+
+    /**
+     * single row table
+     */
     SimpleActionTable<Job> _tasksTable;
 
     String buttonUpStart;
@@ -136,7 +152,7 @@
 
         eventsTable = createActionTable(eventModelProvider, eventBus, 
clientStorage);
         eventsTable.setBarStyle(style.barStyle());
-        initTable(eventsTable);
+        initEventTable(eventsTable, eventModelProvider);
 
         _eventsTable = createActionTable(eventModelProvider, eventBus, 
clientStorage);
         makeSingleRowTable(_eventsTable);
@@ -378,6 +394,53 @@
         table.addColumn(messageColumn, constants.messageEvent());
     }
 
+    void initEventTable(final SimpleActionTable<AuditLog> table, final 
EventModelProvider eventModelProvider) {
+        table.addColumn(new AuditLogSeverityColumn(), constants.empty(), 
"30px"); //$NON-NLS-1$
+
+        AbstractTextColumn<AuditLog> logTimeColumn = new 
AbstractFullDateTimeColumn<AuditLog>() {
+            @Override
+            protected Date getRawValue(AuditLog object) {
+                return object.getLogTime();
+            }
+        };
+        table.addColumn(logTimeColumn, constants.timeEvent(), "160px"); 
//$NON-NLS-1$
+
+        table.addColumn(new DismissColumn<>(eventModelProvider), 
constants.empty(), "30px"); //$NON-NLS-1$
+
+        AbstractTextColumn<AuditLog> messageColumn = new 
AbstractTextColumn<AuditLog>() {
+            @Override
+            public String getValue(AuditLog object) {
+                return object.getMessage();
+            }
+        };
+        table.addColumn(messageColumn, constants.messageEvent());
+
+        table.getSelectionModel().setMultiSelectEnabled(false);
+
+        table.addActionButton(new 
WebAdminButtonDefinition<AuditLog>(constants.dismissEvent(), 
CommandLocation.OnlyFromContext) {
+            @Override
+            protected UICommand resolveCommand() {
+                return eventModelProvider.getModel().getDismissCommand();
+            }
+        });
+
+        table.addActionButton(new 
WebAdminButtonDefinition<AuditLog>(constants.clearAllDismissedEvents(), 
CommandLocation.OnlyFromContext) {
+            @Override
+            protected UICommand resolveCommand() {
+                return eventModelProvider.getModel().getClearAllCommand();
+            }
+        });
+
+        table.getSelectionModel().addSelectionChangeHandler(new 
SelectionChangeEvent.Handler() {
+            @Override
+            public void onSelectionChange(SelectionChangeEvent event) {
+                List<AuditLog> selectedItems = 
table.getSelectionModel().getSelectedList();
+                AuditLog selectedItem = selectedItems != null && 
selectedItems.size() > 0 ? selectedItems.get(0) : null;
+                eventModelProvider.getModel().setSelectedItem(selectedItem);
+            }
+        });
+    }
+
     void initAlertTable(final SimpleActionTable<AuditLog> table, final 
AlertModelProvider alertModelProvider) {
         table.addColumn(new AuditLogSeverityColumn(), constants.empty(), 
"30px"); //$NON-NLS-1$
 
@@ -389,7 +452,7 @@
         };
         table.addColumn(logTimeColumn, constants.timeEvent(), "160px"); 
//$NON-NLS-1$
 
-        table.addColumn(new DismissColumn(alertModelProvider), 
constants.empty(), "30px"); //$NON-NLS-1$
+        table.addColumn(new DismissColumn<>(alertModelProvider), 
constants.empty(), "30px"); //$NON-NLS-1$
 
         AbstractTextColumn<AuditLog> messageColumn = new 
AbstractTextColumn<AuditLog>() {
             @Override
@@ -491,10 +554,11 @@
         tasksTree.updateTree(taskModelProvider.getModel());
     }
 
-    class DismissColumn extends AbstractColumn<AuditLog, AuditLog> {
+    class DismissColumn<T extends ModelProvider<U>, U extends 
ListModel<AuditLog> & HasDismissCommand & HasEntity>
+            extends AbstractColumn<AuditLog, AuditLog> {
 
-        DismissColumn(AlertModelProvider alertModelProvider) {
-            super(new DismissAuditLogImageButtonCell(alertModelProvider));
+        DismissColumn(T modelProvider) {
+            super(new DismissAuditLogImageButtonCell<>(modelProvider));
         }
 
         @Override
@@ -504,23 +568,24 @@
 
         @Override
         public SafeHtml getTooltip(AuditLog object) {
-            return SafeHtmlUtils.fromSafeConstant(constants.dismissAlert());
+            return SafeHtmlUtils.fromSafeConstant(constants.dismissEvent());
         }
     }
 
-    class DismissAuditLogImageButtonCell extends 
AbstractImageButtonCell<AuditLog> {
+    class DismissAuditLogImageButtonCell<T extends ModelProvider<U>, U extends 
ListModel<AuditLog> & HasDismissCommand & HasEntity>
+            extends AbstractImageButtonCell<AuditLog> {
 
-        AlertModelProvider alertModelProvider;
+        T modelProvider;
 
-        public DismissAuditLogImageButtonCell(AlertModelProvider 
alertModelProvider) {
+        public DismissAuditLogImageButtonCell(T modelProvider) {
             super(resources.dialogIconClose(), "", 
resources.dialogIconClose(), ""); //$NON-NLS-1$ //$NON-NLS-2$
-            this.alertModelProvider = alertModelProvider;
+            this.modelProvider = modelProvider;
         }
 
         @Override
         protected UICommand resolveCommand(AuditLog value) {
-            alertModelProvider.getModel().setSelectedItem(value);
-            return alertModelProvider.getModel().getDismissCommand();
+            modelProvider.getModel().setSelectedItem(value);
+            return modelProvider.getModel().getDismissCommand();
         }
     }
 
diff --git a/packaging/dbscripts/audit_log_sp.sql 
b/packaging/dbscripts/audit_log_sp.sql
index 2bc02f0..05d2981 100644
--- a/packaging/dbscripts/audit_log_sp.sql
+++ b/packaging/dbscripts/audit_log_sp.sql
@@ -118,11 +118,11 @@
 END; $procedure$
 LANGUAGE plpgsql;
 
-Create or replace FUNCTION ClearAllDismissedAuditLogs()
+Create or replace FUNCTION ClearDismissedAuditLogsBy(v_severity INTEGER)
 RETURNS VOID
    AS $procedure$
 BEGIN
-      UPDATE audit_log SET deleted = false;
+      UPDATE audit_log SET deleted = false WHERE severity = v_severity;
 END; $procedure$
 LANGUAGE plpgsql;
 
@@ -322,4 +322,4 @@
       FROM audit_log
       WHERE gluster_volume_id = v_gluster_volume_id and log_type = v_log_type;
 END; $procedure$
-LANGUAGE plpgsql;
\ No newline at end of file
+LANGUAGE plpgsql;


-- 
To view, visit https://gerrit.ovirt.org/41382
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to