Search in sources :

Example 1 with SortParam

use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project syncope by apache.

the class SearchClausePanel method settingsDependingComponents.

@Override
public FieldPanel<SearchClause> settingsDependingComponents() {
    final SearchClause searchClause = this.clause.getObject();
    final WebMarkupContainer operatorContainer = new WebMarkupContainer("operatorContainer");
    operatorContainer.setOutputMarkupId(true);
    field.add(operatorContainer);
    final BootstrapToggleConfig config = new BootstrapToggleConfig().withOnStyle(BootstrapToggleConfig.Style.info).withOffStyle(BootstrapToggleConfig.Style.warning).withSize(BootstrapToggleConfig.Size.mini);
    operatorFragment.add(new BootstrapToggle("operator", new Model<Boolean>() {

        private static final long serialVersionUID = -7157802546272668001L;

        @Override
        public Boolean getObject() {
            return searchClause.getOperator() == Operator.AND;
        }

        @Override
        public void setObject(final Boolean object) {
            searchClause.setOperator(object ? Operator.AND : Operator.OR);
        }
    }, config) {

        private static final long serialVersionUID = 2969634208049189343L;

        @Override
        protected IModel<String> getOffLabel() {
            return Model.of("OR");
        }

        @Override
        protected IModel<String> getOnLabel() {
            return Model.of("AND");
        }

        @Override
        protected CheckBox newCheckBox(final String id, final IModel<Boolean> model) {
            final CheckBox checkBox = super.newCheckBox(id, model);
            checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                }
            });
            return checkBox;
        }
    }.setOutputMarkupPlaceholderTag(true));
    if (getIndex() > 0) {
        operatorContainer.add(operatorFragment);
    } else {
        operatorContainer.add(searchButtonFragment);
    }
    final AjaxTextFieldPanel property = new AjaxTextFieldPanel("property", "property", new PropertyModel<String>(searchClause, "property"), false);
    property.hideLabel().setOutputMarkupId(true).setEnabled(true);
    property.setChoices(properties.getObject());
    field.add(property);
    property.getField().add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) { event.preventDefault(); }")));
    property.getField().add(new IndicatorAjaxEventBehavior("onkeyup") {

        private static final long serialVersionUID = -7866120562087857309L;

        @Override
        protected void onEvent(final AjaxRequestTarget target) {
            if (field.getModel().getObject() == null || field.getModel().getObject().getType() == null) {
                return;
            }
            if (field.getModel().getObject().getType() == Type.GROUP_MEMBERSHIP) {
                String[] inputAsArray = property.getField().getInputAsArray();
                if (StringUtils.isBlank(property.getField().getInput()) || inputAsArray.length == 0) {
                    property.setChoices(properties.getObject());
                } else {
                    String inputValue = (inputAsArray.length > 1 && inputAsArray[1] != null) ? inputAsArray[1] : property.getField().getInput();
                    inputValue = (inputValue.startsWith("*") && !inputValue.endsWith("*")) ? inputValue + "*" : (!inputValue.startsWith("*") && inputValue.endsWith("*")) ? "*" + inputValue : (inputValue.startsWith("*") && inputValue.endsWith("*") ? inputValue : "*" + inputValue + "*");
                    if (groupInfo.getRight() > AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY) {
                        List<GroupTO> filteredGroups = groupRestClient.search("/", SyncopeClient.getGroupSearchConditionBuilder().is("name").equalToIgnoreCase(inputValue).query(), 1, AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY, new SortParam<>("name", true), null);
                        Collection<String> newList = CollectionUtils.collect(filteredGroups, new Transformer<GroupTO, String>() {

                            @Override
                            public String transform(final GroupTO input) {
                                return input.getName();
                            }
                        });
                        final List<String> names = new ArrayList<>(newList);
                        Collections.sort(names);
                        property.setChoices(names);
                    }
                }
            }
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().clear();
        }
    }, new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
        }
    });
    final AjaxDropDownChoicePanel<SearchClause.Comparator> comparator = new AjaxDropDownChoicePanel<>("comparator", "comparator", new PropertyModel<>(searchClause, "comparator"));
    comparator.setChoices(comparators);
    comparator.setNullValid(false).hideLabel().setOutputMarkupId(true);
    comparator.setRequired(required);
    comparator.setChoiceRenderer(getComparatorRender(field.getModel()));
    field.add(comparator);
    final AjaxTextFieldPanel value = new AjaxTextFieldPanel("value", "value", new PropertyModel<>(searchClause, "value"), false);
    value.hideLabel().setOutputMarkupId(true);
    field.add(value);
    value.getField().add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
    value.getField().add(new IndicatorAjaxEventBehavior("onkeydown") {

        private static final long serialVersionUID = -7133385027739964990L;

        @Override
        protected void onEvent(final AjaxRequestTarget target) {
            target.focusComponent(null);
            value.getField().inputChanged();
            value.getField().validate();
            if (value.getField().isValid()) {
                value.getField().valid();
                value.getField().updateModel();
            }
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new AjaxCallListener() {

                private static final long serialVersionUID = 7160235486520935153L;

                @Override
                public CharSequence getPrecondition(final Component component) {
                    return "if (Wicket.Event.keyCode(attrs.event)  == 13) { return true; } else { return false; }";
                }
            });
        }
    });
    final AjaxDropDownChoicePanel<SearchClause.Type> type = new AjaxDropDownChoicePanel<>("type", "type", new PropertyModel<>(searchClause, "type"));
    type.setChoices(types).hideLabel().setRequired(required).setOutputMarkupId(true);
    type.setNullValid(false);
    type.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            final SearchClause searchClause = new SearchClause();
            if (StringUtils.isNotEmpty(type.getDefaultModelObjectAsString())) {
                searchClause.setType(Type.valueOf(type.getDefaultModelObjectAsString()));
            }
            SearchClausePanel.this.clause.setObject(searchClause);
            setFieldAccess(searchClause.getType(), property, comparator, value);
            // reset property value in case and just in case of change of type
            property.setModelObject(StringUtils.EMPTY);
            target.add(property);
            target.add(comparator);
            target.add(value);
        }
    });
    field.add(type);
    comparator.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (type.getModelObject() == SearchClause.Type.ATTRIBUTE || type.getModelObject() == SearchClause.Type.RELATIONSHIP) {
                if (comparator.getModelObject() == SearchClause.Comparator.IS_NULL || comparator.getModelObject() == SearchClause.Comparator.IS_NOT_NULL) {
                    value.setModelObject(StringUtils.EMPTY);
                    value.setEnabled(false);
                } else {
                    value.setEnabled(true);
                }
                target.add(value);
            }
            if (type.getModelObject() == SearchClause.Type.RELATIONSHIP) {
                property.setEnabled(true);
                final SearchClause searchClause = new SearchClause();
                searchClause.setType(Type.valueOf(type.getDefaultModelObjectAsString()));
                searchClause.setComparator(comparator.getModelObject());
                SearchClausePanel.this.clause.setObject(searchClause);
                target.add(property);
            }
        }
    });
    setFieldAccess(searchClause.getType(), property, comparator, value);
    return this;
}
Also used : Transformer(org.apache.commons.collections4.Transformer) IndicatorAjaxFormComponentUpdatingBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) Comparator(org.apache.syncope.client.console.panels.search.SearchClause.Comparator) IndicatorAjaxEventBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxEventBehavior) List(java.util.List) ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) IModel(org.apache.wicket.model.IModel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) Type(org.apache.syncope.client.console.panels.search.SearchClause.Type) BootstrapToggleConfig(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggleConfig) BootstrapToggle(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggle) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Collection(java.util.Collection) AjaxCallListener(org.apache.wicket.ajax.attributes.AjaxCallListener)

Example 2 with SortParam

use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.

the class TaskErrorsTabPanel method initLayoutNew.

private void initLayoutNew() {
    var provider = new SelectableBeanContainerDataProvider<OperationExecutionType>(this, Model.of(), null, true) {

        @Override
        protected String getDefaultSortParam() {
            return TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP;
        }

        @Override
        protected SortOrder getDefaultSortOrder() {
            return SortOrder.DESCENDING;
        }

        @Override
        public SelectableBean<OperationExecutionType> createDataObjectWrapper(OperationExecutionType obj) {
            return new TaskErrorSelectableBeanImpl(obj);
        }

        @Override
        public ObjectQuery getQuery() {
            return createContentQuery(getModelObject().getOid(), getPageBase());
        }

        @NotNull
        @Override
        protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
            if (sortParam != null && sortParam.getProperty() != null) {
                OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                ItemPath ordering;
                if (sortParam.getProperty().equals(TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP)) {
                    ordering = ItemPath.create(OperationExecutionType.F_TIMESTAMP);
                } else if (sortParam.getProperty().equals("name")) {
                    // TODO why is this "name" and not TaskErrorSelectableBeanImpl.F_OBJECT_REF_NAME?
                    ordering = ItemPath.create(PrismConstants.T_PARENT, ObjectType.F_NAME);
                } else {
                    // TODO this is actually not used
                    ordering = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
                }
                return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ordering, order));
            } else {
                return Collections.emptyList();
            }
        }

        @Override
        public Class<OperationExecutionType> getType() {
            return OperationExecutionType.class;
        }
    };
    BoxedTablePanel<?> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumns());
    table.setOutputMarkupId(true);
    add(table);
}
Also used : QName(javax.xml.namespace.QName) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) TaskErrorSelectableBeanImpl(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl) OperationExecutionType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationExecutionType) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with SortParam

use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.

the class TaskErrorsPanel method initLayoutNew.

private void initLayoutNew() {
    var provider = new SelectableBeanContainerDataProvider<OperationExecutionType>(this, Model.of(), null, true) {

        @Override
        protected String getDefaultSortParam() {
            return TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP;
        }

        @Override
        protected SortOrder getDefaultSortOrder() {
            return SortOrder.DESCENDING;
        }

        @Override
        public SelectableBean<OperationExecutionType> createDataObjectWrapper(OperationExecutionType obj) {
            return new TaskErrorSelectableBeanImpl(obj);
        }

        @Override
        public ObjectQuery getQuery() {
            return createContentQuery(getObjectWrapper().getOid(), getPageBase());
        }

        @NotNull
        @Override
        protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
            if (sortParam != null && sortParam.getProperty() != null) {
                OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                ItemPath ordering;
                if (sortParam.getProperty().equals(TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP)) {
                    ordering = ItemPath.create(OperationExecutionType.F_TIMESTAMP);
                } else if (sortParam.getProperty().equals("name")) {
                    // TODO why is this "name" and not TaskErrorSelectableBeanImplNew.F_OBJECT_REF_NAME?
                    ordering = ItemPath.create(PrismConstants.T_PARENT, ObjectType.F_NAME);
                } else {
                    // TODO this is actually not used
                    ordering = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
                }
                return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ordering, order));
            } else {
                return Collections.emptyList();
            }
        }

        @Override
        public Class<OperationExecutionType> getType() {
            return OperationExecutionType.class;
        }
    };
    BoxedTablePanel<?> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsNew());
    table.setOutputMarkupId(true);
    add(table);
}
Also used : QName(javax.xml.namespace.QName) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) TaskErrorSelectableBeanImpl(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with SortParam

use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam 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);
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) Task(com.evolveum.midpoint.task.api.Task) GuiObjectColumnType(com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectColumnType) AuditLogStorage(com.evolveum.midpoint.web.session.AuditLogStorage) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StringValue(org.apache.wicket.util.string.StringValue) Component(org.apache.wicket.Component) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) LocalDate(java.time.LocalDate) CsvDownloadButtonPanel(com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 5 with SortParam

use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.

the class ContainerableListPanel method setDefaultSorting.

protected void setDefaultSorting(ISelectableDataProvider<C, PO> provider) {
    if (provider instanceof SortableDataProvider && isCollectionViewPanel() && getObjectCollectionView().getPaging() != null && getObjectCollectionView().getPaging().getOrderBy() != null) {
        PagingType paging = getObjectCollectionView().getPaging();
        boolean ascending = !OrderDirectionType.DESCENDING.equals(paging.getOrderDirection());
        ItemPath orderBy = paging.getOrderBy().getItemPath();
        ItemName name = orderBy.lastName();
        if (name == null) {
            return;
        }
        ((SortableDataProvider) provider).setSort(new SortParam(name.getLocalPart(), ascending));
    }
}
Also used : PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) ItemName(com.evolveum.midpoint.prism.path.ItemName) SortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam)

Aggregations

SortParam (org.apache.wicket.extensions.markup.html.repeater.util.SortParam)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)6 OrderDirection (com.evolveum.midpoint.prism.query.OrderDirection)6 QName (javax.xml.namespace.QName)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)4 SelectableBeanContainerDataProvider (com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 SelectableBeanObjectDataProvider (com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 TaskErrorSelectableBeanImpl (com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl)2 TaskErrorSelectableBeanImplOld (com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImplOld)2 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)2 Component (org.apache.wicket.Component)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IModel (org.apache.wicket.model.IModel)2 CsvDownloadButtonPanel (com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel)1