Search in sources :

Example 16 with RefinedResourceSchema

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

the class AbstractIntegrationTest method assertShadowRepo.

protected void assertShadowRepo(PrismObject<ShadowType> accountShadow, String oid, String username, ResourceType resourceType, QName objectClass, MatchingRule<String> nameMatchingRule) throws SchemaException {
    assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, true);
    PrismContainer<Containerable> attributesContainer = accountShadow.findContainer(ShadowType.F_ATTRIBUTES);
    List<Item<?, ?>> attributes = attributesContainer.getValue().getItems();
    //		Collection secIdentifiers = ShadowUtil.getSecondaryIdentifiers(accountShadow);
    if (attributes == null) {
        AssertJUnit.fail("No attributes in repo shadow");
    }
    RefinedResourceSchema refinedSchema = null;
    try {
        refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    } catch (SchemaException e) {
        AssertJUnit.fail(e.getMessage());
    }
    ObjectClassComplexTypeDefinition objClassDef = refinedSchema.getRefinedDefinition(objectClass);
    Collection secIdentifiers = objClassDef.getSecondaryIdentifiers();
    if (secIdentifiers == null) {
        AssertJUnit.fail("No secondary identifiers in repo shadow");
    }
    // repo shadow should contains all secondary identifiers + ICF_UID
    assertRepoShadowAttributes(attributes, secIdentifiers.size() + 1);
}
Also used : Item(com.evolveum.midpoint.prism.Item) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Collection(java.util.Collection) Containerable(com.evolveum.midpoint.prism.Containerable) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 17 with RefinedResourceSchema

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

the class AbstractIntegrationTest method createShadow.

protected PrismObject<ShadowType> createShadow(PrismObject<ResourceType> resource, String uid, String name) throws SchemaException {
    PrismObject<ShadowType> shadow = getShadowDefinition().instantiate();
    ShadowType shadowType = shadow.asObjectable();
    if (name != null) {
        shadowType.setName(PrismTestUtil.createPolyStringType(name));
    }
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    shadowType.setResourceRef(resourceRef);
    shadowType.setKind(ShadowKindType.ACCOUNT);
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    shadowType.setObjectClass(objectClassDefinition.getTypeName());
    ResourceAttributeContainer attrContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition);
    if (uid != null) {
        RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "uid"));
        ResourceAttribute<String> uidAttr = uidAttrDef.instantiate();
        uidAttr.setRealValue(uid);
        attrContainer.add(uidAttr);
    }
    if (name != null) {
        RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "name"));
        ResourceAttribute<String> nameAttr = nameAttrDef.instantiate();
        nameAttr.setRealValue(name);
        attrContainer.add(nameAttr);
    }
    return shadow;
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) QName(javax.xml.namespace.QName) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 18 with RefinedResourceSchema

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

the class AbstractIntegrationTest method createAccountShadowQuerySecondaryIdentifier.

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

Example 19 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema 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 20 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema 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)

Aggregations

RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 QName (javax.xml.namespace.QName)10 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 Test (org.testng.annotations.Test)4 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 Containerable (com.evolveum.midpoint.prism.Containerable)2 MatchingRule (com.evolveum.midpoint.prism.match.MatchingRule)2