use of com.evolveum.midpoint.repo.sqale.qmodel.role.MRole in project midpoint by Evolveum.
the class RoleMemberListRepoTest method fillDatabase.
@Test
public void fillDatabase() throws SchemaException, ObjectAlreadyExistsException {
OperationResult operationResult = createOperationResult();
for (int roleIndex = ROLE_MIN; roleIndex <= ROLE_MAX; roleIndex++) {
String name = String.format("role-%05d", roleIndex);
RoleType role = new RoleType(prismContext).name(PolyStringType.fromOrig(name));
try {
repositoryService.addObject(role.asPrismObject(), null, operationResult);
roleOids.add(role.getOid());
System.out.println("Created role " + name);
} catch (ObjectAlreadyExistsException e) {
// never mind, we'll use the existing one
QRole r = aliasFor(QRole.class);
MRole existingRow = selectOne(r, r.nameOrig.eq(name));
roleOids.add(existingRow.oid.toString());
System.out.println("Reused existing role " + name);
}
}
for (int userIndex = USER_MIN; userIndex <= USER_MAX; userIndex++) {
String name = String.format("user-%07d", userIndex);
UserType user = new UserType(prismContext).name(PolyStringType.fromOrig(name));
addRoles(user);
try {
repositoryService.addObject(user.asPrismObject(), null, operationResult);
System.out.println("Created user " + name + " with " + user.getRoleMembershipRef().size() + " roles");
} catch (ObjectAlreadyExistsException e) {
System.out.println("User " + name + " already exists");
}
}
}
Aggregations