Search in sources :

Example 6 with QueryFactory

use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.

the class PageAuthenticationBase method createDynamicFormQuery.

protected ObjectQuery createDynamicFormQuery() {
    DynamicFormPanel<UserType> userDynamicPanel = getDynamicForm();
    List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
    PrismObject<UserType> user;
    try {
        user = userDynamicPanel.getObject();
    } catch (SchemaException e1) {
        getSession().error(getString("pageForgetPassword.message.usernotfound"));
        throw new RestartResponseException(PageForgotPassword.class);
    }
    List<EqualFilter> filters = new ArrayList<>();
    QueryFactory queryFactory = getPrismContext().queryFactory();
    for (ItemPath path : filledItems) {
        PrismProperty<?> property = user.findProperty(path);
        EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
        filter.setValue(property.getAnyValue().clone());
        filters.add(filter);
    }
    return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ArrayList(java.util.ArrayList) PageForgotPassword(com.evolveum.midpoint.web.page.forgetpassword.PageForgotPassword) RestartResponseException(org.apache.wicket.RestartResponseException) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) ArrayList(java.util.ArrayList) List(java.util.List) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 7 with QueryFactory

use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.

the class PageForgotPassword method createDynamicFormQuery.

private ObjectQuery createDynamicFormQuery(Form form) {
    DynamicFormPanel<UserType> userDynamicPanel = (DynamicFormPanel<UserType>) form.get(createComponentPath(ID_DYNAMIC_LAYOUT, ID_DYNAMIC_FORM));
    List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
    PrismObject<UserType> user;
    try {
        user = userDynamicPanel.getObject();
    } catch (SchemaException e1) {
        getSession().error(getString("pageForgetPassword.message.usernotfound"));
        throw new RestartResponseException(PageForgotPassword.class);
    }
    List<EqualFilter> filters = new ArrayList<>();
    QueryFactory queryFactory = getPrismContext().queryFactory();
    for (ItemPath path : filledItems) {
        PrismProperty<?> property = user.findProperty(path);
        EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
        filter.setValue(property.getAnyValue().clone());
        filters.add(filter);
    }
    return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ArrayList(java.util.ArrayList) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) RestartResponseException(org.apache.wicket.RestartResponseException) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) List(java.util.List) ArrayList(java.util.ArrayList) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 8 with QueryFactory

use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.

the class FocusPersonasTabPanel method loadModel.

private LoadableModel<List<PrismObject<FocusType>>> loadModel() {
    return new LoadableModel<List<PrismObject<FocusType>>>(false) {

        @Override
        protected List<PrismObject<FocusType>> load() {
            List<String> personaOidsList = getPersonasOidsList();
            List<PrismObject<FocusType>> personasList = new ArrayList<>();
            if (personaOidsList.size() > 0) {
                QueryFactory factory = getPrismContext().queryFactory();
                ObjectQuery query = factory.createQuery(factory.createInOid(personaOidsList));
                OperationResult result = new OperationResult(OPERATION_SEARCH_PERSONAS_OBJECTS);
                personasList = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
            }
            return personasList;
        }
    };
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 9 with QueryFactory

use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.

the class CompleteQuery method or.

/**
 * Composes complete queries into single "OR" query. Requires compatible paging and options.
 * (Currently no paging nor options is allowed.)
 */
@NotNull
public static CompleteQuery<?> or(List<CompleteQuery<?>> completeQueries, PrismContext prismContext) {
    QueryFactory queryFactory = prismContext.queryFactory();
    Class<? extends ObjectType> commonType = getCommonAncestor(completeQueries);
    List<ObjectFilter> disjuncts = new ArrayList<>();
    for (CompleteQuery<?> completeQuery : completeQueries) {
        if (CollectionUtils.isNotEmpty(completeQuery.options)) {
            throw new UnsupportedOperationException("Query options are not supported here: " + completeQuery.options);
        }
        ObjectQuery query = completeQuery.query;
        if (query != null && query.getPaging() != null) {
            throw new UnsupportedOperationException("Query paging is not supported here: " + query.getPaging());
        }
        ObjectFilter filter = query != null ? query.getFilter() : null;
        Class<?> type = completeQuery.type;
        if (type.equals(commonType)) {
            if (filter != null) {
                disjuncts.add(filter);
            }
        } else {
            QName typeName = prismContext.getSchemaRegistry().determineTypeForClassRequired(type);
            disjuncts.add(queryFactory.createType(typeName, filter));
        }
    }
    ObjectQuery orQuery = queryFactory.createQuery(queryFactory.createOrOptimized(disjuncts));
    return new CompleteQuery<>(commonType, orQuery, null);
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with QueryFactory

use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.

the class DeleteRepositoryAction method deleteByOid.

private void deleteByOid() throws SchemaException {
    QueryFactory queryFactory = context.getPrismContext().queryFactory();
    InOidFilter filter = queryFactory.createInOid(options.getOid());
    ObjectQuery query = queryFactory.createQuery(filter);
    deleteByFilter(query);
}
Also used : InOidFilter(com.evolveum.midpoint.prism.query.InOidFilter) QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

QueryFactory (com.evolveum.midpoint.prism.query.QueryFactory)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 ArrayList (java.util.ArrayList)6 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 EqualFilter (com.evolveum.midpoint.prism.query.EqualFilter)2 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)2 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 List (java.util.List)2 QName (javax.xml.namespace.QName)2 InitialDataImport (com.evolveum.midpoint.init.InitialDataImport)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 InOidFilter (com.evolveum.midpoint.prism.query.InOidFilter)1 NotFilter (com.evolveum.midpoint.prism.query.NotFilter)1 TypeFilter (com.evolveum.midpoint.prism.query.TypeFilter)1