Search in sources :

Example 1 with ObjectSearchDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto in project midpoint by Evolveum.

the class ObjectSelectionPanel method clearSearchPerformed.

private void clearSearchPerformed(AjaxRequestTarget target) {
    searchModel.setObject(new ObjectSearchDto());
    TablePanel panel = getTablePanel();
    DataTable table = panel.getDataTable();
    ObjectDataProvider provider = (ObjectDataProvider) table.getDataProvider();
    if (context.getDataProviderQuery() != null) {
        provider.setQuery(context.getDataProviderQuery());
    } else {
        provider.setQuery(null);
    }
    target.add(panel, getSearchForm());
}
Also used : DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 2 with ObjectSearchDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto in project midpoint by Evolveum.

the class ObjectSelectionPanel method initLayout.

public void initLayout(PageBase pageBase) {
    Form searchForm = new Form(ID_SEARCH_FORM);
    searchForm.setOutputMarkupId(true);
    add(searchForm);
    searchForm.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return context.isSearchEnabled();
        }
    });
    BasicSearchPanel<ObjectSearchDto> basicSearch = new BasicSearchPanel<ObjectSearchDto>(ID_BASIC_SEARCH) {

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, ObjectSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.clearSearchPerformed(target);
        }
    };
    searchForm.add(basicSearch);
    add(context.createExtraContentContainer(ID_EXTRA_CONTENT_CONTAINER, this));
    List<IColumn<SelectableBean<ObjectType>, String>> columns = initColumns();
    ObjectDataProvider provider = new ObjectDataProvider(pageBase, this.objectType);
    provider.setQuery(context.getDataProviderQuery());
    provider.setOptions(context.getDataProviderOptions());
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    addOrReplace(table);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("chooseTypeDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            modalWindow.close(ajaxRequestTarget);
        }
    };
    add(cancelButton);
}
Also used : ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) Form(org.apache.wicket.markup.html.form.Form) PropertyModel(org.apache.wicket.model.PropertyModel) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 3 with ObjectSearchDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto in project midpoint by Evolveum.

the class ObjectSelectionPanel method createObjectQuery.

private ObjectQuery createObjectQuery() {
    ObjectSearchDto dto = searchModel.getObject();
    ObjectQuery query = null;
    if (StringUtils.isEmpty(dto.getText())) {
        if (context.getDataProviderQuery() != null) {
            return context.getDataProviderQuery();
        } else {
            return query;
        }
    }
    try {
        PageBase pageBase = WebComponentUtil.getPageBase(this);
        PrismContext prismContext = pageBase.getPrismContext();
        PolyStringNormalizer normalizer = prismContext.getDefaultPolyStringNormalizer();
        String normalized = normalizer.normalize(dto.getText());
        ObjectFilter filter = QueryBuilder.queryFor(objectType, prismContext).item(context.getSearchProperty()).contains(normalized).matchingNorm().buildFilter();
        if (context.getDataProviderQuery() != null) {
            AndFilter and = AndFilter.createAnd(context.getDataProviderQuery().getFilter(), filter);
            query = ObjectQuery.createObjectQuery(and);
        } else {
            query = ObjectQuery.createObjectQuery(filter);
        }
    } catch (Exception e) {
        error(getString("chooseTypeDialog.message.queryError") + " " + e.getMessage());
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create query filter.", e);
    }
    return query;
}
Also used : AndFilter(com.evolveum.midpoint.prism.query.AndFilter) ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) PrismContext(com.evolveum.midpoint.prism.PrismContext) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Aggregations

ObjectSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto)3 ObjectDataProvider (com.evolveum.midpoint.web.component.data.ObjectDataProvider)2 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)1 AndFilter (com.evolveum.midpoint.prism.query.AndFilter)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 BasicSearchPanel (com.evolveum.midpoint.web.component.BasicSearchPanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 DataTable (org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1 Form (org.apache.wicket.markup.html.form.Form)1 PropertyModel (org.apache.wicket.model.PropertyModel)1