Search in sources :

Example 1 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ContainerableListPanel method getObjectCollectionView.

protected CompiledObjectCollectionView getObjectCollectionView() {
    CompiledObjectCollectionView containerPanelCollectionView = getCompiledCollectionViewFromPanelConfiguration();
    if (containerPanelCollectionView != null) {
        return containerPanelCollectionView;
    }
    CompiledObjectCollectionView view = getWidgetCollectionView();
    if (view != null) {
        return view;
    }
    String collectionName = getCollectionNameParameterValue().toString();
    return getPageBase().getCompiledGuiProfile().findObjectCollectionView(WebComponentUtil.containerClassToQName(getPageBase().getPrismContext(), getType()), collectionName);
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView 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 3 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ContainerableListPanel method createReportPerformed.

protected void createReportPerformed(AjaxRequestTarget target) {
    PrismContext prismContext = getPageBase().getPrismContext();
    PrismObjectDefinition<ReportType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(ReportType.COMPLEX_TYPE);
    PrismObject<ReportType> obj;
    try {
        obj = def.instantiate();
    } catch (SchemaException e) {
        LOGGER.error("Couldn't instantiate new report", e);
        getPageBase().error(getString("MainObjectListPanel.message.error.instantiateNewReport"));
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    ReportType report = obj.asObjectable();
    ObjectCollectionReportEngineConfigurationType objectCollection = new ObjectCollectionReportEngineConfigurationType();
    CompiledObjectCollectionView view = getObjectCollectionView();
    CollectionRefSpecificationType collection = new CollectionRefSpecificationType();
    objectCollection.setUseOnlyReportView(true);
    if (view != null) {
        objectCollection.setView(view.toGuiObjectListViewType());
        if (view.getCollection() != null && view.getCollection().getCollectionRef() != null) {
            if (!QNameUtil.match(view.getCollection().getCollectionRef().getType(), ArchetypeType.COMPLEX_TYPE)) {
                collection.setBaseCollectionRef(view.getCollection());
            } else {
                OperationResult result = new OperationResult(MainObjectListPanel.class.getSimpleName() + "." + "evaluateExpressionsInFilter");
                CollectionRefSpecificationType baseCollection = new CollectionRefSpecificationType();
                try {
                    baseCollection.setFilter(getPageBase().getQueryConverter().createSearchFilterType(WebComponentUtil.evaluateExpressionsInFilter(view.getFilter(), result, getPageBase())));
                    collection.setBaseCollectionRef(baseCollection);
                } catch (SchemaException e) {
                    LOGGER.error("Couldn't create filter for archetype");
                    getPageBase().error(getString("MainObjectListPanel.message.error.createArchetypeFilter"));
                    target.add(getPageBase().getFeedbackPanel());
                }
            }
        }
    } else {
        objectCollection.setView(getDefaultView());
    }
    SearchFilterType searchFilter = null;
    ObjectQuery query = getSearchModel().getObject().createObjectQuery(getPageBase());
    if (query != null) {
        ObjectFilter filter = query.getFilter();
        try {
            searchFilter = getPageBase().getPrismContext().getQueryConverter().createSearchFilterType(filter);
        } catch (Exception e) {
            LOGGER.error("Couldn't create filter from search panel", e);
            getPageBase().error(getString("ExportingFilterTabPanel.message.error.serializeFilterFromSearch"));
        }
    }
    if (searchFilter != null) {
        collection.setFilter(searchFilter);
    } else {
        try {
            SearchFilterType allFilter = prismContext.getQueryConverter().createSearchFilterType(prismContext.queryFactory().createAll());
            collection.setFilter(allFilter);
        } catch (SchemaException e) {
            LOGGER.error("Couldn't create all filter", e);
            getPageBase().error(getString("MainObjectListPanel.message.error.createAllFilter"));
            target.add(getPageBase().getFeedbackPanel());
            return;
        }
    }
    objectCollection.setCollection(collection);
    report.setObjectCollection(objectCollection);
    report.getAssignment().add(ObjectTypeUtil.createAssignmentTo(SystemObjectsType.ARCHETYPE_COLLECTION_REPORT.value(), ObjectTypes.ARCHETYPE, prismContext));
    report.getArchetypeRef().add(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_COLLECTION_REPORT.value(), ObjectTypes.ARCHETYPE));
    PageReport pageReport = new PageReport(report.asPrismObject());
    getPageBase().navigateToNext(pageReport);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) PageReport(com.evolveum.midpoint.gui.impl.page.admin.report.PageReport) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 4 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ContainerableListPanel method getAutoRefreshInterval.

protected int getAutoRefreshInterval() {
    if (isCollectionViewPanel()) {
        CompiledObjectCollectionView view = getObjectCollectionView();
        if (view == null) {
            return 0;
        }
        Integer autoRefreshInterval = view.getRefreshInterval();
        return Objects.requireNonNullElse(autoRefreshInterval, 0);
    }
    return 0;
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)

Example 5 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ContainerableListPanel method getCompiledCollectionViewFromPanelConfiguration.

private CompiledObjectCollectionView getCompiledCollectionViewFromPanelConfiguration() {
    if (compiledCollectionViewFromPanelConfiguration != null) {
        return compiledCollectionViewFromPanelConfiguration;
    }
    if (config == null) {
        return null;
    }
    GuiObjectListViewType listViewType = config.getListView();
    if (listViewType == null) {
        return null;
    }
    Task task = getPageBase().createSimpleTask("Compile collection");
    OperationResult result = task.getResult();
    try {
        compiledCollectionViewFromPanelConfiguration = new CompiledObjectCollectionView();
        getPageBase().getModelInteractionService().compileView(compiledCollectionViewFromPanelConfiguration, listViewType, task, result);
    } catch (Throwable e) {
        LOGGER.error("Cannot compile object collection view for panel configuration {}. Reason: {}", config, e.getMessage(), e);
        result.recordFatalError("Cannot compile object collection view for panel configuration " + config + ". Reason: " + e.getMessage(), e);
        getPageBase().showResult(result);
    }
    return compiledCollectionViewFromPanelConfiguration;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)41 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)13 WebPage (org.apache.wicket.markup.html.WebPage)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)6 ArrayList (java.util.ArrayList)6 MultiCompositedButtonPanel (com.evolveum.midpoint.web.component.MultiCompositedButtonPanel)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 MultiFunctinalButtonDto (com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Form (org.apache.wicket.markup.html.form.Form)3