Search in sources :

Example 6 with PageStorage

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

the class ObjectListPanel method saveSearchModel.

private void saveSearchModel() {
    String storageKey = getStorageKey();
    if (StringUtils.isNotEmpty(storageKey)) {
        PageStorage storage = getPageStorage(storageKey);
        if (storage != null) {
            storage.setSearch(searchModel.getObject());
            storage.setPaging(null);
        }
    }
}
Also used : PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 7 with PageStorage

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

the class ObjectListPanel method initProvider.

protected BaseSortableDataProvider<SelectableBean<O>> initProvider() {
    Set<O> selectedObjectsSet = selectedObjects == null ? null : new HashSet<O>(selectedObjects);
    SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(parentPage, type, selectedObjectsSet) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            String storageKey = getStorageKey();
            if (StringUtils.isNotEmpty(storageKey)) {
                PageStorage storage = getPageStorage(storageKey);
                if (storage != null) {
                    storage.setPaging(paging);
                }
            }
        }

        @Override
        public SelectableBean<O> createDataObjectWrapper(O obj) {
            SelectableBean<O> bean = super.createDataObjectWrapper(obj);
            List<InlineMenuItem> inlineMenu = createInlineMenu();
            if (inlineMenu != null) {
                bean.getMenuItems().addAll(inlineMenu);
            }
            return bean;
        }
    };
    if (options == null) {
        if (ResourceType.class.equals(type)) {
            options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
        }
    } else {
        if (ResourceType.class.equals(type)) {
            GetOperationOptions root = SelectorOptions.findRootOptions(options);
            root.setNoFetch(Boolean.TRUE);
        }
        provider.setOptions(options);
    }
    provider.setQuery(getQuery());
    return provider;
}
Also used : SelectableBeanObjectDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 8 with PageStorage

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

the class PageRepositoryQuery method useInObjectListPerformed.

private void useInObjectListPerformed(AjaxRequestTarget target) {
    final RepoQueryDto dto = model.getObject();
    String queryText = dto.getMidPointQuery();
    if (StringUtils.isBlank(queryText)) {
        queryText = "<query/>";
    }
    RepositoryQueryDiagRequest request = new RepositoryQueryDiagRequest();
    Task task = createSimpleTask(OPERATION_CHECK_QUERY);
    OperationResult result = task.getResult();
    try {
        // just to parse the query
        updateRequestWithMidpointQuery(request, dto.getObjectType(), queryText, task, result);
        ObjectFilter parsedFilter = request.getQuery().getFilter();
        String filterAsString;
        if (parsedFilter != null) {
            SearchFilterType filterType = QueryConvertor.createSearchFilterType(parsedFilter, getPrismContext());
            filterAsString = getPrismContext().xmlSerializer().serializeRealValue(filterType, SchemaConstantsGenerated.Q_FILTER);
        // TODO remove extra xmlns from serialized value
        } else {
            filterAsString = "";
        }
        Class<? extends PageBase> listPageClass = WebComponentUtil.getObjectListPage(request.getType());
        String storageKey = listPageClass != null ? WebComponentUtil.getStorageKeyForPage(listPageClass) : null;
        if (storageKey == null) {
            // shouldn't occur because of button visibility
            error("No page to redirect for " + dto.getObjectType());
            target.add(getFeedbackPanel());
            return;
        }
        Search search = SearchFactory.createSearch(request.getType(), this);
        search.setAdvancedQuery(filterAsString);
        search.setShowAdvanced(true);
        if (!search.isAdvancedQueryValid(getPrismContext())) {
            // shouldn't occur because the query was already parsed
            error("Query is not valid: " + search.getAdvancedError());
            target.add(getFeedbackPanel());
            return;
        }
        SessionStorage sessionStorage = ((MidPointAuthWebSession) getSession()).getSessionStorage();
        PageStorage storage = sessionStorage.getPageStorageMap().get(storageKey);
        if (storage == null) {
            storage = sessionStorage.initPageStorage(storageKey);
        }
        storage.setSearch(search);
        setResponsePage(listPageClass);
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't parse query: " + e.getMessage(), e);
        showResult(result);
        target.add(this);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RepositoryQueryDiagRequest(com.evolveum.midpoint.schema.RepositoryQueryDiagRequest) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) MidPointAuthWebSession(com.evolveum.midpoint.web.security.MidPointAuthWebSession) RepoQueryDto(com.evolveum.midpoint.web.page.admin.configuration.dto.RepoQueryDto) Search(com.evolveum.midpoint.web.component.search.Search) CommonException(com.evolveum.midpoint.util.exception.CommonException) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Aggregations

PageStorage (com.evolveum.midpoint.web.session.PageStorage)8 Search (com.evolveum.midpoint.web.component.search.Search)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 RepositoryQueryDiagRequest (com.evolveum.midpoint.schema.RepositoryQueryDiagRequest)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 SelectableBeanObjectDataProvider (com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider)1 Table (com.evolveum.midpoint.web.component.data.Table)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 SearchItem (com.evolveum.midpoint.web.component.search.SearchItem)1 SearchValue (com.evolveum.midpoint.web.component.search.SearchValue)1 RepoQueryDto (com.evolveum.midpoint.web.page.admin.configuration.dto.RepoQueryDto)1 MidPointAuthWebSession (com.evolveum.midpoint.web.security.MidPointAuthWebSession)1