Search in sources :

Example 1 with MultiplicityPolicyConstraintType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType 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 2 with MultiplicityPolicyConstraintType

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

the class RolePolicyPanel method createMultiplicityPolicyLabel.

private IModel<String> createMultiplicityPolicyLabel(final IModel<MultiplicityPolicyConstraintType> model) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            if (model == null || model.getObject() == null || model.getObject().getMultiplicity() == null || model.getObject().getMultiplicity().isEmpty()) {
                return getString("PageRoleEditor.label.assignmentConstraint.placeholder");
            }
            MultiplicityPolicyConstraintType policy = model.getObject();
            sb.append(policy.getMultiplicity());
            if (policy.getEnforcement() != null) {
                sb.append(" (");
                sb.append(policy.getEnforcement());
                sb.append(")");
            }
            return sb.toString();
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType)

Example 3 with MultiplicityPolicyConstraintType

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

the class BaseAbstractRolePanel method createMultiplicityPolicyLabel.

private IModel<String> createMultiplicityPolicyLabel(final IModel<MultiplicityPolicyConstraintType> model) {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            if (model == null || model.getObject() == null || model.getObject().getMultiplicity() == null || model.getObject().getMultiplicity().isEmpty()) {
                return getString("PageRoleEditor.label.assignmentConstraint.placeholder");
            }
            MultiplicityPolicyConstraintType policy = model.getObject();
            sb.append(policy.getMultiplicity());
            if (policy.getEnforcement() != null) {
                sb.append(" (");
                sb.append(policy.getEnforcement());
                sb.append(")");
            }
            return sb.toString();
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType)

Example 4 with MultiplicityPolicyConstraintType

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

the class BaseAbstractRolePanel method initLayout.

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

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

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            if (abstractRole.getPolicyConstraints() == null) {
                abstractRole.setPolicyConstraints(new PolicyConstraintsType());
            }
            return abstractRole.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) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType) List(java.util.List)

Aggregations

MultiplicityPolicyConstraintType (com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType)4 GenericMultiValueLabelEditPanel (com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel)2 MultiplicityPolicyPanel (com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel)2 PolicyConstraintsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType)2 List (java.util.List)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 IModel (org.apache.wicket.model.IModel)2 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)1