Search in sources :

Example 41 with RefinedObjectClassDefinition

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

the class RefinedObjectTypeChoicePanel method createChoiceModel.

private static IModel<? extends List<? extends RefinedObjectClassDefinition>> createChoiceModel(final IModel<PrismObject<ResourceType>> resourceModel) {
    return new IModel<List<? extends RefinedObjectClassDefinition>>() {

        @Override
        public List<? extends RefinedObjectClassDefinition> getObject() {
            RefinedResourceSchema refinedSchema;
            try {
                refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceModel.getObject());
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            List<? extends RefinedObjectClassDefinition> refinedDefinitions = refinedSchema.getRefinedDefinitions();
            List<? extends RefinedObjectClassDefinition> defs = new ArrayList<>();
            for (RefinedObjectClassDefinition rdef : refinedDefinitions) {
                if (rdef.getKind() != null) {
                    ((List) defs).add(rdef);
                }
            }
            return defs;
        }

        @Override
        public void detach() {
        }

        @Override
        public void setObject(List<? extends RefinedObjectClassDefinition> object) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 42 with RefinedObjectClassDefinition

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

the class SchemaListPanel method loadAllClasses.

private List<ObjectClassDto> loadAllClasses() {
    List<ObjectClassDto> list = new ArrayList<>();
    RefinedResourceSchema schema = loadResourceSchema();
    if (schema == null) {
        return list;
    }
    for (RefinedObjectClassDefinition definition : schema.getRefinedDefinitions()) {
        list.add(new ObjectClassDto(definition));
    }
    Collections.sort(list);
    return list;
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ArrayList(java.util.ArrayList) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ObjectClassDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDto)

Example 43 with RefinedObjectClassDefinition

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

the class AbstractIntegrationTest method findShadowByName.

protected PrismObject<ShadowType> findShadowByName(ShadowKindType kind, String intent, String name, PrismObject<ResourceType> resource, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind, intent);
    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 44 with RefinedObjectClassDefinition

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

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

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