Search in sources :

Example 6 with SessionStorage

use of com.evolveum.midpoint.web.session.SessionStorage 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

SessionStorage (com.evolveum.midpoint.web.session.SessionStorage)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 RepositoryQueryDiagRequest (com.evolveum.midpoint.schema.RepositoryQueryDiagRequest)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxTabbedPanel (com.evolveum.midpoint.web.component.AjaxTabbedPanel)1 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)1 Search (com.evolveum.midpoint.web.component.search.Search)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 RepoQueryDto (com.evolveum.midpoint.web.page.admin.configuration.dto.RepoQueryDto)1 MidPointAuthWebSession (com.evolveum.midpoint.web.security.MidPointAuthWebSession)1