Search in sources :

Example 1 with PolicyConstraintsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType in project midpoint by Evolveum.

the class FocusProcessor method triggerRule.

private <F extends FocusType> void triggerRule(LensFocusContext<F> focusContext, EvaluatedPolicyRule policyRule) throws PolicyViolationException, SchemaException {
    PolicyConstraintsType policyConstraints = policyRule.getPolicyConstraints();
    if (policyConstraints == null) {
        return;
    }
    for (ModificationPolicyConstraintType modificationConstraintType : policyConstraints.getModification()) {
        focusContext.addPolicyRule(policyRule);
        if (modificationConstraintMatches(focusContext, policyRule, modificationConstraintType)) {
            EvaluatedPolicyRuleTrigger<?> trigger = new EvaluatedPolicyRuleTrigger<>(PolicyConstraintKindType.MODIFICATION, modificationConstraintType, "Focus " + focusContext.getHumanReadableName() + " was modified");
            focusContext.triggerConstraint(policyRule, trigger);
        }
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) EvaluatedPolicyRuleTrigger(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger) ModificationPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModificationPolicyConstraintType)

Example 2 with PolicyConstraintsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType in project midpoint by Evolveum.

the class RolePolicyPanel method initLayout.

@Override
protected void initLayout() {
    minAssignmentModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            RoleType roleType = role.asObjectable();
            if (roleType.getPolicyConstraints() == null) {
                roleType.setPolicyConstraints(new PolicyConstraintsType());
            }
            return roleType.getPolicyConstraints().getMinAssignees();
        }
    };
    maxAssignmentsModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            RoleType roleType = role.asObjectable();
            if (roleType.getPolicyConstraints() == null) {
                roleType.setPolicyConstraints(new PolicyConstraintsType());
            }
            return roleType.getPolicyConstraints().getMaxAssignees();
        }
    };
    GenericMultiValueLabelEditPanel minAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MIN_ASSIGNMENTS, minAssignmentModel, createStringResource("PageRoleEditor.label.minAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMinAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    minAssignments.setOutputMarkupId(true);
    add(minAssignments);
    GenericMultiValueLabelEditPanel maxAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MAX_ASSIGNMENTS, maxAssignmentsModel, createStringResource("PageRoleEditor.label.maxAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMaxAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    maxAssignments.setOutputMarkupId(true);
    add(maxAssignments);
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultiplicityPolicyPanel(com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel) IModel(org.apache.wicket.model.IModel) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType) List(java.util.List)

Example 3 with PolicyConstraintsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType in project midpoint by Evolveum.

the class PageRole method removeEmptyPolicyConstraints.

/**
	 * Removes empty policy constraints from role. It was created when loading
	 * model (not very good model implementation). MID-2366
	 *
	 * TODO improve
	 *
	 * @param prism
	 */
private void removeEmptyPolicyConstraints(PrismObject<RoleType> prism) {
    RoleType role = prism.asObjectable();
    PolicyConstraintsType pc = role.getPolicyConstraints();
    if (pc == null) {
        return;
    }
    if (pc.getExclusion().isEmpty() && pc.getMinAssignees().isEmpty() && pc.getMaxAssignees().isEmpty()) {
        role.setPolicyConstraints(null);
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)

Example 4 with PolicyConstraintsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType in project midpoint by Evolveum.

the class PageRole method prepareObjectForAdd.

@Override
protected void prepareObjectForAdd(PrismObject<RoleType> focus) throws SchemaException {
    // TODO policyConstraints
    super.prepareObjectForAdd(focus);
    getObjectWrapper().getObjectOld().findOrCreateContainer(RoleType.F_POLICY_CONSTRAINTS);
    ObjectDelta<RoleType> delta = getObjectWrapper().getObjectOld().diff(getObjectWrapper().getObject());
    ContainerDelta<PolicyConstraintsType> policyConstraintsDelta = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS));
    if (policyConstraintsDelta != null) {
        policyConstraintsDelta.applyTo(focus);
        return;
    }
    ContainerDelta maxAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MAX_ASSIGNEES));
    if (maxAssignes != null) {
        maxAssignes.applyTo(focus);
    }
    ContainerDelta minAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MIN_ASSIGNEES));
    if (minAssignes != null) {
        minAssignes.applyTo(focus);
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 5 with PolicyConstraintsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType in project midpoint by Evolveum.

the class PageRole method prepareObjectDeltaForModify.

@Override
protected void prepareObjectDeltaForModify(ObjectDelta<RoleType> focusDelta) throws SchemaException {
    super.prepareObjectDeltaForModify(focusDelta);
    ObjectDelta<RoleType> delta = getObjectWrapper().getObjectOld().diff(getObjectWrapper().getObject());
    ContainerDelta<PolicyConstraintsType> policyConstraintsDelta = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS));
    if (policyConstraintsDelta != null) {
        focusDelta.addModification(policyConstraintsDelta);
        return;
    }
    ContainerDelta maxAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MAX_ASSIGNEES));
    if (maxAssignes != null) {
        focusDelta.addModification(maxAssignes);
    }
    ContainerDelta minAssignes = delta.findContainerDelta(new ItemPath(RoleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_MIN_ASSIGNEES));
    if (minAssignes != null) {
        focusDelta.addModification(minAssignes);
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

PolicyConstraintsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType)6 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)4 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 GenericMultiValueLabelEditPanel (com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel)2 MultiplicityPolicyPanel (com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel)2 MultiplicityPolicyConstraintType (com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType)2 List (java.util.List)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IModel (org.apache.wicket.model.IModel)2 EvaluatedPolicyRuleTrigger (com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger)1 ModificationPolicyConstraintType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModificationPolicyConstraintType)1