Search in sources :

Example 1 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class HeaderPresenterWidget method onBind.

@SuppressWarnings("unchecked")
@Override
protected void onBind() {
    super.onBind();
    registerHandler(getView().getLogoutLink().addClickHandler(event -> user.logout()));
    registerHandler(getView().getGuideLink().addClickHandler(event -> WebUtils.openUrlInNewWindow(windowName, guideUrl)));
    registerHandler(getView().getOptionsLink().addClickHandler(event -> {
        OptionsModel model = optionsProvider.getModel();
        model.executeCommand(model.getEditCommand());
    }));
    registerHandler(getView().getAboutLink().addClickHandler(event -> RevealRootPopupContentEvent.fire(HeaderPresenterWidget.this, aboutPopupProvider.get())));
    registerHandler(getView().getTasksWidget().addClickHandler(event -> toggleOverlayPresenter(tasksPresenter)));
    registerHandler(getView().getBookmarkLink().addClickHandler(event -> toggleOverlayPresenter(bookmarksPresenter)));
    registerHandler(getView().getTagsLink().addClickHandler(event -> toggleOverlayPresenter(tagsPresenter)));
    getView().getAlertActionWidget().addAction(constants.dismissAlert(), this.alertModelProvider.getModel().getDismissCommand(), (command, log) -> {
        AlertListModel model = alertModelProvider.getModel();
        if (log != null) {
            model.setSelectedItem(log);
            model.executeCommand(command);
        }
    });
    getView().getAlertActionWidget().addClearAllAction(constants.clearAllDismissedAlerts(), this.alertModelProvider.getModel().getClearAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
    getView().getAlertActionWidget().addRestoreAllAction(constants.displayAllDismissedAlerts(), this.alertModelProvider.getModel().getDisplayAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
    getView().getEventActionWidget().addAction(constants.dismissEvent(), this.eventModelProvider.getModel().getDismissCommand(), (command, log) -> {
        EventListModel<?> model = eventModelProvider.getModel();
        if (log != null) {
            model.setSelectedItem(log);
            model.executeCommand(command);
        }
    });
    getView().getEventActionWidget().addClearAllAction(constants.clearAllDismissedEvents(), this.eventModelProvider.getModel().getClearAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
    getView().getEventActionWidget().addRestoreAllAction(constants.displayAllDismissedEvents(), this.eventModelProvider.getModel().getDisplayAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
    taskModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            Collection<Job> jobs = taskModelProvider.getModel().getItems();
            long count = jobs.stream().filter(job -> JobExecutionStatus.STARTED.equals(job.getStatus())).count();
            // I know I will never have more than 100 items, so I can cast to int.
            getView().setRunningTaskCount((int) count);
        }
    });
    alertModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            Collection<AuditLog> alerts = alertModelProvider.getModel().getItems();
            long count = alerts.stream().filter(alert -> AuditLogSeverity.ALERT.equals(alert.getSeverity())).count();
            // I know I will never have more than 100 items, so I can cast to int.
            getView().setAlertCount((int) count);
        }
    });
}
Also used : RevealRootPopupContentEvent(com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Job(org.ovirt.engine.core.common.job.Job) Inject(com.google.inject.Inject) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) Event(org.ovirt.engine.ui.uicompat.Event) EventModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.EventModelProvider) EventListModel(org.ovirt.engine.ui.uicommonweb.models.events.EventListModel) AlertModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.AlertModelProvider) ActionWidget(org.ovirt.engine.ui.webadmin.widget.alert.ActionWidget) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) BookmarkPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.BookmarkPresenterWidget) OptionsModel(org.ovirt.engine.ui.uicommonweb.models.OptionsModel) TagsPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.TagsPresenterWidget) AlertListModel(org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel) PresenterWidget(com.gwtplatform.mvp.client.PresenterWidget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) TasksPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.TasksPresenterWidget) CurrentUser(org.ovirt.engine.ui.common.auth.CurrentUser) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) WebUtils(org.ovirt.engine.ui.common.utils.WebUtils) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) HasData(com.google.gwt.view.client.HasData) EventBus(com.google.gwt.event.shared.EventBus) View(com.gwtplatform.mvp.client.View) Collection(java.util.Collection) OptionsProvider(org.ovirt.engine.ui.common.uicommon.model.OptionsProvider) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) HasClickHandlers(com.google.gwt.event.dom.client.HasClickHandlers) Provider(com.google.inject.Provider) TaskModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.TaskModelProvider) AuditLogSeverity(org.ovirt.engine.core.common.AuditLogSeverity) ApplicationDynamicMessages(org.ovirt.engine.ui.webadmin.ApplicationDynamicMessages) Named(com.google.inject.name.Named) AlertListModel(org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel) Collection(java.util.Collection) OptionsModel(org.ovirt.engine.ui.uicommonweb.models.OptionsModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs)

Example 2 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class EventPopupView method edit.

@Override
public void edit(final EventModel eventModel) {
    driver.edit(eventModel);
    AuditLog event = eventModel.getEvent();
    eventIdLabel.asValueBox().setValue(String.valueOf(event.getLogTypeValue()));
    eventTimeLabel.asValueBox().setValue(new FullDateTimeRenderer().render(event.getLogTime()));
    eventMessageTextArea.asValueBox().setValue(event.getMessage());
}
Also used : FullDateTimeRenderer(org.ovirt.engine.ui.common.widget.renderer.FullDateTimeRenderer) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 3 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class RemoveAuditLogByIdCommandTest method getEventWithExternalOrigin.

private AuditLog getEventWithExternalOrigin() {
    AuditLog auditLog = new AuditLog();
    auditLog.setAuditLogId(EVENT_ID_3);
    auditLog.setOrigin(EXTERNAL_ORIGIN);
    return auditLog;
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 4 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class GetAllAuditLogsByVMTemplateIdQueryTest method testExecuteQueryCommand.

@Test
public void testExecuteQueryCommand() {
    // Mock the Query Parameters
    Guid vmTemplateId = Guid.newGuid();
    when(getQueryParameters().getId()).thenReturn(vmTemplateId);
    // Set up the expected result
    AuditLog expectedResult = new AuditLog();
    expectedResult.setVmTemplateId(vmTemplateId);
    // Mock the Daos
    when(auditLogDaoMock.getAllByVMTemplateId(vmTemplateId, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(Collections.singletonList(expectedResult));
    getQuery().executeQueryCommand();
    @SuppressWarnings("unchecked") List<AuditLog> result = getQuery().getQueryReturnValue().getReturnValue();
    assertEquals("Wrong number of audit logs in result", 1, result.size());
    assertEquals("Wrong audit log in result", expectedResult, result.get(0));
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Test(org.junit.Test)

Example 5 with AuditLog

use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.

the class EventListModel method details.

private void details() {
    AuditLog event = getSelectedItem();
    if (getWindow() != null || event == null) {
        return;
    }
    EventModel model = new EventModel();
    model.setEvent(event);
    model.setTitle(ConstantsManager.getInstance().getConstants().eventDetailsTitle());
    model.setHelpTag(HelpTag.event_details);
    // $NON-NLS-1$
    model.setHashName("event_details");
    setWindow(model);
    // $NON-NLS-1$
    UICommand command = new UICommand("Cancel", this);
    command.setTitle(ConstantsManager.getInstance().getConstants().close());
    command.setIsCancel(true);
    model.getCommands().add(command);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Aggregations

AuditLog (org.ovirt.engine.core.common.businessentities.AuditLog)31 Test (org.junit.Test)13 Date (java.util.Date)6 Guid (org.ovirt.engine.core.compat.Guid)4 AuditLogSeverity (org.ovirt.engine.core.common.AuditLogSeverity)2 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)2 AuditLogSeverityColumn (org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn)2 HasClickHandlers (com.google.gwt.event.dom.client.HasClickHandlers)1 EventBus (com.google.gwt.event.shared.EventBus)1 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HasData (com.google.gwt.view.client.HasData)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Named (com.google.inject.name.Named)1 PresenterWidget (com.gwtplatform.mvp.client.PresenterWidget)1 View (com.gwtplatform.mvp.client.View)1 RevealRootPopupContentEvent (com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent)1 Date (java.sql.Date)1 Collection (java.util.Collection)1