use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class SampleFormFocusTabPanel method initLayout.
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
add(new Label(ID_HEADER, "Object details"));
WebMarkupContainer body = new WebMarkupContainer("body");
add(body);
addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
// TODO: create proxy for these operations
Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
List<PrismObject<RoleType>> availableRoles;
try {
availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
task.getResult().recordFatalError(e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
availableRoles = new ArrayList<>();
// TODO: better errror reporting
}
add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType 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.RoleType in project midpoint by Evolveum.
the class TestDeltaConverter method testModifyInducement.
@Test
public void testModifyInducement() throws Exception {
System.out.println("===[ testModifyInducement ]====");
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "role-modify-inducement.xml"), ObjectModificationType.COMPLEX_TYPE);
// WHEN
ObjectDelta<RoleType> objectDelta = DeltaConvertor.createObjectDelta(objectChange, RoleType.class, getPrismContext());
System.out.println("Delta:");
System.out.println(objectDelta.debugDump());
// THEN
assertNotNull("No object delta", objectDelta);
objectDelta.checkConsistence();
assertEquals("Wrong OID", "00000000-8888-6666-0000-100000000005", objectDelta.getOid());
ReferenceDelta targetRefDelta = objectDelta.findReferenceModification(new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(5L), new NameItemPathSegment(AssignmentType.F_TARGET_REF)));
assertNotNull("No targetRef delta", targetRefDelta);
Collection<PrismReferenceValue> valuesToAdd = targetRefDelta.getValuesToAdd();
assertEquals("Wrong number of values to add", 1, valuesToAdd.size());
PrismReferenceValue targetRefVal = valuesToAdd.iterator().next();
assertNotNull("Null value in targetRef delta", targetRefVal);
assertEquals("wrong OID in targetRef", "12345678-d34d-b33f-f00d-987987987987", targetRefVal.getOid());
assertEquals("wrong target type in targetRef", RoleType.COMPLEX_TYPE, targetRefVal.getTargetType());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestAssignmentProcessor2 method test020AssignMR1ToR1.
@Test(enabled = FIRST_PART)
public void test020AssignMR1ToR1() throws Exception {
final String TEST_NAME = "test020AssignMR1ToR1";
displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
LensContext<RoleType> context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result);
// WHEN
displayWhen(TEST_NAME);
assignmentProcessor.processAssignmentsProjections(context, clock.currentTimeXMLGregorianCalendar(), task, result);
// THEN
displayThen(TEST_NAME);
display("Output context", context);
display("Evaluated assignment triple", context.getEvaluatedAssignmentTriple());
assertSuccess(result);
// assignment of construction R1-0
// assignment of focus mappings R1-0
// assignment of focus policy rules R1-0
// assignment of metarole MR1 (this will be checked)
Collection<EvaluatedAssignmentImpl<RoleType>> evaluatedAssignments = assertAssignmentTripleSetSize(context, 4, 0, 0);
List<EvaluatedAssignmentImpl<RoleType>> targetedAssignments = evaluatedAssignments.stream().filter(ea -> ea.getTarget() != null).collect(Collectors.toList());
assertEquals("Wrong # of targeted assignments", 1, targetedAssignments.size());
EvaluatedAssignmentImpl<RoleType> evaluatedAssignment = targetedAssignments.get(0);
assertEquals("Wrong evaluatedAssignment.isValid", true, evaluatedAssignment.isValid());
// R4, R5, R6 could be optimized out
assertTargets(evaluatedAssignment, true, "MR1 MR3 MR4", null, null, null, null, null);
assertTargets(evaluatedAssignment, false, "MMR1 R5 R4 R6", null, null, null, null, null);
assertMembershipRef(evaluatedAssignment, "MR1 MR3 MR4");
assertOrgRef(evaluatedAssignment, "");
assertDelegation(evaluatedAssignment, null);
assertConstructions(evaluatedAssignment, "MR1-1 MR3-1 MMR1-2 MR4-1", null, null, null, null, null);
assertFocusMappings(evaluatedAssignment, "MR1-1 MR3-1 MMR1-2 MR4-1");
assertFocusPolicyRules(evaluatedAssignment, "MR1-1 MR3-1 MMR1-2 MR4-1");
assertTargetPolicyRules(evaluatedAssignment, "MR1-0 MMR1-1", "MR3-0 MR4-0");
assertAuthorizations(evaluatedAssignment, "MR1 MR3 MR4");
assertGuiConfig(evaluatedAssignment, "MR1 MR3 MR4");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType 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);
}
}
Aggregations