Search in sources :

Example 16 with ResourceAttributeDefinition

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

the class CapabilityStep method editCapabilityPerformed.

@SuppressWarnings("unchecked")
private void editCapabilityPerformed(final AjaxRequestTarget target, CapabilityDto<? extends CapabilityType> capability) {
    dtoModel.getObject().setSelected(capability);
    WebMarkupContainer config = getConfigContainer();
    WebMarkupContainer newConfig;
    CapabilityType capType = capability.getCapability();
    if (capType instanceof ActivationCapabilityType) {
        newConfig = new CapabilityActivationPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ActivationCapabilityType>) capability), parentPage) {

            @Override
            public IModel<List<QName>> createAttributeChoiceModel(final IChoiceRenderer<QName> renderer) {
                LoadableModel<List<QName>> attributeChoiceModel = new LoadableModel<List<QName>>(false) {

                    @Override
                    protected List<QName> load() {
                        List<QName> choices = new ArrayList<>();
                        PrismObject<ResourceType> resourcePrism = resourceModel.getObject();
                        try {
                            ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resourcePrism);
                            if (schema != null) {
                                // TODO is this OK?
                                ResourceObjectTypeDefinition def = schema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
                                if (def != null) {
                                    for (ResourceAttributeDefinition<?> attribute : def.getAttributeDefinitions()) {
                                        choices.add(attribute.getItemName());
                                    }
                                }
                            }
                        } catch (CommonException | RuntimeException e) {
                            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource schema attributes.", e);
                            getPageBase().error("Couldn't load resource schema attributes" + e);
                        }
                        choices.sort((o1, o2) -> {
                            String s1 = (String) renderer.getDisplayValue(o1);
                            String s2 = (String) renderer.getDisplayValue(o2);
                            return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
                        });
                        return choices;
                    }
                };
                parentPage.registerDependentModel(attributeChoiceModel);
                return attributeChoiceModel;
            }
        };
    } else if (capType instanceof ScriptCapabilityType) {
        newConfig = new CapabilityScriptPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ScriptCapabilityType>) capability), getTable(), parentPage);
    } else if (capType instanceof CredentialsCapabilityType) {
        newConfig = new CapabilityCredentialsPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CredentialsCapabilityType>) capability), getTable(), parentPage);
    } else {
        newConfig = new CapabilityValuePanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CapabilityType>) capability), getTable(), parentPage);
    }
    // TODO other specific capabilities (paged, count, ...)
    newConfig.setOutputMarkupId(true);
    config.replaceWith(newConfig);
    target.add(newConfig);
    target.add(getTable());
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchemaFactory(com.evolveum.midpoint.schema.processor.ResourceSchemaFactory) com.evolveum.midpoint.web.component.wizard.resource.component.capability(com.evolveum.midpoint.web.component.wizard.resource.component.capability) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) IModel(org.apache.wicket.model.IModel) Method(java.lang.reflect.Method) Label(org.apache.wicket.markup.html.basic.Label) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Model(org.apache.wicket.model.Model) ResourceTypeUtil(com.evolveum.midpoint.schema.util.ResourceTypeUtil) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Task(com.evolveum.midpoint.task.api.Task) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) AttributeModifier(org.apache.wicket.AttributeModifier) com.evolveum.midpoint.xml.ns._public.resource.capabilities_3(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3) InvocationTargetException(java.lang.reflect.InvocationTargetException) ModelService(com.evolveum.midpoint.model.api.ModelService) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) PropertyModel(org.apache.wicket.model.PropertyModel) Item(org.apache.wicket.markup.repeater.Item) Type(java.lang.reflect.Type) SystemException(com.evolveum.midpoint.util.exception.SystemException) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) QName(javax.xml.namespace.QName) DataView(org.apache.wicket.markup.repeater.data.DataView) NotNull(org.jetbrains.annotations.NotNull) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) java.util(java.util) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) CapabilityUtil(com.evolveum.midpoint.schema.CapabilityUtil) Capability(com.evolveum.midpoint.web.component.wizard.resource.dto.Capability) CloneUtil(com.evolveum.midpoint.prism.util.CloneUtil) JAXBElement(javax.xml.bind.JAXBElement) WizardStep(com.evolveum.midpoint.web.component.wizard.WizardStep) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) CommonException(com.evolveum.midpoint.util.exception.CommonException) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ParameterizedType(java.lang.reflect.ParameterizedType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 17 with ResourceAttributeDefinition

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

the class ResourceContentResourcePanel method createAttributeDefinitionList.

private <T extends ObjectType> List<SearchItemDefinition> createAttributeDefinitionList() {
    List<SearchItemDefinition> map = new ArrayList<>();
    ResourceObjectDefinition ocDef = null;
    try {
        if (getKind() != null) {
            ocDef = getDefinitionByKind();
        } else if (getObjectClass() != null) {
            ocDef = getDefinitionByObjectClass();
        }
    } catch (SchemaException e) {
        warn("Could not get determine object class definition");
        return map;
    }
    if (ocDef == null) {
        return map;
    }
    for (ResourceAttributeDefinition def : ocDef.getAttributeDefinitions()) {
        map.add(new SearchItemDefinition(ItemPath.create(ShadowType.F_ATTRIBUTES, getAttributeName(def)), def, null));
    }
    return map;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ArrayList(java.util.ArrayList) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition)

Example 18 with ResourceAttributeDefinition

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

the class TestSanity method checkOpenDjSchema.

private void checkOpenDjSchema(ResourceType resource, String source) throws SchemaException {
    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition accountDefinition = schema.findObjectClassDefinition(RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
    assertNotNull("Schema does not define any account (resource from " + source + ")", accountDefinition);
    Collection<? extends ResourceAttributeDefinition> identifiers = accountDefinition.getPrimaryIdentifiers();
    assertFalse("No account identifiers (resource from " + source + ")", identifiers == null || identifiers.isEmpty());
    // TODO: check for naming attributes and display names, etc
    ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    if (capActivation != null && capActivation.getStatus() != null && capActivation.getStatus().getAttribute() != null) {
        // There is simulated activation capability, check if the attribute is in schema.
        QName enableAttrName = capActivation.getStatus().getAttribute();
        ResourceAttributeDefinition enableAttrDef = accountDefinition.findAttributeDefinition(enableAttrName);
        display("Simulated activation attribute definition", enableAttrDef);
        assertNotNull("No definition for enable attribute " + enableAttrName + " in account (resource from " + source + ")", enableAttrDef);
        assertTrue("Enable attribute " + enableAttrName + " is not ignored (resource from " + source + ")", enableAttrDef.isIgnored());
    }
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 19 with ResourceAttributeDefinition

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

the class AbstractIntegrationTest method createShadowQuerySecondaryIdentifier.

protected ObjectQuery createShadowQuerySecondaryIdentifier(ObjectClassComplexTypeDefinition rAccount, String identifier, PrismObject<ResourceType> resource) throws SchemaException {
    Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getSecondaryIdentifiers();
    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.getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)

Example 20 with ResourceAttributeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition 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)

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