Search in sources :

Example 1 with PageReport

use of com.evolveum.midpoint.gui.impl.page.admin.report.PageReport 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)

Aggregations

MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 PageReport (com.evolveum.midpoint.gui.impl.page.admin.report.PageReport)1 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)1