Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Dec 20, 2022
1 parent 22b11bf commit 1853a5a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5453,4 +5453,12 @@ public static String translateMessage(LocalizableMessage msg) {

return application.getLocalizationService().translate(msg, getCurrentLocale());
}

public static ItemPath getPath(GuiObjectColumnType column) {
if (column == null) {
return null;
}

return column.getPath().getItemPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,8 @@ protected boolean isPagingVisible() {
private int getDefaultPageSize() {
if (isPreview()) {
Integer previewSize = ((PreviewContainerPanelConfigurationType) config).getPreviewSize();
if (previewSize == null) {
return UserProfileStorage.DEFAULT_DASHBOARD_PAGING_SIZE;
}
return previewSize;

return Objects.requireNonNullElse(previewSize, UserProfileStorage.DEFAULT_DASHBOARD_PAGING_SIZE);
}

Integer collectionViewPagingSize = getViewPagingMaxSize();
Expand Down Expand Up @@ -534,7 +532,7 @@ protected List<IColumn<PO, String>> getViewColumnsTransformed(List<GuiObjectColu
if (nothingToTransform(customColumn)) {
continue;
}
ItemPath columnPath = getPath(customColumn);
ItemPath columnPath = WebComponentUtil.getPath(customColumn);
// TODO this throws an exception for some kinds of invalid paths like e.g. fullName/norm (but we probably should fix prisms in that case!)
ExpressionType expression = customColumn.getExport() != null ? customColumn.getExport().getExpression() : null;
if (expression == null && noItemDefinitionFor(columnPath, customColumn)) {
Expand Down Expand Up @@ -588,20 +586,6 @@ private IModel<String> createColumnDisplayModel(GuiObjectColumnType customColumn
Model.of(customColumn.getName())));
}

protected ItemPath getPath(GuiObjectColumnType column) {
if (column == null) {
return null;
}

return column.getPath().getItemPath();
}

/**
* @param columnDisplayModel
* @param customColumn
* @param expression
* @return
*/
protected IColumn<PO, String> createCustomExportableColumn(IModel<String> columnDisplayModel, GuiObjectColumnType customColumn, ExpressionType expression) {
return new AbstractExportableColumn<>(columnDisplayModel, getSortProperty(customColumn, expression)) {
private static final long serialVersionUID = 1L;
Expand All @@ -613,7 +597,7 @@ public void populateItem(org.apache.wicket.markup.repeater.Item<ICellPopulator<P
if (model.getObject() instanceof Collection) {
RepeatingView listItems = new RepeatingView(componentId);
for (Object object : (Collection) model.getObject()) {
listItems.add(new Label(listItems.newChildId(), (IModel) () -> object));
listItems.add(new Label(listItems.newChildId(), () -> object));
}
item.add(listItems);
} else {
Expand All @@ -623,7 +607,7 @@ public void populateItem(org.apache.wicket.markup.repeater.Item<ICellPopulator<P

@Override
public IModel<?> getDataModel(IModel<PO> rowModel) {
ItemPath columnPath = getPath(customColumn);
ItemPath columnPath = WebComponentUtil.getPath(customColumn);

return getExportableColumnDataModel(rowModel, customColumn, columnPath, expression);
}
Expand All @@ -648,22 +632,21 @@ private String getSortProperty(GuiObjectColumnType customColumn, ExpressionType
return null;
}

ItemPath path = getPath(customColumn);
ItemPath path = WebComponentUtil.getPath(customColumn);
if (path == null || path.isEmpty()) {
return null;
}

List<ItemPath> searchablePaths = getSearchablePaths(getType(), getPageBase());

ItemPath columnPath = getPath(customColumn);
for (ItemPath searchablePath : searchablePaths) {
if (searchablePath.size() > 1) {
//TODO: do we support such orderings in repo?
continue; //eg. activation/administrative status.. sortParam (BaseSortableDataProvider) should be changes to ItemPath..
}

if (searchablePath.equivalent(columnPath)) {
return columnPath.toString();
if (searchablePath.equivalent(path)) {
return path.toString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected IColumn<PrismContainerValueWrapper<AssignmentType>, String> createName

@Override
public IModel<String> createLinkModel(IModel<PrismContainerValueWrapper<AssignmentType>> rowModel) {
ItemPath itemPath = customColumn.getPath() != null ? customColumn.getPath().getItemPath() : null;
ItemPath itemPath = WebComponentUtil.getPath(customColumn);

return new LoadableModel<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private IColumn<PrismContainerValueWrapper<ShadowType>, String> createProjection

@Override
public IModel<String> createLinkModel(IModel<PrismContainerValueWrapper<ShadowType>> rowModel) {
ItemPath itemPath = customColumn.getPath() != null ? customColumn.getPath().getItemPath() : null;
ItemPath itemPath = WebComponentUtil.getPath(customColumn);

return new LoadableModel<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@
*/
package com.evolveum.midpoint.web.page.admin.reports.component;

import static com.evolveum.midpoint.gui.api.util.WebComponentUtil.dispatchToObjectDetailsPage;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.audit.api.AuditEventType;
import com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
Expand Down Expand Up @@ -77,6 +50,33 @@
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;
import org.jetbrains.annotations.NotNull;

import javax.xml.namespace.QName;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;

import static com.evolveum.midpoint.gui.api.util.WebComponentUtil.dispatchToObjectDetailsPage;

/**
* Created by honchar
*/
Expand All @@ -103,7 +103,7 @@ protected IColumn<SelectableBean<AuditEventRecordType>, String> createNameColumn
if (displayModel == null || customColumn == null) {
return null;
}
return new ContainerableNameColumn<>(displayModel, getPath(customColumn), expression, getPageBase()) {
return new ContainerableNameColumn<>(displayModel, WebComponentUtil.getPath(customColumn), expression, getPageBase()) {
@Override
protected IModel<String> getContainerName(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
return () -> {
Expand Down Expand Up @@ -276,7 +276,7 @@ protected ObjectQuery getCustomizeContentQuery() {

@Override
protected IColumn<SelectableBean<AuditEventRecordType>, String> createCustomExportableColumn(IModel<String> displayModel, GuiObjectColumnType guiObjectColumn, ExpressionType expression) {
ItemPath path = guiObjectColumn.getPath() != null ? guiObjectColumn.getPath().getItemPath() : null;
ItemPath path = WebComponentUtil.getPath(guiObjectColumn);

if (AuditEventRecordType.F_INITIATOR_REF.equivalent(path)) {
return new LinkColumn<>(createStringResource("AuditEventRecordType.initiatorRef"),
Expand Down

0 comments on commit 1853a5a

Please sign in to comment.