Search in sources :

Example 1 with Capability

use of com.evolveum.midpoint.web.component.wizard.resource.dto.Capability 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 2 with Capability

use of com.evolveum.midpoint.web.component.wizard.resource.dto.Capability in project midpoint by Evolveum.

the class AddCapabilityDialog method loadModel.

private List<CapabilityDto<CapabilityType>> loadModel(IModel<CapabilityStepDto> capabilityModel) {
    List<Class<? extends CapabilityType>> existingCapabilityClasses = new ArrayList<>();
    for (CapabilityDto cap : capabilityModel.getObject().getCapabilities()) {
        existingCapabilityClasses.add(cap.getCapability().getClass());
    }
    List<CapabilityDto<CapabilityType>> rv = new ArrayList<>();
    for (Capability supportedCapability : Capability.values()) {
        if (!existingCapabilityClasses.contains(supportedCapability.getClazz())) {
            // 'among natives' doesn't matter here
            rv.add(new CapabilityDto<>(CapabilityStep.fillDefaults(supportedCapability.newInstance()), false));
        }
    }
    return rv;
}
Also used : CapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType) Capability(com.evolveum.midpoint.web.component.wizard.resource.dto.Capability) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) ArrayList(java.util.ArrayList)

Aggregations

Capability (com.evolveum.midpoint.web.component.wizard.resource.dto.Capability)2 CapabilityDto (com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 NonEmptyLoadableModel (com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel)1 WebModelServiceUtils (com.evolveum.midpoint.gui.api.util.WebModelServiceUtils)1 ModelService (com.evolveum.midpoint.model.api.ModelService)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 CloneUtil (com.evolveum.midpoint.prism.util.CloneUtil)1 CapabilityUtil (com.evolveum.midpoint.schema.CapabilityUtil)1 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)1 ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 ResourceSchemaFactory (com.evolveum.midpoint.schema.processor.ResourceSchemaFactory)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ResourceTypeUtil (com.evolveum.midpoint.schema.util.ResourceTypeUtil)1 Task (com.evolveum.midpoint.task.api.Task)1 MiscUtil (com.evolveum.midpoint.util.MiscUtil)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1