use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class AuditLogViewerPanel method initLayout.
private void initLayout() {
ContainerableListPanel<AuditEventRecordType, SelectableBean<AuditEventRecordType>> auditLogViewerTable = new ContainerableListPanel<>(ID_AUDIT_LOG_VIEWER_TABLE, AuditEventRecordType.class) {
@Override
protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createDefaultColumns() {
return AuditLogViewerPanel.this.createColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return null;
}
@Override
protected IColumn<SelectableBean<AuditEventRecordType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
return AuditLogViewerPanel.this.createNameColumn();
}
@Override
protected IColumn<SelectableBean<AuditEventRecordType>, String> createCheckboxColumn() {
return null;
}
@Override
protected IColumn<SelectableBean<AuditEventRecordType>, String> createIconColumn() {
return null;
}
@Override
protected Search createSearch(Class<AuditEventRecordType> type) {
// TODO: use storage?
AuditLogStorage storage = (AuditLogStorage) getPageStorage();
Search search = SearchFactory.createContainerSearch(new ContainerTypeSearchItem(new SearchValue(type, "")), AuditEventRecordType.F_TIMESTAMP, getPageBase(), true);
DateSearchItem timestampItem = (DateSearchItem) search.findPropertySearchItem(AuditEventRecordType.F_TIMESTAMP);
if (timestampItem != null && timestampItem.getFromDate() == null && timestampItem.getToDate() == null && !isCollectionViewPanelForWidget()) {
Date todayDate = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
timestampItem.setFromDate(MiscUtil.asXMLGregorianCalendar(todayDate));
}
return search;
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER;
}
@Override
protected String getStorageKey() {
String collectionNameValue = null;
if (isCollectionViewPanelForCompiledView()) {
StringValue collectionName = getCollectionNameParameterValue();
collectionNameValue = collectionName != null ? collectionName.toString() : "";
}
return getAuditStorageKey(collectionNameValue);
}
@Override
protected ISelectableDataProvider createProvider() {
PageStorage pageStorage = getPageStorage();
SelectableBeanContainerDataProvider<AuditEventRecordType> provider = new SelectableBeanContainerDataProvider<AuditEventRecordType>(AuditLogViewerPanel.this, getSearchModel(), null, false) {
@Override
protected PageStorage getPageStorage() {
return pageStorage;
}
@Override
protected Integer countObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommonException {
return getPageBase().getModelAuditService().countObjects(query, currentOptions, task, result);
}
@Override
protected List<AuditEventRecordType> searchObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommonException {
return getPageBase().getModelAuditService().searchObjects(query, options, task, result);
}
@NotNull
@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
if (sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
} else {
return Collections.emptyList();
}
}
@Override
protected ObjectQuery getCustomizeContentQuery() {
return AuditLogViewerPanel.this.getCustomizeContentQuery();
}
};
provider.setSort(AuditEventRecordType.F_TIMESTAMP.getLocalPart(), SortOrder.DESCENDING);
return provider;
}
@Override
protected AuditEventRecordType getRowRealValue(SelectableBean<AuditEventRecordType> rowModelObject) {
if (rowModelObject == null) {
return null;
}
return rowModelObject.getValue();
}
@Override
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> buttonsList = new ArrayList<>();
CsvDownloadButtonPanel exportDataLink = new CsvDownloadButtonPanel(idButton) {
private static final long serialVersionUID = 1L;
@Override
protected String getFilename() {
return "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
}
@Override
protected DataTable<?, ?> getDataTable() {
return getTable().getDataTable();
}
};
exportDataLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_CSV_EXPORT_ACTION_URI);
}
});
buttonsList.add(exportDataLink);
AjaxCompositedIconButton createReport = new AjaxCompositedIconButton(idButton, WebComponentUtil.createCreateReportIcon(), getPageBase().createStringResource("MainObjectListPanel.createReport")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
createReportPerformed(target);
}
};
createReport.add(AttributeAppender.append("class", "btn btn-default btn-sm btn-margin-right"));
buttonsList.add(createReport);
return buttonsList;
}
};
auditLogViewerTable.setOutputMarkupId(true);
add(auditLogViewerTable);
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class AuditLogViewerPanel method createColumns.
protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createColumns() {
List<IColumn<SelectableBean<AuditEventRecordType>, String>> columns = new ArrayList<>();
LinkColumn<SelectableBean<AuditEventRecordType>> initiatorRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.initiatorRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getInitiatorRef(), getPageBase(), true);
});
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getInitiatorRef(), getPageBase(), false);
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null;
}
};
columns.add(initiatorRefColumn);
if (!isObjectHistoryPanel()) {
IColumn<SelectableBean<AuditEventRecordType>, String> eventStageColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventStageLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return new Model<>();
}
return WebComponentUtil.createLocalizedModelForEnum(record.getEventStage(), AuditLogViewerPanel.this);
}
};
columns.add(eventStageColumn);
}
IColumn<SelectableBean<AuditEventRecordType>, String> eventTypeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventTypeLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return Model.of();
}
return WebComponentUtil.createLocalizedModelForEnum(record.getEventType(), AuditLogViewerPanel.this);
}
};
columns.add(eventTypeColumn);
if (!isObjectHistoryPanel()) {
LinkColumn<SelectableBean<AuditEventRecordType>> targetRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetRef(), getPageBase(), true);
});
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null && !AuditEventTypeType.DELETE_OBJECT.equals(unwrapModel(rowModel).getEventType());
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getTargetRef(), getPageBase(), false);
}
};
columns.add(targetRefColumn);
}
if (!isObjectHistoryPanel()) {
LinkColumn<SelectableBean<AuditEventRecordType>> targetOwnerRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetOwnerRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return new ReadOnlyModel<>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
return null;
}
return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetOwnerRef(), getPageBase(), true);
});
}
@Override
public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
dispatchToObjectDetailsPage(auditEventRecordType.getTargetOwnerRef(), getPageBase(), false);
}
@Override
public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return unwrapModel(rowModel) != null;
}
};
columns.add(targetOwnerRefColumn);
}
IColumn<SelectableBean<AuditEventRecordType>, String> channelColumn = new PropertyColumn<>(createStringResource("AuditEventRecordType.channel"), AuditEventRecordType.F_CHANNEL.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_CHANNEL.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<AuditEventRecordType>>> item, String componentId, IModel<SelectableBean<AuditEventRecordType>> rowModel) {
IModel<String> channelModel = new ReadOnlyModel<String>(() -> {
AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
if (auditEventRecordType == null) {
// TODO might we return null?
return "";
}
String channel = auditEventRecordType.getChannel();
for (GuiChannel chan : GuiChannel.values()) {
if (chan.getUri().equals(channel)) {
// WebComponentUtil.createLocalizedModelForEnum(chan, AuditLogViewerPanel.this);
return getPageBase().createStringResource(chan).getString();
}
}
return "";
});
// if (channelValue != null) {
// item.add(new Label(componentId, WebComponentUtil.createLocalizedModelForEnum(channelValue, AuditLogViewerPanel.this)));
// } else {
// item.add(new Label(componentId, ""));
// }
item.add(new Label(componentId, channelModel));
item.add(new AttributeModifier("style", new Model<>("width: 10%;")));
}
};
columns.add(channelColumn);
IColumn<SelectableBean<AuditEventRecordType>, String> outcomeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.outcomeLabel"), AuditEventRecordType.F_OUTCOME.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_OUTCOME.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
AuditEventRecordType record = unwrapModel(rowModel);
if (record == null) {
return null;
}
return WebComponentUtil.createLocalizedModelForEnum(record.getOutcome(), AuditLogViewerPanel.this);
}
};
columns.add(outcomeColumn);
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class ResourceContentPanel method initColumns.
private List<IColumn<SelectableBean<ShadowType>, String>> initColumns() {
List<ColumnTypeDto<String>> columnDefs = Arrays.asList(new ColumnTypeDto<>("ShadowType.synchronizationSituation", SelectableBeanImpl.F_VALUE + ".synchronizationSituation", ShadowType.F_SYNCHRONIZATION_SITUATION.getLocalPart()), new ColumnTypeDto<>("ShadowType.intent", SelectableBeanImpl.F_VALUE + ".intent", ShadowType.F_INTENT.getLocalPart()));
List<IColumn<SelectableBean<ShadowType>, String>> columns = new ArrayList<>();
IColumn<SelectableBean<ShadowType>, String> identifiersColumn = new AbstractColumn<>(createStringResource("pageContentAccounts.identifiers")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ShadowType>>> cellItem, String componentId, IModel<SelectableBean<ShadowType>> rowModel) {
SelectableBean<ShadowType> dto = rowModel.getObject();
RepeatingView repeater = new RepeatingView(componentId);
ShadowType value = dto.getValue();
if (value != null) {
for (ResourceAttribute<?> attr : ShadowUtil.getAllIdentifiers(value)) {
repeater.add(new Label(repeater.newChildId(), attr.getElementName().getLocalPart() + ": " + attr.getRealValue()));
}
}
cellItem.add(repeater);
}
};
columns.add(identifiersColumn);
columns.addAll(ColumnUtils.createColumns(columnDefs));
ObjectLinkColumn<SelectableBean<ShadowType>> ownerColumn = new ObjectLinkColumn<>(createStringResource("pageContentAccounts.owner")) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<FocusType> createLinkModel(final IModel<SelectableBean<ShadowType>> rowModel) {
return new IModel<>() {
private static final long serialVersionUID = 1L;
@Override
public FocusType getObject() {
return loadShadowOwner(rowModel);
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel, ObjectType targetObjectType) {
ownerDetailsPerformed((FocusType) targetObjectType);
}
};
columns.add(ownerColumn);
columns.add(new AbstractColumn<>(createStringResource("PageAccounts.accounts.pendingOperations")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ShadowType>>> cellItem, String componentId, IModel<SelectableBean<ShadowType>> rowModel) {
cellItem.add(new PendingOperationPanel(componentId, new PropertyModel<>(rowModel, SelectableBeanImpl.F_VALUE + "." + ShadowType.F_PENDING_OPERATION.getLocalPart())));
}
});
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageObjectCollections method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<ObjectCollectionType> table = new MainObjectListPanel<ObjectCollectionType>(ID_TABLE, ObjectCollectionType.class) {
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.TABLE_OBJECTS_COLLECTION;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
List<InlineMenuItem> menu = new ArrayList<>();
menu.add(createDeleteInlineMenu());
return menu;
}
@Override
protected List<IColumn<SelectableBean<ObjectCollectionType>, String>> createDefaultColumns() {
return ColumnUtils.getDefaultObjectColumns();
}
@Override
protected String getNothingSelectedMessage() {
return getString("pageObjectCollections.message.nothingSelected");
}
@Override
protected String getConfirmMessageKeyForSingleObject() {
return "pageObjectCollections.message.confirmationMessageForMultipleObject";
}
@Override
protected String getConfirmMessageKeyForMultiObject() {
return "pageObjectCollections.message.confirmationMessageForSingleObject";
}
};
table.setOutputMarkupId(true);
mainForm.add(table);
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class ReportMainPanel method createColumnsForColumns.
private List<IColumn<PrismContainerValueWrapper<GuiObjectColumnType>, String>> createColumnsForColumns(PageAdminObjectDetails<ReportType> parentPage) {
PrismContainerWrapperModel<ReportType, GuiObjectColumnType> containerModel = PrismContainerWrapperModel.fromContainerWrapper(getObjectModel(), ItemPath.create(ReportType.F_OBJECT_COLLECTION, ObjectCollectionReportEngineConfigurationType.F_VIEW, GuiObjectListViewType.F_COLUMN));
List<IColumn<PrismContainerValueWrapper<GuiObjectColumnType>, String>> columns = new ArrayList<>();
columns.add(new PrismPropertyWrapperColumn<GuiObjectColumnType, String>(containerModel, GuiObjectColumnType.F_NAME, AbstractItemWrapperColumn.ColumnType.VALUE, parentPage) {
@Override
public String getCssClass() {
return "col-sm-3 col-md-2";
}
});
columns.add(new PrismPropertyWrapperColumn<GuiObjectColumnType, String>(containerModel, GuiObjectColumnType.F_PATH, AbstractItemWrapperColumn.ColumnType.VALUE, parentPage) {
@Override
public String getCssClass() {
return "col-md-3";
}
});
PrismContainerDefinition<Containerable> def = containerModel.getObject().getComplexTypeDefinition().findContainerDefinition(GuiObjectColumnType.F_DISPLAY);
columns.add(new PrismPropertyWrapperColumn(Model.of(def), DisplayType.F_LABEL, AbstractItemWrapperColumn.ColumnType.VALUE, parentPage) {
@Override
public IModel<?> getDataModel(IModel rowModel) {
return PrismPropertyWrapperModel.fromContainerValueWrapper(rowModel, ItemPath.create(GuiObjectColumnType.F_DISPLAY, DisplayType.F_LABEL));
}
});
return columns;
}
Aggregations