Search in sources :

Example 1 with PageStorage

use of com.evolveum.midpoint.web.session.PageStorage in project midpoint by Evolveum.

the class ObjectListPanel method createTable.

private BoxedTablePanel<SelectableBean<O>> createTable() {
    List<IColumn<SelectableBean<O>, String>> columns;
    if (isCustomColumnsListConfigured()) {
        columns = initCustomColumns();
    } else {
        columns = initColumns();
    }
    BaseSortableDataProvider<SelectableBean<O>> provider = initProvider();
    BoxedTablePanel<SelectableBean<O>> table = new BoxedTablePanel<SelectableBean<O>>(ID_TABLE, provider, columns, tableId, tableId == null ? 10 : parentPage.getSessionStorage().getUserProfile().getPagingSize(tableId)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return initSearch(headerId);
        }

        @Override
        public String getAdditionalBoxCssClasses() {
            return ObjectListPanel.this.getAdditionalBoxCssClasses();
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            WebMarkupContainer bar = ObjectListPanel.this.createTableButtonToolbar(id);
            return bar != null ? bar : super.createButtonToolbar(id);
        }
    };
    table.setOutputMarkupId(true);
    String storageKey = getStorageKey();
    if (StringUtils.isNotEmpty(storageKey)) {
        PageStorage storage = getPageStorage(storageKey);
        if (storage != null) {
            table.setCurrentPage(storage.getPaging());
        }
    }
    return table;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 2 with PageStorage

use of com.evolveum.midpoint.web.session.PageStorage in project midpoint by Evolveum.

the class PageUsers method initSearch.

private void initSearch(String text) {
    PageStorage storage = getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_USERS);
    if (storage == null) {
        storage = getSessionStorage().initPageStorage(SessionStorage.KEY_USERS);
    }
    Search search = SearchFactory.createSearch(UserType.class, this);
    if (SearchBoxModeType.FULLTEXT.equals(search.getSearchType())) {
        search.setFullText(text);
    } else if (search.getItems() != null && search.getItems().size() > 0) {
        SearchItem searchItem = search.getItems().get(0);
        searchItem.getValues().add(new SearchValue<>(text));
    }
    storage.setSearch(search);
    getSessionStorage().getPageStorageMap().put(SessionStorage.KEY_USERS, storage);
}
Also used : Search(com.evolveum.midpoint.web.component.search.Search) SearchValue(com.evolveum.midpoint.web.component.search.SearchValue) PageStorage(com.evolveum.midpoint.web.session.PageStorage) SearchItem(com.evolveum.midpoint.web.component.search.SearchItem)

Example 3 with PageStorage

use of com.evolveum.midpoint.web.session.PageStorage in project midpoint by Evolveum.

the class ContainerableListPanel method createSearchModel.

protected LoadableDetachableModel<Search<C>> createSearchModel() {
    return new LoadableDetachableModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Search<C> load() {
            Search<C> newSearch = createSearch(getType());
            Search<C> search = null;
            PageStorage storage = getPageStorage();
            String searchByName = getSearchByNameParameterValue();
            if (storage != null && searchByName == null) {
                // do NOT use storage when using name search (e.g. from dashboard)
                search = storage.getSearch();
            }
            if (search == null || (!SearchBoxModeType.ADVANCED.equals(search.getSearchType()) && !search.getAllDefinitions().containsAll(newSearch.getAllDefinitions())) || search.isTypeChanged()) {
                search = newSearch;
                search.searchWasReload();
            }
            if (searchByName != null) {
                if (SearchBoxModeType.FULLTEXT.equals(search.getSearchType())) {
                    search.setFullText(searchByName);
                } else {
                    for (PropertySearchItem<String> item : search.getPropertyItems()) {
                        if (ItemPath.create(ObjectType.F_NAME).equivalent(item.getPath())) {
                            item.setValue(new SearchValue<>(searchByName));
                        }
                    }
                }
            }
            if (isCollectionViewPanel()) {
                CompiledObjectCollectionView view = getObjectCollectionView();
                search.setCollectionSearchItem(new ObjectCollectionSearchItem(search, view));
                search.setCollectionItemVisible(isCollectionViewPanelForWidget());
                if (storage != null && view.getPaging() != null) {
                    ObjectPaging paging = ObjectQueryUtil.convertToObjectPaging(view.getPaging(), getPrismContext());
                    if (storage.getPaging() == null) {
                        storage.setPaging(paging);
                    }
                    if (getTableId() != null && paging.getMaxSize() != null && !getPageBase().getSessionStorage().getUserProfile().isExistPagingSize(getTableId())) {
                        getPageBase().getSessionStorage().getUserProfile().setPagingSize(getTableId(), paging.getMaxSize());
                    }
                }
            }
            if (storage != null) {
                storage.setSearch(search);
            }
            return search;
        }
    };
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 4 with PageStorage

use of com.evolveum.midpoint.web.session.PageStorage in project midpoint by Evolveum.

the class ContainerableListPanel method saveSearchModel.

protected void saveSearchModel(ObjectPaging paging) {
    PageStorage storage = getPageStorage();
    if (storage != null) {
        storage.setSearch(searchModel.getObject());
        storage.setPaging(paging);
    }
}
Also used : PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 5 with PageStorage

use of com.evolveum.midpoint.web.session.PageStorage in project midpoint by Evolveum.

the class FocusProjectionsPanel method initLayout.

protected void initLayout() {
    IModel<Integer> deadShadows = new ReadOnlyModel<>(this::countDeadShadows);
    Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
    label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
    add(label);
    MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class, getPanelConfiguration()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
            return new ProjectionsListProvider(FocusProjectionsPanel.this, getSearchModel(), loadShadowModel()) {

                @Override
                protected PageStorage getPageStorage() {
                    PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    if (storage == null) {
                        storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    }
                    return storage;
                }
            };
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            List<QName> supportedTypes = Arrays.asList(ResourceType.COMPLEX_TYPE);
            PageBase pageBase = FocusProjectionsPanel.this.getPageBase();
            ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
                    FocusProjectionsPanel.this.addSelectedAccountPerformed(target, selected);
                    target.add(getPageBase().getFeedbackPanel());
                }
            };
            resourceSelectionPanel.setOutputMarkupId(true);
            pageBase.showMainPopup(resourceSelectionPanel, target);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            PrismObjectDefinition<F> def = FocusProjectionsPanel.this.getObjectWrapperModel().getObject().getObject().getDefinition();
            PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
            return (ref.canRead() && ref.canAdd());
        }

        @Override
        protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
            return null;
        }

        @Override
        protected TableId getTableId() {
            return TableId.FOCUS_PROJECTION_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
            return initBasicColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return createShadowMenu();
        }

        @Override
        public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
            loadShadowIfNeeded(rowModel, target);
            if (listItems != null) {
                listItems.forEach(value -> {
                    if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
                        loadFullShadow((PrismObjectValueWrapper) value, target);
                    }
                });
            }
            super.editItemPerformed(target, rowModel, listItems);
        }

        @Override
        protected Search createSearch(Class<ShadowType> type) {
            Search search = super.createSearch(type);
            PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
            if (defaultDeadItem != null) {
                defaultDeadItem.setVisible(false);
            }
            addDeadSearchItem(search);
            return search;
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
            return defs;
        }

        @Override
        protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
            return FocusProjectionsPanel.this.getMultivalueContainerDetailsPanel(item);
        }
    };
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ProjectionsListProvider(com.evolveum.midpoint.web.component.util.ProjectionsListProvider) List(java.util.List) ArrayList(java.util.ArrayList) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

PageStorage (com.evolveum.midpoint.web.session.PageStorage)17 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 Search (com.evolveum.midpoint.web.component.search.Search)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 QName (javax.xml.namespace.QName)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 IModel (org.apache.wicket.model.IModel)3 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2