Search in sources :

Example 1 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class ResourceAssociationEditor method loadObjectReferences.

private List<QName> loadObjectReferences(boolean restrictObjectClass) {
    List<QName> references = new ArrayList<>();
    ResourceSchema schema = loadResourceSchema();
    if (schema == null) {
        return references;
    }
    for (ObjectClassComplexTypeDefinition def : schema.getObjectClassDefinitions()) {
        if (restrictObjectClass) {
            if (objectType != null && def.getTypeName().equals(objectType.getObjectClass())) {
                for (ResourceAttributeDefinition attributeDefinition : def.getAttributeDefinitions()) {
                    references.add(attributeDefinition.getName());
                }
            }
        } else {
            for (ResourceAttributeDefinition attributeDefinition : def.getAttributeDefinitions()) {
                references.add(attributeDefinition.getName());
            }
        }
    }
    return references;
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 2 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class TestUtil method setAttribute.

public static void setAttribute(PrismObject<ShadowType> account, QName attrName, QName typeName, PrismContext prismContext, String value) throws SchemaException {
    PrismContainer<Containerable> attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES);
    ResourceAttributeDefinition attrDef = new ResourceAttributeDefinitionImpl(attrName, typeName, prismContext);
    ResourceAttribute attribute = attrDef.instantiate();
    attribute.setRealValue(value);
    attributesContainer.add(attribute);
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) Containerable(com.evolveum.midpoint.prism.Containerable) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) ResourceAttributeDefinitionImpl(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinitionImpl)

Example 3 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class AbstractIntegrationTest method assertShadowSecondaryIdentifier.

protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass());
    ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
    assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + expectedIdentifier, idProp);
    if (nameMatchingRule == null) {
        assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue());
    } else {
        PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue());
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Containerable(com.evolveum.midpoint.prism.Containerable) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 4 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createAccountShadowQuery.

protected ObjectQuery createAccountShadowQuery(String username, 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(username).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) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 5 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition in project midpoint by Evolveum.

the class IntegrationTestTools method assertProvisioningShadow.

public static void assertProvisioningShadow(PrismObject<ShadowType> account, ResourceType resourceType, Class<?> expetcedAttributeDefinitionClass, QName objectClass) {
    // Check attribute definition
    PrismContainer attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES);
    assertEquals("Wrong attributes container class", ResourceAttributeContainer.class, attributesContainer.getClass());
    ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer) attributesContainer;
    PrismContainerDefinition attrsDef = attributesContainer.getDefinition();
    assertNotNull("No attributes container definition", attrsDef);
    assertTrue("Wrong attributes definition class " + attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition);
    ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition) attrsDef;
    ObjectClassComplexTypeDefinition objectClassDef = rAttrsDef.getComplexTypeDefinition();
    assertNotNull("No object class definition in attributes definition", objectClassDef);
    assertEquals("Wrong object class in attributes definition", objectClass, objectClassDef.getTypeName());
    ResourceAttributeDefinition primaryIdDef = objectClassDef.getPrimaryIdentifiers().iterator().next();
    ResourceAttribute<?> primaryIdAttr = rAttributesContainer.findAttribute(primaryIdDef.getName());
    assertNotNull("No primary ID " + primaryIdDef.getName() + " in " + account, primaryIdAttr);
    assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expetcedAttributeDefinitionClass);
    ResourceAttributeDefinition secondaryIdDef = objectClassDef.getSecondaryIdentifiers().iterator().next();
    ResourceAttribute<Object> secondaryIdAttr = rAttributesContainer.findAttribute(secondaryIdDef.getName());
    assertNotNull("No secondary ID " + secondaryIdDef.getName() + " in " + account, secondaryIdAttr);
    assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expetcedAttributeDefinitionClass);
}
Also used : ResourceAttributeContainerDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Aggregations

ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)32 QName (javax.xml.namespace.QName)19 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)8 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)7 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Task (com.evolveum.midpoint.task.api.Task)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 ArrayList (java.util.ArrayList)6 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)5 Entry (org.apache.directory.api.ldap.model.entry.Entry)5 Test (org.testng.annotations.Test)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)3 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)2 Containerable (com.evolveum.midpoint.prism.Containerable)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2