Skip to content

Commit

Permalink
generics + removing unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Feb 18, 2021
1 parent dc0d1d2 commit 9cedbe1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Expand Up @@ -160,9 +160,9 @@ public void addPerformed(AjaxRequestTarget target, List<O> selected) {
}

@Override
protected IColumn<SelectableBean<O>, String> createNameColumn(IModel<String> columnNameModel, String itemPath, ExpressionType expression) {
protected IColumn<SelectableBean<O>, String> createNameColumn(IModel<String> columnNameModel, String itemPath) {
return new ObjectNameColumn<O>(columnNameModel == null ? createStringResource("ObjectType.name") : columnNameModel,
itemPath, expression, getPageBase(), StringUtils.isEmpty(itemPath)) {
itemPath, null, getPageBase(), StringUtils.isEmpty(itemPath)) {
private static final long serialVersionUID = 1L;

@Override
Expand Down
Expand Up @@ -107,8 +107,6 @@ public abstract class ContainerableListPanel<C extends Containerable, PO extends
private static final String ID_BUTTON_REPEATER = "buttonsRepeater";
private static final String ID_BUTTON = "button";

private static final String DOT_CLASS = ContainerableListPanel.class.getName() + ".";

private Class<C> defaultType;

private LoadableModel<Search<C>> searchModel;
Expand Down Expand Up @@ -174,9 +172,9 @@ public Search<C> load() {
if (SearchBoxModeType.FULLTEXT.equals(search.getSearchType())) {
search.setFullText(searchByName);
} else {
for (PropertySearchItem item : search.getPropertyItems()) {
for (PropertySearchItem<String> item : search.getPropertyItems()) {
if (ItemPath.create(ObjectType.F_NAME).equivalent(item.getPath())) {
item.setValue(new SearchValue(searchByName));
item.setValue(new SearchValue<>(searchByName));
}
}
}
Expand All @@ -199,8 +197,8 @@ protected String getSearchByNameParameterValue() {
return null;
}

protected Search createSearch(Class<? extends C> type) {
return SearchFactory.createContainerSearch(new ContainerTypeSearchItem<C>(new SearchValue(type, "")), getPageBase());
protected Search createSearch(Class<C> type) {
return SearchFactory.createContainerSearch(new ContainerTypeSearchItem<>(new SearchValue<>(type, "")), getPageBase());
}

private void initLayout() {
Expand Down Expand Up @@ -253,7 +251,7 @@ protected WebMarkupContainer createHeader(String headerId) {
}

@Override
protected org.apache.wicket.markup.repeater.Item customizeNewRowItem(org.apache.wicket.markup.repeater.Item item, IModel model) {
protected org.apache.wicket.markup.repeater.Item<PO> customizeNewRowItem(org.apache.wicket.markup.repeater.Item item, IModel model) {
String status = GuiImplUtil.getObjectStatus(model.getObject());
if (status != null) {
item.add(AttributeModifier.append("class", new IModel<String>() {
Expand Down Expand Up @@ -349,14 +347,15 @@ protected DisplayType getNewObjectButtonDisplayType(){
}

public BoxedTablePanel<PO> getTable() {
//noinspection unchecked
return (BoxedTablePanel<PO>) get(ID_ITEMS).get(ID_ITEMS_TABLE);
}

public Class<C> getType() {
return getSearchModel().isLoaded() ? getSearchModel().getObject().getTypeClass() : (Class<C>) getDefaultType();
return getSearchModel().isLoaded() ? getSearchModel().getObject().getTypeClass() : getDefaultType();
}

protected Class<? extends C> getDefaultType() {
protected Class<C> getDefaultType() {
return defaultType;
}

Expand Down Expand Up @@ -433,7 +432,7 @@ private List<IColumn<PO, String>> getViewColumnsTransformed(List<GuiObjectColumn

if (customColumns.indexOf(customColumn) == 0) {
// TODO what if a complex path is provided here?
column = createNameColumn(columnDisplayModel, customColumn.getPath() == null ? "" : customColumn.getPath().toString(), null); //TODO check expression
column = createNameColumn(columnDisplayModel, customColumn.getPath() == null ? "" : customColumn.getPath().toString()); //TODO check expression
} else {
column = createCustomExportableColumn(columnDisplayModel, customColumn, columnPath, expression);
}
Expand Down Expand Up @@ -514,9 +513,14 @@ private IModel<?> getExportableColumnDataModel(IModel<PO> rowModel, GuiObjectCol
}
ExpressionVariables expressionVariables = new ExpressionVariables();
expressionVariables.put(ExpressionConstants.VAR_OBJECT, object, object.getClass());
String stringValue = ExpressionUtil.evaluateStringExpression(expressionVariables, getPageBase().getPrismContext(), expression,
Collection<String> evaluatedValues = ExpressionUtil.evaluateStringExpression(expressionVariables, getPageBase().getPrismContext(), expression,
MiscSchemaUtil.getExpressionProfile(), getPageBase().getExpressionFactory(), "evaluate column expression",
task, task.getResult()).iterator().next();
task, task.getResult());
String stringValue = null;
if (evaluatedValues != null) {
stringValue = evaluatedValues.iterator().next(); // TODO: what if more than one value is returned?
}

return Model.of(stringValue);
} catch (Exception e) {
LOGGER.error("Couldn't execute expression for name column");
Expand Down Expand Up @@ -592,7 +596,7 @@ private List<IColumn<PO, String>> initColumns() {
}
others = getViewColumnsTransformed(defaultView.getColumn());
} else {
IColumn<PO, String> nameColumn = createNameColumn(null, null, null);
IColumn<PO, String> nameColumn = createNameColumn(null, null);
if (nameColumn != null) {
columns.add(nameColumn);
}
Expand All @@ -613,8 +617,7 @@ protected IColumn<PO, String> createIconColumn(){
return (IColumn<PO, String>) ColumnUtils.createIconColumn(getPageBase());
}

protected IColumn<PO, String> createNameColumn(IModel<String> columnNameModel, String itemPath,
ExpressionType expression) {
protected IColumn<PO, String> createNameColumn(IModel<String> columnNameModel, String itemPath) {
return null;
}

Expand Down
Expand Up @@ -39,7 +39,7 @@ public class ContainerTypeSearchItem<C extends Containerable> extends SearchItem
private ObjectTypeSearchItemConfigurationType configuration = null;

public ContainerTypeSearchItem(Class<C> typeClass) {
this(new SearchValue(typeClass, ""), null);
this(new SearchValue<>(typeClass, ""), null);
}

public ContainerTypeSearchItem(@NotNull DisplayableValue<Class<C>> type) {
Expand Down
Expand Up @@ -156,7 +156,7 @@ protected IColumn createIconColumn() {
}

@Override
protected IColumn createNameColumn(IModel columnNameModel, String itemPath, ExpressionType expression) {
protected IColumn createNameColumn(IModel columnNameModel, String itemPath) {
return CaseWorkItemsPanel.this.createNameColumn();
}

Expand Down
Expand Up @@ -41,7 +41,6 @@
import com.evolveum.midpoint.web.session.UserProfileStorage;

import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -107,7 +106,7 @@ protected List<InlineMenuItem> createInlineMenu() {

@Override
protected IColumn<SelectableBean<AuditEventRecordType>, String> createNameColumn(IModel<String> columnNameModel,
String itemPath, ExpressionType expression) {
String itemPath) {
return AuditLogViewerPanel.this.createNameColumn();
}

Expand Down
Expand Up @@ -30,7 +30,6 @@
import com.evolveum.midpoint.web.page.admin.users.PageUsers;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -106,7 +105,7 @@ protected IColumn<SelectableBean<UserType>, String> createCheckboxColumn() {
}

@Override
protected IColumn<SelectableBean<UserType>, String> createNameColumn(IModel<String> columnNameModel, String itemPath, ExpressionType expression) {
protected IColumn<SelectableBean<UserType>, String> createNameColumn(IModel<String> columnNameModel, String itemPath) {
return new ObjectNameColumn<UserType>(createStringResource("ObjectType.name")) {

private static final long serialVersionUID = 1L;
Expand All @@ -122,7 +121,7 @@ public void onClick(AjaxRequestTarget target, IModel<SelectableBean<UserType>> r
@Override
protected List<IColumn<SelectableBean<UserType>, String>> createDefaultColumns() {
List<IColumn<SelectableBean<UserType>, String>> columns = new ArrayList<>();
columns.add(createNameColumn(null, null, null));
columns.add(createNameColumn(null, null));
columns.addAll(PageAttorneySelection.this.initColumns());
return columns;
}
Expand Down

0 comments on commit 9cedbe1

Please sign in to comment.