use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method getUserAssignment.
protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
PrismObject<UserType> user = getUser(userOid);
List<AssignmentType> assignments = user.asObjectable().getAssignment();
for (AssignmentType assignment : assignments) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, targetRef.getRelation())) {
return assignment;
}
}
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method unassignAllRoles.
protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
Task task = createPlainTask("unassignAllRoles");
OperationResult result = task.getResult();
PrismObject<UserType> user = modelService.getObject(UserType.class, userOid, null, task, result);
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
for (AssignmentType assignment : user.asObjectable().getAssignment()) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) {
ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition());
PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue();
cval.setId(assignment.getId());
assignmentDelta.addValueToDelete(cval);
modifications.add(assignmentDelta);
}
}
}
if (modifications.isEmpty()) {
return;
}
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
modelService.executeChanges(deltas, useRawPlusRecompute ? executeOptions().raw() : null, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
if (useRawPlusRecompute) {
recomputeUser(userOid, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class ResourceTypeAssignmentPopupTabPanel method getSelectedAssignmentsMap.
@Override
protected Map<String, AssignmentType> getSelectedAssignmentsMap() {
Map<String, AssignmentType> assignmentList = new HashMap<>();
List<ResourceType> selectedObjects = getSelectedObjectsList();
ShadowKindType kind = getKindValue();
String intent = getIntentValue();
selectedObjects.forEach(selectedObject -> {
AssignmentType newConstructionAssignment = ObjectTypeUtil.createAssignmentWithConstruction(selectedObject.asPrismObject(), kind, intent, getPageBase().getPrismContext());
if (isEntitlementAssignment()) {
NameItemPathSegment segment = getAssociationValue() != null ? new NameItemPathSegment(getAssociationValue().getName()) : null;
if (segment != null) {
ResourceObjectAssociationType association = new ResourceObjectAssociationType();
association.setRef(new ItemPathType(ItemPath.create(segment)));
newConstructionAssignment.getConstruction().getAssociation().add(association);
}
}
assignmentList.put(selectedObject.getOid(), newConstructionAssignment);
});
return assignmentList;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AssignmentHolderTypeAssignmentsTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
PrismContainerWrapperModel<AHT, AssignmentType> model = PrismContainerWrapperModel.fromContainerWrapper(getObjectWrapperModel(), AssignmentHolderType.F_ASSIGNMENT);
SwitchAssignmentTypePanel panel = createPanel(ID_ASSIGNMENTS_PANEL, model);
assignments.add(panel);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSoD method test020AssignRolePirate.
/**
* Assign Pirate to jack. This should trigger an approval.
*/
@Test
public void test020AssignRolePirate() throws Exception {
given();
login(userAdministrator);
OperationResult result = getTestOperationResult();
PrismObject<UserType> jack = getUser(userJackOid);
String originalDescription = jack.asObjectable().getDescription();
ObjectDelta<UserType> addPirateDelta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(createAssignmentTo(rolePirateOid, ObjectTypes.ROLE, prismContext)).asObjectDelta(userJackOid);
ObjectDelta<UserType> changeDescriptionDelta = prismContext.deltaFor(UserType.class).item(UserType.F_DESCRIPTION).replace("Pirate Judge").asObjectDelta(userJackOid);
ObjectDelta<UserType> primaryDelta = ObjectDeltaCollectionsUtil.summarize(addPirateDelta, changeDescriptionDelta);
when();
executeTest2(new TestDetails2<UserType>() {
@Override
protected PrismObject<UserType> getFocus(OperationResult result) {
return jack.clone();
}
@Override
protected ObjectDelta<UserType> getFocusDelta() {
return primaryDelta.clone();
}
@Override
protected int getNumberOfDeltasToApprove() {
return 1;
}
@Override
protected List<Boolean> getApprovals() {
return Collections.singletonList(true);
}
@Override
protected List<ObjectDelta<UserType>> getExpectedDeltasToApprove() {
return Collections.singletonList(addPirateDelta.clone());
}
@Override
protected ObjectDelta<UserType> getExpectedDelta0() {
return changeDescriptionDelta.clone();
}
@Override
protected String getObjectOid() {
return jack.getOid();
}
@Override
protected List<ExpectedTask> getExpectedTasks() {
return Collections.singletonList(new ExpectedTask(rolePirateOid, "Role \"Pirate\" excludes role \"Judge\""));
}
@Override
protected List<ExpectedWorkItem> getExpectedWorkItems() {
List<ExpectedTask> etasks = getExpectedTasks();
return Collections.singletonList(new ExpectedWorkItem(userSodApproverOid, rolePirateOid, etasks.get(0)));
}
@Override
protected void assertDeltaExecuted(int number, boolean yes, Task opTask, OperationResult result) throws Exception {
switch(number) {
case 0:
if (yes) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, "Pirate Judge");
} else {
if (originalDescription != null) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, originalDescription);
} else {
assertUserNoProperty(userJackOid, UserType.F_DESCRIPTION);
}
}
break;
case 1:
if (yes) {
assertAssignedRole(userJackOid, rolePirateOid, result);
} else {
assertNotAssignedRole(userJackOid, rolePirateOid, result);
}
break;
}
}
@Override
protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Exception {
login(getUser(userSodApproverOid));
return true;
}
}, 1, false);
then();
display("jack as a Pirate + Judge", getUser(userJackOid));
AssignmentType judgeAssignment = assertAssignedRole(userJackOid, roleJudgeOid, result);
assertExclusionViolationSituation(judgeAssignment);
AssignmentType pirateAssignment = assertAssignedRole(userJackOid, rolePirateOid, result);
assertExclusionViolationSituation(pirateAssignment);
}
Aggregations