use of com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto in project midpoint by Evolveum.
the class ObjectHistoryTabPanel method initLayout.
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusWrapperModel, final PageAdminObjectDetails<F> page) {
AuditSearchDto searchDto = new AuditSearchDto();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(focusWrapperModel.getObject().getOid());
searchDto.setTargetNames(asList(ort));
searchDto.setEventStage(AuditEventStageType.EXECUTION);
Map<String, Boolean> visibilityMap = new HashMap<>();
visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_COLUMN_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_COLUMN_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_COLUMN_VISIBILITY, false);
AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL, page, searchDto, visibilityMap) {
@Override
protected List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = super.initColumns();
IColumn<AuditEventRecordType, String> column = new MultiButtonColumn<AuditEventRecordType>(new Model(), 2) {
private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS };
@Override
public String getCaption(int id) {
return "";
}
@Override
public String getButtonTitle(int id) {
switch(id) {
case 0:
return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle").getString();
case 1:
return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle").getString();
}
return "";
}
@Override
public String getButtonColorCssClass(int id) {
return colors[id].toString();
}
@Override
protected String getButtonCssClass(int id) {
StringBuilder sb = new StringBuilder();
sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
sb.append(getButtonColorCssClass(id)).append(" ");
switch(id) {
case 0:
sb.append("fa fa-circle-o");
break;
case 1:
sb.append("fa fa-file-text-o");
break;
}
return sb.toString();
}
@Override
public void clickPerformed(int id, AjaxRequestTarget target, IModel<AuditEventRecordType> model) {
switch(id) {
case 0:
currentStateButtonClicked(target, focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE), page.getCompileTimeClass());
break;
case 1:
viewObjectXmlButtonClicked(focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), page.getCompileTimeClass(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE));
break;
}
}
};
columns.add(column);
return columns;
}
};
panel.setOutputMarkupId(true);
add(panel);
}
use of com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto in project midpoint by Evolveum.
the class AuditLogViewerPanel method addOrReplaceTable.
private void addOrReplaceTable(Form mainForm) {
AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {
private static final long serialVersionUID = 1L;
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
AuditSearchDto search = auditSearchDto.getObject();
parameters.put("from", search.getFrom());
parameters.put("to", search.getTo());
if (search.getChannel() != null) {
parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
}
parameters.put("hostIdentifier", search.getHostIdentifier());
if (search.getInitiatorName() != null) {
parameters.put("initiatorName", search.getInitiatorName().getOid());
}
if (search.getTargetOwnerName() != null) {
parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
}
List<String> targetOids = new ArrayList<>();
if (isNotEmpty(search.getTargetNamesObjects())) {
targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
}
if (isNotEmpty(search.getTargetNames())) {
targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
}
if (!targetOids.isEmpty()) {
parameters.put("targetNames", targetOids);
}
if (search.getChangedItem().toItemPath() != null) {
ItemPath itemPath = search.getChangedItem().toItemPath();
parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
}
parameters.put("eventType", search.getEventType());
parameters.put("eventStage", search.getEventStage());
parameters.put("outcome", search.getOutcome());
if (isNotEmpty(search.getvalueRefTargetNames())) {
parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
}
return parameters;
}
@Override
protected void saveCurrentPage(long from, long count) {
if (count != 0) {
auditLogStorage.setPageNumber(from / count);
}
}
};
UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
int pageSize = DEFAULT_PAGE_SIZE;
if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
}
List<IColumn<AuditEventRecordType, String>> columns = initColumns();
BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter() {
@Override
public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
((AuditEventRecordProvider) dataProvider).setExportSize(true);
super.exportData(dataProvider, columns, outputStream);
((AuditEventRecordProvider) dataProvider).setExportSize(false);
}
};
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
@Override
public void setShowPaging(boolean show) {
//we don't need to do anything here
}
};
table.setShowPaging(true);
table.setCurrentPage(auditLogStorage.getPageNumber());
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}
Aggregations