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);
}
}
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations