use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractOrgClosureTest method createOrg.
protected PrismObject<OrgType> createOrg(List<String> parentOids, String oidPrefix) throws Exception {
OrgType org = new OrgType();
org.setOid("o" + createOid(oidPrefix));
org.setDisplayName(createPolyString("o" + oidPrefix));
org.setName(createPolyString("o" + oidPrefix));
if (parentOids != null) {
for (String parentOid : parentOids) {
ObjectReferenceType ref = new ObjectReferenceType();
ref.setOid(parentOid);
ref.setType(OrgType.COMPLEX_TYPE);
org.getParentOrgRef().add(ref);
}
}
prismContext.adopt(org);
return org.asPrismContainer();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractOrgClosureTest method removeOrgStructure.
protected void removeOrgStructure(String nodeOid, OperationResult result) throws Exception {
removeUsersFromOrg(nodeOid, result);
ObjectQuery query = QueryBuilder.queryFor(OrgType.class, prismContext).isDirectChildOf(nodeOid).build();
List<PrismObject<OrgType>> subOrgs = repositoryService.searchObjects(OrgType.class, query, null, result);
for (PrismObject<OrgType> subOrg : subOrgs) {
removeOrgStructure(subOrg.getOid(), result);
}
try {
repositoryService.deleteObject(OrgType.class, nodeOid, result);
} catch (Exception e) {
System.err.println("error while deleting " + nodeOid + ": " + e.getMessage());
}
LOGGER.trace("Org " + nodeOid + " was removed");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractOrgClosureTest method _test200AddRemoveLinks.
protected void _test200AddRemoveLinks(boolean useReplace) throws Exception {
OperationResult opResult = new OperationResult("===[ addRemoveLinks ]===");
int totalRounds = 0;
OrgClosureStatistics stat = new OrgClosureStatistics();
// parentRef link removal + addition
long totalTimeLinkRemovals = 0, totalTimeLinkAdditions = 0;
for (int level = 0; level < getConfiguration().getLinkRoundsForLevel().length; level++) {
for (int round = 0; round < getConfiguration().getLinkRoundsForLevel()[level]; round++) {
// removal
List<String> levelOids = orgsByLevels.get(level);
if (levelOids.isEmpty()) {
continue;
}
int index = (int) Math.floor(Math.random() * levelOids.size());
String oid = levelOids.get(index);
OrgType org = repositoryService.getObject(OrgType.class, oid, null, opResult).asObjectable();
// check if it has no parents (shouldn't occur here!)
if (org.getParentOrgRef().isEmpty()) {
throw new IllegalStateException("No parents in " + org);
}
int i = (int) Math.floor(Math.random() * org.getParentOrgRef().size());
ObjectReferenceType parentOrgRef = org.getParentOrgRef().get(i);
info("Removing parent from org #" + totalRounds + "(" + level + "/" + round + "): " + org.getOid() + ", parent: " + parentOrgRef.getOid() + (useReplace ? " using replace" : ""));
long start = System.currentTimeMillis();
removeObjectParent(org, parentOrgRef, useReplace, opResult);
long timeRemoval = System.currentTimeMillis() - start;
info(" ... done in " + timeRemoval + " ms " + getNetDurationMessage());
stat.recordExtended(baseHelper.getConfiguration().getHibernateDialect(), allOrgCreated.size(), allUsersCreated.size(), closureSize, "AddRemoveLinks", level, false, getNetDuration());
totalTimeLinkRemovals += getNetDuration();
checkClosure(getVertices());
// addition
info("Re-adding parent for org #" + totalRounds + (useReplace ? " using replace" : ""));
start = System.currentTimeMillis();
addOrgParent(org, parentOrgRef, useReplace, opResult);
long timeAddition = System.currentTimeMillis() - start;
info(" ... done in " + timeAddition + " ms " + getNetDurationMessage());
stat.recordExtended(baseHelper.getConfiguration().getHibernateDialect(), allOrgCreated.size(), allUsersCreated.size(), closureSize, "AddRemoveLinks", level, true, getNetDuration());
checkClosure(getVertices());
totalTimeLinkAdditions += getNetDuration();
totalRounds++;
}
}
if (totalRounds > 0) {
System.out.println("Avg time for an arbitrary link removal: " + ((double) totalTimeLinkRemovals / totalRounds) + " ms");
System.out.println("Avg time for an arbitrary link re-addition: " + ((double) totalTimeLinkAdditions / totalRounds) + " ms");
LOGGER.info("===================================================");
LOGGER.info("Statistics for org link removal/addition:");
stat.dump(LOGGER, baseHelper.getConfiguration().getHibernateDialect(), allOrgCreated.size(), allUsersCreated.size(), closureSize, "AddRemoveLinks");
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractOrgClosureTest method _test190AddLink.
protected void _test190AddLink(String childOid, String parentOid) throws Exception {
OperationResult opResult = new OperationResult("===[ test190AddLink ]===");
//checkClosure(orgGraph.vertexSet());
ObjectType child = repositoryService.getObject(ObjectType.class, childOid, null, opResult).asObjectable();
ObjectReferenceType parentOrgRef = new ObjectReferenceType();
parentOrgRef.setOid(parentOid);
parentOrgRef.setType(OrgType.COMPLEX_TYPE);
System.out.println("Adding link " + childOid + " -> " + parentOid);
long start = System.currentTimeMillis();
if (child instanceof OrgType) {
addOrgParent((OrgType) child, parentOrgRef, false, opResult);
} else {
addUserParent((UserType) child, parentOrgRef, opResult);
}
long timeAddition = System.currentTimeMillis() - start;
System.out.println(" ... done in " + timeAddition + " ms" + getNetDurationMessage());
//checkClosure(orgGraph.vertexSet());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractEDirTest method test500AddOrgMeleeIsland.
// TODO: create account with a group membership
@Test
public void test500AddOrgMeleeIsland() throws Exception {
final String TEST_NAME = "test500AddOrgMeleeIsland";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
OrgType orgType = org.asObjectable();
orgType.setName(new PolyStringType(GROUP_MELEE_ISLAND_NAME));
AssignmentType metaroleAssignment = new AssignmentType();
ObjectReferenceType metaroleRef = new ObjectReferenceType();
metaroleRef.setOid(ROLE_META_ORG_OID);
metaroleRef.setType(RoleType.COMPLEX_TYPE);
metaroleAssignment.setTargetRef(metaroleRef);
orgType.getAssignment().add(metaroleAssignment);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(org, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
orgMeleeIslandOid = org.getOid();
Entry entry = assertLdapGroup(GROUP_MELEE_ISLAND_NAME);
org = getObject(OrgType.class, orgMeleeIslandOid);
groupMeleeOid = getSingleLinkOid(org);
PrismObject<ShadowType> shadow = getShadowModel(groupMeleeOid);
display("Shadow (model)", shadow);
}
Aggregations