use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchTest method delegatedSearchTest.
@Test
public void delegatedSearchTest() throws Exception {
PrismReferenceValue r789 = new PrismReferenceValue("r789", RoleType.COMPLEX_TYPE);
// intentionally without relation (meaning "member")
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_DELEGATED_REF).ref(r789).build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00003", users.get(0).getName().getOrig());
PrismReferenceValue r123 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_DELEGATED_REF).ref(r123).build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find no users", 0, users.size());
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchTest method orgAssignmentSearchTest.
@Test
public void orgAssignmentSearchTest() throws Exception {
PrismReferenceValue org = new PrismReferenceValue("00000000-8888-6666-0000-100000000085", OrgType.COMPLEX_TYPE);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(org).build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchTest method roleAndOrgAssignmentSearchTest.
@Test
public void roleAndOrgAssignmentSearchTest() throws Exception {
PrismReferenceValue r123 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
PrismReferenceValue org = new PrismReferenceValue("00000000-8888-6666-0000-100000000085", OrgType.COMPLEX_TYPE);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(r123).and().item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(org).build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class AbstractOrgClosureTest method removeObjectParent.
protected void removeObjectParent(ObjectType object, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception {
List<ItemDelta> modifications = new ArrayList<>();
if (!useReplace) {
// standard case
PrismReferenceValue existingValue = parentOrgRef.asReferenceValue();
ItemDelta removeParent = ReferenceDelta.createModificationDelete(object.getClass(), OrgType.F_PARENT_ORG_REF, prismContext, existingValue.clone());
modifications.add(removeParent);
} else {
// using REPLACE modification
List<PrismReferenceValue> newValues = new ArrayList<>();
for (ObjectReferenceType ort : object.getParentOrgRef()) {
if (!ort.getOid().equals(parentOrgRef.getOid())) {
newValues.add(ort.asReferenceValue().clone());
}
}
PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(object.getClass());
ItemDelta replaceParent = ReferenceDelta.createModificationReplace(new ItemPath(OrgType.F_PARENT_ORG_REF), objectDefinition, newValues);
modifications.add(replaceParent);
}
repositoryService.modifyObject(object.getClass(), object.getOid(), modifications, opResult);
if (object instanceof OrgType) {
orgGraph.removeEdge(object.getOid(), parentOrgRef.getOid());
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class AbstractOrgClosureTest method addUserParent.
protected void addUserParent(UserType user, ObjectReferenceType parentOrgRef, OperationResult opResult) throws Exception {
List<ItemDelta> modifications = new ArrayList<>();
PrismReferenceValue existingValue = parentOrgRef.asReferenceValue();
ItemDelta readdParent = ReferenceDelta.createModificationAdd(UserType.class, UserType.F_PARENT_ORG_REF, prismContext, existingValue.clone());
modifications.add(readdParent);
repositoryService.modifyObject(UserType.class, user.getOid(), modifications, opResult);
}
Aggregations