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;
}
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);
}
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());
}
}
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();
}
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);
}
Aggregations