Search in sources :

Example 1 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 2 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 3 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)

Example 4 with ObjectQuery

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

the class TreeTablePanel method hasChildren.

private boolean hasChildren(SelectableBean<OrgType> orgToDelete) {
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isChildOf(// TODO what if orgToDelete.getValue()==null
    orgToDelete.getValue().getOid()).build();
    Task task = getPageBase().createSimpleTask(OPERATION_COUNT_CHILDREN);
    OperationResult result = new OperationResult(OPERATION_COUNT_CHILDREN);
    try {
        int count = getPageBase().getModelService().countObjects(ObjectType.class, query, null, task, result);
        return (count > 0);
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | CommunicationException | ExpressionEvaluationException e) {
        LoggingUtils.logUnexpectedException(LOGGER, e.getMessage(), e);
        result.recordFatalError("Could not count members for org " + orgToDelete.getValue(), e);
        return false;
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 5 with ObjectQuery

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

the class OrgTreeProvider method getChildren.

@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
    //    	getAvailableData().clear();
    LOGGER.debug("Loading children for {}", new Object[] { node });
    Iterator<SelectableBean<OrgType>> iterator = null;
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
    node.getValue().getOid()).asc(ObjectType.F_NAME).build();
    OperationResult result = new OperationResult(LOAD_ORG_UNITS);
    try {
        //            Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
        Collection<SelectorOptions<GetOperationOptions>> options = null;
        Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
        List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
        LOGGER.debug("Found {} units.", units.size());
        List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
        for (PrismObject<OrgType> unit : units) {
            SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
            list.add(selectable);
        //                if (getAvailableData().contains(selectable)){
        //                	getAvailableData().remove(selectable);
        //                } 
        //                getAvailableData().add(selectable);
        }
        getAvailableData().addAll(list);
        //            Collections.sort(list);
        iterator = list.iterator();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
        result.recordFatalError("Unable to load org unit", ex);
    } finally {
        result.computeStatus();
    }
    if (WebComponentUtil.showResultInPage(result)) {
        getPageBase().showResult(result);
        throw new RestartResponseException(PageOrgTree.class);
    }
    if (iterator == null) {
        iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
    }
    LOGGER.debug("Finished loading children.");
    return iterator;
}
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) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Aggregations

ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)697 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)453 Test (org.testng.annotations.Test)335 PrismObject (com.evolveum.midpoint.prism.PrismObject)284 Task (com.evolveum.midpoint.task.api.Task)268 QName (javax.xml.namespace.QName)111 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)78 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)76 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)64 ArrayList (java.util.ArrayList)61 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)58 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)53 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)41 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)41 SystemException (com.evolveum.midpoint.util.exception.SystemException)38 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)37 NotNull (org.jetbrains.annotations.NotNull)35 List (java.util.List)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27