Search in sources :

Example 31 with ObjectQuery

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

the class ObjectBrowserPanel method createObjectListPanel.

private ObjectListPanel<O> createObjectListPanel(Class<? extends O> type, final boolean multiselect) {
    PopupObjectListPanel<O> listPanel = new PopupObjectListPanel<O>(ID_TABLE, type, multiselect, parentPage, selectedObjectsList) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSelectPerformed(AjaxRequestTarget target, O object) {
            ObjectBrowserPanel.this.onSelectPerformed(target, object);
        }

        @Override
        protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
            if (queryFilter != null) {
                if (query == null) {
                    query = new ObjectQuery();
                }
                query.addFilter(queryFilter);
            }
            return query;
        }
    };
    listPanel.setOutputMarkupId(true);
    return listPanel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 32 with ObjectQuery

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

the class TypedAssignablePanel method createObjectListPanel.

private PopupObjectListPanel<T> createObjectListPanel(String id, final String countId, final QName type) {
    PopupObjectListPanel<T> listPanel = new PopupObjectListPanel<T>(id, qnameToCompileTimeClass(type), true, getPageBase()) {

        @Override
        protected void onUpdateCheckbox(AjaxRequestTarget target) {
            refreshCounts(target);
        }

        @Override
        protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
            if (type.equals(RoleType.COMPLEX_TYPE)) {
                LOGGER.debug("Loading roles which the current user has right to assign");
                OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNABLE_ROLES);
                ObjectFilter filter = null;
                try {
                    ModelInteractionService mis = parentPage.getModelInteractionService();
                    RoleSelectionSpecification roleSpec = mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), result);
                    filter = roleSpec.getFilter();
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
                    result.recordFatalError("Couldn't load available roles", ex);
                } finally {
                    result.recomputeStatus();
                }
                if (!result.isSuccess() && !result.isHandledError()) {
                    parentPage.showResult(result);
                }
                if (query == null) {
                    query = new ObjectQuery();
                }
                query.addFilter(filter);
            }
            return query;
        }
    };
    listPanel.setOutputMarkupId(true);
    listPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return type.equals(typeModel.getObject());
        }
    });
    return listPanel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 33 with ObjectQuery

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

the class MappingEditorDialog method createPasswordPolicyList.

private List<ObjectReferenceType> createPasswordPolicyList() {
    policyMap.clear();
    OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
    List<PrismObject<ValuePolicyType>> policies = null;
    List<ObjectReferenceType> references = new ArrayList<>();
    try {
        policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't load password policies.", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
    }
    if (policies != null) {
        ObjectReferenceType ref;
        for (PrismObject<ValuePolicyType> policy : policies) {
            policyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
            ref = new ObjectReferenceType();
            ref.setType(ValuePolicyType.COMPLEX_TYPE);
            ref.setOid(policy.getOid());
            references.add(ref);
        }
    }
    return references;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 34 with ObjectQuery

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

the class SynchronizationReactionEditor method createObjectTemplateList.

private List<ObjectReferenceType> createObjectTemplateList() {
    objectTemplateMap.clear();
    OperationResult result = new OperationResult(OPERATION_LOAD_OBJECT_TEMPLATES);
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_OBJECT_TEMPLATES);
    List<PrismObject<ObjectTemplateType>> templates = null;
    List<ObjectReferenceType> references = new ArrayList<>();
    try {
        templates = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't load object templates from repository. ", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object templates from repository", e);
    }
    if (templates != null) {
        ObjectReferenceType ref;
        for (PrismObject<ObjectTemplateType> template : templates) {
            objectTemplateMap.put(template.getOid(), WebComponentUtil.getName(template));
            ref = new ObjectReferenceType();
            ref.setType(ObjectTemplateType.COMPLEX_TYPE);
            ref.setOid(template.getOid());
            references.add(ref);
        }
    }
    return references;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 35 with ObjectQuery

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

the class ResourceCredentialsEditor method createPasswordPolicyList.

private List<ObjectReferenceType> createPasswordPolicyList() {
    passPolicyMap.clear();
    OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
    List<PrismObject<ValuePolicyType>> policies = null;
    List<ObjectReferenceType> references = new ArrayList<>();
    try {
        policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
        result.recomputeStatus();
    } catch (CommonException | RuntimeException e) {
        result.recordFatalError("Couldn't load password policies.", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
    }
    if (policies != null) {
        ObjectReferenceType ref;
        for (PrismObject<ValuePolicyType> policy : policies) {
            passPolicyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
            ref = new ObjectReferenceType();
            ref.setType(ValuePolicyType.COMPLEX_TYPE);
            ref.setOid(policy.getOid());
            references.add(ref);
        }
    }
    return references;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Aggregations

ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)355 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)241 PrismObject (com.evolveum.midpoint.prism.PrismObject)217 Test (org.testng.annotations.Test)159 Task (com.evolveum.midpoint.task.api.Task)150 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)67 QName (javax.xml.namespace.QName)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)50 ArrayList (java.util.ArrayList)50 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)38 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)35 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)33 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)30 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)21 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)18 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)17 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)16