Search in sources :

Example 1 with ModelInteractionService

use of com.evolveum.midpoint.model.api.ModelInteractionService in project midpoint by Evolveum.

the class ProgressReporter method executeChanges.

/**
     * Executes changes on behalf of the parent page. By default, changes are executed asynchronously (in
     * a separate thread). However, when set in the midpoint configuration, changes are executed synchronously.
     *
     * @param deltas Deltas to be executed.
     * @param options Model execution options.
     * @param task Task in context of which the changes have to be executed.
     * @param result Operation result.
     * @param target AjaxRequestTarget into which any synchronous changes are signalized.
     */
public void executeChanges(final Collection<ObjectDelta<? extends ObjectType>> deltas, final boolean previewOnly, final ModelExecuteOptions options, final Task task, final OperationResult result, AjaxRequestTarget target) {
    parentPage.startProcessing(target, result);
    ModelService modelService = parentPage.getModelService();
    ModelInteractionService modelInteractionService = parentPage.getModelInteractionService();
    if (asynchronousExecution) {
        executeChangesAsync(deltas, previewOnly, options, task, result, target, modelService, modelInteractionService);
    } else {
        executeChangesSync(deltas, previewOnly, options, task, result, target, modelService, modelInteractionService);
    }
}
Also used : ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) ModelService(com.evolveum.midpoint.model.api.ModelService)

Example 2 with ModelInteractionService

use of com.evolveum.midpoint.model.api.ModelInteractionService in project midpoint by Evolveum.

the class MultipleAssignmentSelectorPanel method getAssignableRolesFilter.

private ObjectFilter getAssignableRolesFilter() {
    LOGGER.debug("Loading roles which the current user has right to assign");
    OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNABLE_ROLES);
    ObjectFilter filter = null;
    try {
        PageBase pb = getPageBase();
        ModelInteractionService mis = pb.getModelInteractionService();
        RoleSelectionSpecification roleSpec = mis.getAssignableRoleSpecification(focus, 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()) {
        getPageBase().showResult(result);
    }
    return filter;
}
Also used : ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 3 with ModelInteractionService

use of com.evolveum.midpoint.model.api.ModelInteractionService 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 4 with ModelInteractionService

use of com.evolveum.midpoint.model.api.ModelInteractionService in project midpoint by Evolveum.

the class AssignmentCatalogPanel method addAssignableRolesFilter.

private void addAssignableRolesFilter(ObjectQuery query) {
    ObjectFilter filter = null;
    LOGGER.debug("Loading roles which the current user has right to assign");
    OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNABLE_ROLES);
    try {
        ModelInteractionService mis = pageBase.getModelInteractionService();
        RoleSelectionSpecification roleSpec = mis.getAssignableRoleSpecification(getTargetUser(), 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()) {
        pageBase.showResult(result);
    }
    if (query == null) {
        query = new ObjectQuery();
    }
    query.addFilter(filter);
}
Also used : ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

ModelInteractionService (com.evolveum.midpoint.model.api.ModelInteractionService)4 RoleSelectionSpecification (com.evolveum.midpoint.model.api.RoleSelectionSpecification)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 ModelService (com.evolveum.midpoint.model.api.ModelService)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1