Search in sources :

Example 76 with OrgType

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();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)

Example 77 with OrgType

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");
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 78 with OrgType

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");
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 79 with OrgType

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());
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) RObjectType(com.evolveum.midpoint.repo.sql.data.common.other.RObjectType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 80 with OrgType

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);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) Entry(org.apache.directory.api.ldap.model.entry.Entry) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)123 Test (org.testng.annotations.Test)70 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)69 Task (com.evolveum.midpoint.task.api.Task)69 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)31 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)22 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 ArrayList (java.util.ArrayList)13 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)11 Entry (org.opends.server.types.Entry)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)8 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)8 QName (javax.xml.namespace.QName)8 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7