Search in sources :

Example 46 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class AbstractIntegrationTest method createAccountShadowQuery.

protected ObjectQuery createAccountShadowQuery(String identifier, PrismObject<ResourceType> resource) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getPrimaryIdentifiers();
    assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
    ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
    //TODO: set matching rule instead of null
    return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(identifier).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 47 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class AbstractIntegrationTest method createAccountShadowQueryByAttribute.

protected ObjectQuery createAccountShadowQueryByAttribute(String attributeName, String attributeValue, PrismObject<ResourceType> resource) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    return createShadowQueryByAttribute(rAccount, attributeName, attributeValue, resource);
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 48 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class AbstractIntegrationTest method findShadowByName.

protected PrismObject<ShadowType> findShadowByName(QName objectClass, String name, PrismObject<ResourceType> resource, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(objectClass);
    ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource);
    List<PrismObject<ShadowType>> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result);
    if (shadows.isEmpty()) {
        return null;
    }
    assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows;
    return shadows.iterator().next();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) PrismObject(com.evolveum.midpoint.prism.PrismObject) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 49 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class TestUnix method test010Schema.

@Test
public void test010Schema() throws Exception {
    final String TEST_NAME = "test010Schema";
    TestUtil.displayTestTile(this, TEST_NAME);
    resourceOpenDj = getObject(ResourceType.class, RESOURCE_OPENDJ_OID);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    IntegrationTestTools.displayXml("Initialized resource", resourceOpenDj);
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resourceOpenDj, prismContext);
    display("OpenDJ schema (resource)", resourceSchema);
    ObjectClassComplexTypeDefinition ocDefPosixAccount = resourceSchema.findObjectClassDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixAccount);
    assertTrue("Objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixAccount.isAuxiliary());
    ObjectClassComplexTypeDefinition ocDefPosixGroup = resourceSchema.findObjectClassDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", ocDefPosixGroup);
    assertTrue("Objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", ocDefPosixGroup.isAuxiliary());
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resourceOpenDj);
    display("OpenDJ schema (refined)", refinedSchema);
    RefinedObjectClassDefinition rOcDefPosixAccount = refinedSchema.getRefinedDefinition(OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixAccount);
    assertTrue("Refined objectclass " + OPENDJ_ACCOUNT_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixAccount.isAuxiliary());
    RefinedObjectClassDefinition rOcDefPosixGroup = refinedSchema.getRefinedDefinition(OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME);
    assertNotNull("No refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " in resource schema", rOcDefPosixGroup);
    assertTrue("Refined objectclass " + OPENDJ_GROUP_POSIX_AUXILIARY_OBJECTCLASS_NAME + " is not auxiliary", rOcDefPosixGroup.isAuxiliary());
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Test(org.testng.annotations.Test)

Example 50 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class TestUnix method test111AccountMancombEditObjectClassDefinition.

@Test
public void test111AccountMancombEditObjectClassDefinition() throws Exception {
    final String TEST_NAME = "test111AccountMancombEditObjectClassDefinition";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<ShadowType> shadow = getShadowModel(accountMancombOid);
    display("shadow", shadow);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    RefinedObjectClassDefinition editObjectClassDefinition = modelInteractionService.getEditObjectClassDefinition(shadow, resourceOpenDj, AuthorizationPhaseType.REQUEST);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    display("OC def", editObjectClassDefinition);
    PrismAsserts.assertPropertyDefinition(editObjectClassDefinition, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn"), DOMUtil.XSD_STRING, 1, -1);
    PrismAsserts.assertPropertyDefinition(editObjectClassDefinition, new QName(RESOURCE_OPENDJ_NAMESPACE, "o"), DOMUtil.XSD_STRING, 0, -1);
    PrismAsserts.assertPropertyDefinition(editObjectClassDefinition, new QName(RESOURCE_OPENDJ_NAMESPACE, "uidNumber"), DOMUtil.XSD_INT, 1, 1);
    PrismAsserts.assertPropertyDefinition(editObjectClassDefinition, new QName(RESOURCE_OPENDJ_NAMESPACE, "gidNumber"), DOMUtil.XSD_INT, 1, 1);
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Aggregations

RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)72 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)33 QName (javax.xml.namespace.QName)28 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)20 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)17 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)12 PrismObject (com.evolveum.midpoint.prism.PrismObject)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 Task (com.evolveum.midpoint.task.api.Task)8 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)8 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)7 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 SystemException (com.evolveum.midpoint.util.exception.SystemException)7 Collection (java.util.Collection)7 RefinedAssociationDefinition (com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition)6