Search in sources :

Example 1 with AbstractRoleCompositedSearchItem

use of com.evolveum.midpoint.web.page.admin.roles.AbstractRoleCompositedSearchItem in project midpoint by Evolveum.

the class Search method createQueryFromDefaultItems.

private ObjectQuery createQueryFromDefaultItems(PageBase pageBase, VariablesMap variables) {
    List<SearchItem> specialItems = getSpecialItems();
    if (specialItems.isEmpty()) {
        if (compositedSpecialItems == null) {
            return null;
        }
    }
    List<ObjectFilter> conditions = new ArrayList<>();
    if (compositedSpecialItems instanceof AbstractRoleCompositedSearchItem) {
        ObjectFilter filter = ((AbstractRoleCompositedSearchItem) compositedSpecialItems).createFilter(pageBase, variables);
        if (filter != null) {
            conditions.add(filter);
        }
    }
    for (SearchItem item : specialItems) {
        if (item.isApplyFilter()) {
            if (item instanceof SpecialSearchItem) {
                ObjectFilter filter = ((SpecialSearchItem) item).createFilter(pageBase, variables);
                if (filter != null) {
                    conditions.add(filter);
                }
            }
            if (item instanceof PropertySearchItem) {
                PropertySearchItem propertyItem = (PropertySearchItem) item;
                ObjectFilter filter = propertyItem.transformToFilter();
                if (filter == null) {
                    filter = createFilterForSearchItem(propertyItem, pageBase.getPrismContext());
                }
                if (filter != null) {
                    conditions.add(filter);
                }
            }
        }
    }
    ObjectQuery query;
    if (getTypeClass() != null) {
        query = pageBase.getPrismContext().queryFor(getTypeClass()).build();
    } else {
        query = pageBase.getPrismContext().queryFactory().createQuery();
    }
    switch(conditions.size()) {
        case 0:
            query = null;
            break;
        default:
            for (ObjectFilter filter : conditions) {
                query.addFilter(filter);
            }
    }
    return query;
}
Also used : AbstractRoleCompositedSearchItem(com.evolveum.midpoint.web.page.admin.roles.AbstractRoleCompositedSearchItem) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AbstractRoleCompositedSearchItem(com.evolveum.midpoint.web.page.admin.roles.AbstractRoleCompositedSearchItem)

Aggregations

ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 AbstractRoleCompositedSearchItem (com.evolveum.midpoint.web.page.admin.roles.AbstractRoleCompositedSearchItem)1 ArrayList (java.util.ArrayList)1