Search in sources :

Example 1 with Definition

use of com.evolveum.midpoint.prism.Definition in project midpoint by Evolveum.

the class ResourceRelatedHandlerPanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleIfView = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !parentPage.isEdit();
        }
    };
    enabledIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleForResourceCoordinates = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresResourceCoordinates();
        }
    };
    final WebMarkupContainer resourceRefContainer = new WebMarkupContainer(ID_RESOURCE_REF_CONTAINER);
    resourceRefContainer.add(visibleForResourceCoordinates);
    resourceRefContainer.setOutputMarkupId(true);
    add(resourceRefContainer);
    final DropDownChoice<TaskAddResourcesDto> resourceRef = new DropDownChoice<>(ID_RESOURCE_REF, new PropertyModel<TaskAddResourcesDto>(getModel(), ResourceRelatedHandlerDto.F_RESOURCE_REFERENCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resourceRef.setOutputMarkupId(true);
    resourceRef.add(enabledIfEdit);
    resourceRef.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Task task = parentPage.createSimpleTask(OPERATION_LOAD_RESOURCE);
            OperationResult result = task.getResult();
            List<QName> objectClassList = new ArrayList<>();
            TaskAddResourcesDto resourcesDto = getModelObject().getResourceRef();
            if (resourcesDto != null) {
                PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ResourceType.class, resourcesDto.getOid(), parentPage, task, result);
                try {
                    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, parentPage.getPrismContext());
                    schema.getObjectClassDefinitions();
                    for (Definition def : schema.getDefinitions()) {
                        objectClassList.add(def.getTypeName());
                    }
                    getModelObject().setObjectClassList(objectClassList);
                } catch (Exception e) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
                    error("Couldn't load object class list from resource.");
                }
            }
            target.add(resourceRefContainer);
        }
    });
    resourceRefContainer.add(resourceRef);
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.add(visibleForResourceCoordinates);
    add(kindContainer);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(getModel(), ResourceRelatedHandlerDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    kindContainer.add(kind);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.add(visibleForResourceCoordinates);
    add(intentContainer);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_INTENT));
    intentContainer.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(enabledIfEdit);
    WebMarkupContainer objectClassContainer = new WebMarkupContainer(ID_OBJECT_CLASS_CONTAINER);
    objectClassContainer.add(visibleForResourceCoordinates);
    add(objectClassContainer);
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(enabledIfEdit);
    objectClassContainer.add(objectClass);
    WebMarkupContainer optionsContainer = new WebMarkupContainer(ID_OPTIONS_CONTAINER);
    optionsContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    add(optionsContainer);
    WebMarkupContainer dryRunContainer = new WebMarkupContainer(ID_DRY_RUN_CONTAINER);
    dryRunContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    optionsContainer.add(dryRunContainer);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_DRY_RUN));
    dryRun.add(enabledIfEdit);
    dryRunContainer.add(dryRun);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 2 with Definition

use of com.evolveum.midpoint.prism.Definition in project midpoint by Evolveum.

the class ItemPathPanel method initNamspaceDefinitionMap.

private Map<QName, Collection<ItemDefinition<?>>> initNamspaceDefinitionMap() {
    Map<QName, Collection<ItemDefinition<?>>> schemaDefinitionsMap = new HashMap<>();
    if (getModelObject().getObjectType() != null) {
        Class clazz = WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), getModelObject().getObjectType());
        if (clazz != null) {
            PrismObjectDefinition<?> objectDef = getPageBase().getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz);
            Collection<? extends ItemDefinition> defs = objectDef.getDefinitions();
            Collection<ItemDefinition<?>> itemDefs = new ArrayList<>();
            for (Definition def : defs) {
                if (def instanceof ItemDefinition) {
                    ItemDefinition<?> itemDef = (ItemDefinition<?>) def;
                    itemDefs.add(itemDef);
                }
            }
            schemaDefinitionsMap.put(getModelObject().getObjectType(), itemDefs);
        }
    }
    return schemaDefinitionsMap;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) Definition(com.evolveum.midpoint.prism.Definition) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) Collection(java.util.Collection)

Example 3 with Definition

use of com.evolveum.midpoint.prism.Definition in project midpoint by Evolveum.

the class PageAccounts method loadResourceObjectClass.

private void loadResourceObjectClass() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    PrismObject<ResourceType> resourcePrism;
    OperationResult result = new OperationResult(OPERATION_GET_OBJECT_CLASS);
    List<QName> accountObjectClassList = new ArrayList<>();
    ResourceItemDto resourceDto = resourceModel.getObject();
    String oid = resourceDto.getOid();
    try {
        resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
        ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPrismContext());
        schema.getObjectClassDefinitions();
        for (Definition def : schema.getDefinitions()) {
            accountObjectClassList.add(def.getTypeName());
        }
        dto.setObjectClassList(accountObjectClassList);
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
        result.recordFatalError("Couldn't load object class list from resource.: " + e.getMessage(), e);
        showResult(result, false);
        resourceModel.setObject(null);
        new RestartResponseException(PageAccounts.this);
    }
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) RestartResponseException(org.apache.wicket.RestartResponseException)

Aggregations

Definition (com.evolveum.midpoint.prism.Definition)3 ArrayList (java.util.ArrayList)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 QName (javax.xml.namespace.QName)2 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 ResourceItemDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto)1 TaskAddResourcesDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1