use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class PageCreatedReports method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<ReportDataType> table = new MainObjectListPanel<ReportDataType>(ID_TABLE, ReportDataType.class) {
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ReportDataType object) {
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL;
}
@Override
protected ISelectableDataProvider<ReportDataType, SelectableBean<ReportDataType>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> appendTypeFilter(), (sortParam) -> PageCreatedReports.this.createCustomOrdering(sortParam));
}
// @Override
// protected ObjectQuery getCustomizeContentQuery() {
// return appendTypeFilter();
// }
//
// @Override
// protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
// return PageCreatedReports.this.createCustomOrdering(sortParam);
// }
// @Override
// protected ISelectableDataProvider<ReportDataType, SelectableBean<ReportDataType>> createProvider() {
// PageStorage storage = getObjectListPanel().getPageStorage();
// SelectableBeanObjectDataProvider<ReportDataType> provider = new SelectableBeanObjectDataProvider<ReportDataType>(
// getPageBase(), getSearchModel(), null) {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected PageStorage getPageStorage() {
// return storage;
// }
//
// @NotNull
// @Override
// protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
// return PageCreatedReports.this.createCustomOrdering(sortParam);
// }
//
// @Override
// protected ObjectQuery getCustomizeContentQuery() {
// return appendTypeFilter();
// }
// };
// provider.setCompiledObjectCollectionView(getObjectCollectionView());
// provider.setOptions(createOptions());
// return provider;
// }
@Override
protected List<InlineMenuItem> createInlineMenu() {
return initInlineMenu();
}
@Override
protected boolean isCreateNewObjectEnabled() {
return false;
}
@Override
protected boolean isObjectDetailsEnabled(IModel<SelectableBean<ReportDataType>> rowModel) {
return false;
}
@Override
protected List<IColumn<SelectableBean<ReportDataType>, String>> createDefaultColumns() {
return PageCreatedReports.this.initColumns();
}
};
table.setOutputMarkupId(true);
mainForm.add(table);
String reportName = reportTypeMal.get(getReportType());
List<String> values = new ArrayList<>(reportTypeMal.values());
DropDownChoicePanel<String> reportTypeSelect = new DropDownChoicePanel<>(ID_REPORT_TYPE_SELECT, Model.of(reportName), Model.ofList(values), StringChoiceRenderer.simple(), true);
reportTypeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
table.refreshTable(target);
}
});
reportTypeSelect.setOutputMarkupId(true);
mainForm.add(reportTypeSelect);
ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {
private static final long serialVersionUID = 1L;
@Override
protected InputStream initStream() {
return createReport();
}
@Override
public String getFileName() {
return getReportFileName();
}
};
mainForm.add(ajaxDownloadBehavior);
}
use of com.evolveum.midpoint.web.component.util.SelectableBean 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 com.evolveum.midpoint.web.component.util.SelectableBean 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 com.evolveum.midpoint.web.component.util.SelectableBean 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 com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class TreeTablePanel method createTreeChildrenMenu.
private List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
List<InlineMenuItem> items = new ArrayList<>();
try {
boolean allowModify = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_MODIFY_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
boolean allowRead = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
InlineMenuItem item;
if (allowModify) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.move"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
moveRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
makeRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
boolean allowDelete = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
if (allowDelete) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.delete"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteNodePerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
if (allowModify) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
recomputeRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.edit"), Model.of(allowModify), Model.of(allowModify), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
} else if (allowRead) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails"), Model.of(allowRead), Model.of(allowRead), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
boolean allowAddNew = parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_ADD_ACTION_URL, AuthorizationPhaseType.REQUEST, (new OrgType(parentPage.getPrismContext())).asPrismObject(), null, null, null);
if (allowModify && allowAddNew) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
try {
initObjectForAdd(ObjectTypeUtil.createObjectRef(getRowModel().getObject().getValue()), OrgType.COMPLEX_TYPE, null, target);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
});
items.add(item);
}
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check menu items authorizations", ex);
}
return items;
}
Aggregations