Search in sources :

Example 1 with AuditLogEntry

use of org.drools.workbench.models.datamodel.auditlog.AuditLogEntry in project drools-wb by kiegroup.

the class AuditLogViewImpl method setup.

public void setup() {
    // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same row.
    eventTypes.setStyleName(Styles.ROW);
    // Fill panel with available events.
    for (Map.Entry<String, Boolean> e : auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
        eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }
    // Create the GWT Cell Table as events container.
    // BZ-996942: Set custom width and table css style.
    events = new CellTable<>();
    events.setWidth("100%");
    events.addStyleName(Styles.TABLE);
    dlp = new ListDataProvider<AuditLogEntry>() {

        @Override
        public void setList(final List<AuditLogEntry> listToWrap) {
            super.setList(listToWrap);
            cellTablePagination.rebuild(pager);
        }
    };
    dlp.addDataDisplay(events);
    AuditLogEntrySummaryColumn summaryColumn = new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue());
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();
    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);
    events.setColumnWidth(summaryColumn, 60.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 40.0, Unit.PCT);
    // If the current user is not an Administrator include the delete comment column
    if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {
        AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
        deleteCommentColumn.setFieldUpdater((int index, AuditLogEntry row, SafeHtml value) -> {
            row.setDeleted(true);
            dlp.setList(filterDeletedEntries(auditLog));
            dlp.refresh();
        });
        events.addColumn(deleteCommentColumn);
        events.setColumnWidth(commentColumn, 35.0, Unit.PCT);
        events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }
    events.setEmptyTableWidget(new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(PAGE_SIZE);
    // Configure the simple pager.
    pager.setDisplay(events);
    pager.setPageSize(PAGE_SIZE);
    // Add the table to the container.
    eventsContainer.add(events);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) RoleImpl(org.jboss.errai.security.shared.api.RoleImpl) Label(org.gwtbootstrap3.client.ui.Label) AuditLogEntry(org.drools.workbench.models.datamodel.auditlog.AuditLogEntry) Map(java.util.Map)

Example 2 with AuditLogEntry

use of org.drools.workbench.models.datamodel.auditlog.AuditLogEntry in project drools-wb by kiegroup.

the class AuditLogViewImpl method filterDeletedEntries.

private List<AuditLogEntry> filterDeletedEntries(final List<AuditLogEntry> entries) {
    if (!identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {
        return entries;
    }
    final List<AuditLogEntry> filteredEntries = new ArrayList<>();
    final Iterator<AuditLogEntry> i = entries.iterator();
    while (i.hasNext()) {
        final AuditLogEntry entry = i.next();
        if (!entry.isDeleted()) {
            filteredEntries.add(entry);
        }
    }
    return filteredEntries;
}
Also used : AuditLogEntry(org.drools.workbench.models.datamodel.auditlog.AuditLogEntry) RoleImpl(org.jboss.errai.security.shared.api.RoleImpl) ArrayList(java.util.ArrayList)

Aggregations

AuditLogEntry (org.drools.workbench.models.datamodel.auditlog.AuditLogEntry)2 RoleImpl (org.jboss.errai.security.shared.api.RoleImpl)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Label (org.gwtbootstrap3.client.ui.Label)1