Search in sources :

Example 31 with PrismContainerDefinition

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

the class SchemaTestUtil method assertFocusDefinition.

public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefinition, String defDesc) {
    assertNotNull("No " + defDesc + " definition", complexTypeDefinition);
    PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_NAME, "ObjectType.name");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_NAME, 0);
    PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_DESCRIPTION, 10);
    assertFalse("" + defDesc + " definition is marked as runtime", complexTypeDefinition.isRuntimeSchema());
    PrismContainerDefinition extensionContainer = complexTypeDefinition.findContainerDefinition(UserType.F_EXTENSION);
    PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1);
    assertTrue("Extension is NOT runtime", extensionContainer.isRuntimeSchema());
    assertTrue("Extension is NOT dynamic", extensionContainer.isDynamic());
    assertEquals("Extension size", 0, extensionContainer.getDefinitions().size());
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, UserType.F_EXTENSION, "ObjectType.extension");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, UserType.F_EXTENSION, 1000);
    PrismContainerDefinition<ActivationType> activationContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ACTIVATION);
    PrismAsserts.assertDefinition(activationContainer, UserType.F_ACTIVATION, ActivationType.COMPLEX_TYPE, 0, 1);
    assertFalse("Activation is runtime", activationContainer.isRuntimeSchema());
    assertEquals("Activation size", 12, activationContainer.getDefinitions().size());
    PrismAsserts.assertPropertyDefinition(activationContainer, ActivationType.F_ADMINISTRATIVE_STATUS, SchemaConstants.C_ACTIVATION_STATUS_TYPE, 0, 1);
    PrismContainerDefinition<AssignmentType> assignmentContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ASSIGNMENT);
    PrismAsserts.assertDefinition(assignmentContainer, UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
    assertFalse("Assignment is runtime", assignmentContainer.isRuntimeSchema());
    assertEquals("Assignment definition size", 21, assignmentContainer.getDefinitions().size());
    PrismContainerDefinition<ConstructionType> constructionContainer = assignmentContainer.findContainerDefinition(AssignmentType.F_CONSTRUCTION);
    PrismAsserts.assertDefinition(constructionContainer, AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1);
    assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema());
    PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class);
    PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1);
    assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
    assertEquals("Wrong composite object element name in accountRef", UserType.F_LINK, accountRefDef.getCompositeObjectElementName());
    PrismContainerDefinition<MetadataType> metadataContainer = complexTypeDefinition.findContainerDefinition(UserType.F_METADATA);
    PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1);
    assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema());
    assertFalse("Metadata is dynamic", metadataContainer.isDynamic());
    assertTrue("Metadata is NOT operational", metadataContainer.isOperational());
    assertEquals("Metadata size", 12, metadataContainer.getDefinitions().size());
    PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class);
    PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1);
    assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Example 32 with PrismContainerDefinition

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

the class UserProfileServiceImpl method initializePrincipalFromAssignments.

private void initializePrincipalFromAssignments(MidPointPrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration) throws SchemaException {
    UserType userType = principal.getUser();
    Collection<Authorization> authorizations = principal.getAuthorities();
    List<AdminGuiConfigurationType> adminGuiConfigurations = new ArrayList<>();
    Task task = taskManager.createTaskInstance(UserProfileServiceImpl.class.getName() + ".initializePrincipalFromAssignments");
    OperationResult result = task.getResult();
    principal.setApplicableSecurityPolicy(securityHelper.locateSecurityPolicy(userType.asPrismObject(), systemConfiguration, task, result));
    if (!userType.getAssignment().isEmpty()) {
        LensContext<UserType> lensContext = new LensContextPlaceholder<>(userType.asPrismObject(), prismContext);
        AssignmentEvaluator.Builder<UserType> builder = new AssignmentEvaluator.Builder<UserType>().repository(repositoryService).focusOdo(new ObjectDeltaObject<>(userType.asPrismObject(), null, userType.asPrismObject())).channel(null).objectResolver(objectResolver).systemObjectCache(systemObjectCache).prismContext(prismContext).mappingFactory(mappingFactory).mappingEvaluator(mappingEvaluator).activationComputer(activationComputer).now(clock.currentTimeXMLGregorianCalendar()).loginMode(true).lensContext(lensContext);
        AssignmentEvaluator<UserType> assignmentEvaluator = builder.build();
        try {
            RepositoryCache.enter();
            for (AssignmentType assignmentType : userType.getAssignment()) {
                try {
                    ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> assignmentIdi = new ItemDeltaItem<>();
                    assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType));
                    assignmentIdi.recompute();
                    EvaluatedAssignment<UserType> assignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userType, userType.toString(), task, result);
                    if (assignment.isValid()) {
                        authorizations.addAll(assignment.getAuthorizations());
                        adminGuiConfigurations.addAll(assignment.getAdminGuiConfigurations());
                    }
                    for (EvaluatedAssignmentTarget target : assignment.getRoles().getNonNegativeValues()) {
                        if (target.getTarget() != null && target.getTarget().asObjectable() instanceof UserType && DeputyUtils.isDelegationPath(target.getAssignmentPath())) {
                            List<OtherPrivilegesLimitationType> limitations = DeputyUtils.extractLimitations(target.getAssignmentPath());
                            principal.addDelegatorWithOtherPrivilegesLimitations(new DelegatorWithOtherPrivilegesLimitations((UserType) target.getTarget().asObjectable(), limitations));
                        }
                    }
                } catch (SchemaException e) {
                    LOGGER.error("Schema violation while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
                } catch (ObjectNotFoundException e) {
                    LOGGER.error("Object not found while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
                } catch (ExpressionEvaluationException e) {
                    LOGGER.error("Evaluation error while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
                } catch (PolicyViolationException e) {
                    LOGGER.error("Policy violation while processing assignment of {}: {}; assignment: {}", userType, e.getMessage(), assignmentType, e);
                }
            }
        } finally {
            RepositoryCache.exit();
        }
    }
    if (userType.getAdminGuiConfiguration() != null) {
        // config from the user object should go last (to be applied as the last one)
        adminGuiConfigurations.add(userType.getAdminGuiConfiguration());
    }
    principal.setAdminGuiConfiguration(AdminGuiConfigTypeUtil.compileAdminGuiConfiguration(adminGuiConfigurations, systemConfiguration));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) ArrayList(java.util.ArrayList) LensContextPlaceholder(com.evolveum.midpoint.model.impl.lens.LensContextPlaceholder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Authorization(com.evolveum.midpoint.security.api.Authorization) AssignmentEvaluator(com.evolveum.midpoint.model.impl.lens.AssignmentEvaluator) ItemDeltaItem(com.evolveum.midpoint.repo.common.expression.ItemDeltaItem) EvaluatedAssignmentTarget(com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) DelegatorWithOtherPrivilegesLimitations(com.evolveum.midpoint.security.api.DelegatorWithOtherPrivilegesLimitations)

Example 33 with PrismContainerDefinition

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

the class LoggingConfigurationTabPanel method initLayout.

protected void initLayout() {
    try {
        ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder();
        builder.visibilityHandler(itemWrapper -> getLoggingVisibility(itemWrapper.getPath()));
        Panel loggingPanel = getPageBase().initItemPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), builder.build());
        add(loggingPanel);
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel for logging: {}", e.getMessage(), e);
        getSession().error("Cannot create panle for logging");
    }
    PrismContainerWrapperModel<LoggingConfigurationType, ClassLoggerConfigurationType> loggerModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_CLASS_LOGGER);
    MultivalueContainerListPanel<ClassLoggerConfigurationType> loggersMultivalueContainerListPanel = new MultivalueContainerListPanel<ClassLoggerConfigurationType>(ID_LOGGERS, ClassLoggerConfigurationType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ClassLoggerConfigurationType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_APPENDER, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ClassLoggerConfigurationType.F_PACKAGE, defs);
            defs.addAll(SearchFactory.createExtensionDefinitionList(containerDef));
            return defs;
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            PrismContainerValue<ClassLoggerConfigurationType> newLogger = loggerModel.getObject().getItem().createNewValue();
            PrismContainerValueWrapper<ClassLoggerConfigurationType> newLoggerWrapper = getLoggersMultivalueContainerListPanel().createNewItemContainerValueWrapper(newLogger, loggerModel.getObject(), target);
            loggerEditPerformed(target, Model.of(newLoggerWrapper), null);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<ClassLoggerConfigurationType>> getContainerModel() {
            return loggerModel;
        }

        @Override
        protected String getStorageKey() {
            return SessionStorage.KEY_LOGGING_TAB_LOGGER_TABLE;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.LOGGING_TAB_LOGGER_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ClassLoggerConfigurationType>, String>> createDefaultColumns() {
            return initLoggersBasicColumns(loggerModel);
        }

        @Override
        protected void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ClassLoggerConfigurationType>> rowModel, List<PrismContainerValueWrapper<ClassLoggerConfigurationType>> listItems) {
            loggerEditPerformed(target, rowModel, listItems);
        }
    };
    add(loggersMultivalueContainerListPanel);
    PrismContainerWrapperModel<LoggingConfigurationType, AppenderConfigurationType> appenderModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_APPENDER);
    MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType> appendersMultivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<AppenderConfigurationType>(ID_APPENDERS, AppenderConfigurationType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            newAppendersClickPerformed(target, appenderModel);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<AppenderConfigurationType>> getContainerModel() {
            return appenderModel;
        }

        @Override
        protected boolean isHeaderVisible() {
            return false;
        }

        @Override
        protected String getStorageKey() {
            return SessionStorage.KEY_LOGGING_TAB_APPENDER_TABLE;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.LOGGING_TAB_APPENDER_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<AppenderConfigurationType>, String>> createDefaultColumns() {
            return initAppendersBasicColumns(appenderModel);
        }

        @Override
        protected MultivalueContainerDetailsPanel<AppenderConfigurationType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AppenderConfigurationType>> item) {
            return LoggingConfigurationTabPanel.this.getAppendersMultivalueContainerDetailsPanel(item);
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            // MidpointForm appenderTypeForm = new MidpointForm(ID_CHOICE_APPENDER_TYPE_FORM);
            AjaxSubmitButton newObjectIcon = new AjaxSubmitButton(idButton, new Model<>("<i class=\"fa fa-plus\"></i>")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    newItemPerformed(target, null);
                }
            };
            newObjectIcon.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return isCreateNewObjectVisible();
                }

                @Override
                public boolean isEnabled() {
                    return isNewObjectButtonEnabled();
                }
            });
            newObjectIcon.add(AttributeModifier.append("class", createStyleClassModelForNewObjectIcon()));
            // appenderTypeForm.add(newObjectIcon);
            bar.add(newObjectIcon);
            List<QName> appendersChoicesList = new ArrayList<>();
            appendersChoicesList.add(FileAppenderConfigurationType.COMPLEX_TYPE);
            appendersChoicesList.add(SyslogAppenderConfigurationType.COMPLEX_TYPE);
            DropDownChoicePanel<QName> appenderChoice = new DropDownChoicePanel<>(idButton, new Model<>(FileAppenderConfigurationType.COMPLEX_TYPE), Model.ofList(appendersChoicesList), new QNameIChoiceRenderer("LoggingConfigurationTabPanel.appendersChoice"));
            appenderChoice.setOutputMarkupId(true);
            LoggingConfigurationTabPanel.this.appenderChoice = appenderChoice;
            bar.add(appenderChoice);
            // bar.add(appenderTypeForm);
            return bar;
        }
    };
    add(appendersMultivalueContainerListPanel);
    IModel<PrismContainerWrapper<LoggingAuditingConfigurationType>> auditModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_AUDITING);
    try {
        Panel auditPanel = getPageBase().initItemPanel(ID_AUDITING, LoggingAuditingConfigurationType.COMPLEX_TYPE, auditModel, new ItemPanelSettingsBuilder().build());
        add(auditPanel);
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel for auditing: {}", e.getMessage(), e);
        getSession().error("Cannot create panel for auditing.");
    }
    setOutputMarkupId(true);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) ArrayList(java.util.ArrayList) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ItemPanelSettingsBuilder(com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) MultivalueContainerListPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) MultivalueContainerListPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 34 with PrismContainerDefinition

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

the class ItemPathPanel method initItemPathPanel.

private void initItemPathPanel() {
    WebMarkupContainer itemPathPanel = new WebMarkupContainer(ID_ITEM_PATH);
    itemPathPanel.setOutputMarkupId(true);
    add(itemPathPanel);
    itemPathPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !getModelObject().isPathDefined();
        }
    });
    WebMarkupContainer namespaceModeContainer = new WebMarkupContainer(ID_NAMESPACE_MODE_CONTAINER);
    namespaceModeContainer.setOutputMarkupId(true);
    namespaceModeContainer.add(new VisibleBehaviour(() -> ItemPathPanelMode.NAMESPACE_MODE.equals(panelMode)));
    itemPathPanel.add(namespaceModeContainer);
    ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
            return initNamspaceDefinitionMap();
        }

        @Override
        protected void onUpdateAutoCompletePanel(AjaxRequestTarget target) {
            ItemPathPanel.this.onUpdate(ItemPathPanel.this.getModelObject());
        }
    };
    itemDefPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    itemDefPanel.setOutputMarkupId(true);
    namespaceModeContainer.add(itemDefPanel);
    AjaxButton plusButton = new AjaxButton(ID_PLUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
        }
    };
    plusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
                return true;
            }
            return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
        }
    });
    plusButton.setOutputMarkupId(true);
    namespaceModeContainer.add(plusButton);
    AjaxButton minusButton = new AjaxButton(ID_MINUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ItemPathDto path = ItemPathPanel.this.getModelObject();
            refreshItemPathPanel(path, false, target);
        }
    };
    minusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
        }
    });
    minusButton.setOutputMarkupId(true);
    namespaceModeContainer.add(minusButton);
    DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<>(ID_NAMESPACE, new PropertyModel<>(getModel(), "objectType"), new ListModel<>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
    namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshItemPath(ItemPathPanel.this.getModelObject(), target);
        }
    });
    namespacePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
        }
    });
    namespacePanel.setOutputMarkupId(true);
    namespaceModeContainer.add(namespacePanel);
    TextPanel<String> itemPathTextField = new TextPanel<String>(ID_ITEM_PATH_TEXT_FIELD, new PropertyModel<>(getModel(), "pathStringValue"));
    itemPathTextField.add(new VisibleBehaviour(() -> switchToTextFieldEnabled && ItemPathPanelMode.TEXT_MODE.equals(panelMode)));
    itemPathTextField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    itemPathPanel.add(itemPathTextField);
    AjaxButton switchButton = new AjaxButton(ID_SWITCH_TO_TEXT_FIELD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            switchButtonClickPerformed(target);
        }
    };
    switchButton.setOutputMarkupId(true);
    switchButton.add(AttributeAppender.append("title", new LoadableModel<String>() {

        @Override
        protected String load() {
            return ItemPathPanelMode.NAMESPACE_MODE.equals(panelMode) ? getPageBase().createStringResource("ItemPathPanel.switchToTextModeTitle").getString() : getPageBase().createStringResource("ItemPathPanel.switchToNamespaceModeTitle").getString();
        }
    }));
    switchButton.add(new VisibleBehaviour(() -> switchToTextFieldEnabled));
    itemPathPanel.add(switchButton);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) Collection(java.util.Collection) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 35 with PrismContainerDefinition

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

the class SearchPropertiesConfigPanel method getAvailablePropertiesListModel.

private LoadableModel<List<Property>> getAvailablePropertiesListModel() {
    return new LoadableModel<List<Property>>() {

        @Override
        protected List<Property> load() {
            Class<?> type = getType();
            if (ObjectType.class.isAssignableFrom(type)) {
                PrismObjectDefinition objectDef = SearchFactory.findObjectDefinition(getType(), null, getPageBase());
                List<SearchItemDefinition> availableDefs = SearchFactory.getAvailableDefinitions(objectDef, null, true, getPageBase());
                List<Property> propertiesList = new ArrayList<>();
                availableDefs.forEach(searchItemDef -> {
                    if (!isPropertyAlreadyAdded(searchItemDef.getPath())) {
                        propertiesList.add(new Property(searchItemDef.getDef(), searchItemDef.getPath()));
                    }
                });
                return propertiesList;
            }
            if (AuditEventRecordType.class.isAssignableFrom(type)) {
                PrismContainerDefinition<AuditEventRecordType> auditDefs = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AuditEventRecordType.class);
                List<Property> propertiesList = auditDefs.getDefinitions().stream().map(def -> new Property(def, def.getItemName())).collect(Collectors.toList());
                return propertiesList;
            }
            return Collections.emptyList();
        }
    };
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) StringResourceModel(org.apache.wicket.model.StringResourceModel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) StringUtils(org.apache.commons.lang3.StringUtils) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) Popupable(com.evolveum.midpoint.web.component.dialog.Popupable) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) BasicSearchFilter(com.evolveum.midpoint.web.component.search.filter.BasicSearchFilter) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PropertyModel(org.apache.wicket.model.PropertyModel) Item(org.apache.wicket.markup.repeater.Item) ValueSearchFilterItem(com.evolveum.midpoint.web.component.search.filter.ValueSearchFilterItem) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) ItemPathComparatorUtil(com.evolveum.midpoint.prism.path.ItemPathComparatorUtil) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) Collections(java.util.Collections) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList)

Aggregations

PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)41 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)18 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)17 Task (com.evolveum.midpoint.task.api.Task)16 Test (org.testng.annotations.Test)16 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)14 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)13 QName (javax.xml.namespace.QName)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 ArrayList (java.util.ArrayList)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5 List (java.util.List)5 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)4 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)4 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)4