Search in sources :

Example 16 with AssignmentObjectRelation

use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.

the class AbstractAssignmentPanel method getAssignmentObjectRelationList.

private List<AssignmentObjectRelation> getAssignmentObjectRelationList() {
    if (AbstractAssignmentPanel.this.getContainerModel().getObject() == null) {
        return null;
    }
    List<AssignmentObjectRelation> assignmentRelationsList = WebComponentUtil.divideAssignmentRelationsByAllValues(loadAssignmentTargetRelationsList());
    if (assignmentRelationsList == null || assignmentRelationsList.isEmpty()) {
        return assignmentRelationsList;
    }
    QName assignmentType = getAssignmentType();
    if (assignmentType == null) {
        return assignmentRelationsList;
    }
    List<AssignmentObjectRelation> assignmentRelationsListFilteredByType = new ArrayList<>();
    assignmentRelationsList.forEach(assignmentRelation -> {
        QName objectType = assignmentRelation.getObjectTypes() != null && !assignmentRelation.getObjectTypes().isEmpty() ? assignmentRelation.getObjectTypes().get(0) : null;
        if (QNameUtil.match(assignmentType, objectType)) {
            assignmentRelationsListFilteredByType.add(assignmentRelation);
        }
    });
    return assignmentRelationsListFilteredByType;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Example 17 with AssignmentObjectRelation

use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.

the class AbstractRoleMemberPanel method getDefaultNewMemberRelations.

protected List<AssignmentObjectRelation> getDefaultNewMemberRelations() {
    List<AssignmentObjectRelation> relationsList = new ArrayList<>();
    List<QName> newMemberObjectTypes = getNewMemberObjectTypes();
    if (newMemberObjectTypes != null) {
        newMemberObjectTypes.forEach(objectType -> {
            List<QName> supportedRelation = getSupportedRelations();
            if (!UserType.COMPLEX_TYPE.equals(objectType) && !OrgType.COMPLEX_TYPE.equals(objectType)) {
                supportedRelation.remove(RelationTypes.APPROVER.getRelation());
                supportedRelation.remove(RelationTypes.OWNER.getRelation());
                supportedRelation.remove(RelationTypes.MANAGER.getRelation());
            }
            AssignmentObjectRelation assignmentObjectRelation = new AssignmentObjectRelation();
            assignmentObjectRelation.addRelations(supportedRelation);
            assignmentObjectRelation.addObjectTypes(Collections.singletonList(objectType));
            assignmentObjectRelation.getArchetypeRefs().addAll(archetypeReferencesListForType(objectType));
            relationsList.add(assignmentObjectRelation);
        });
    } else {
        AssignmentObjectRelation assignmentObjectRelation = new AssignmentObjectRelation();
        assignmentObjectRelation.addRelations(getSupportedRelations());
        relationsList.add(assignmentObjectRelation);
    }
    return relationsList;
}
Also used : QName(javax.xml.namespace.QName) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Example 18 with AssignmentObjectRelation

use of com.evolveum.midpoint.model.api.AssignmentObjectRelation 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 19 with AssignmentObjectRelation

use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.

the class AssignmentHolderOperationalButtonsPanel method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getPageBase().getMainPopupBodyId(), Model.of(new AssignmentPopupDto(null))) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            addArchetypePerformed(target, newAssignmentsList);
        }

        @Override
        protected List<ITab> createAssignmentTabs(AssignmentObjectRelation assignmentObjectRelation) {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(getPageBase().createStringResource("ObjectTypes.ARCHETYPE"), new VisibleBehaviour(() -> true)) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new FocusTypeAssignmentPopupTabPanel<ArchetypeType>(panelId, ObjectTypes.ARCHETYPE, null) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
                            PrismContainerWrapper<AssignmentType> assignmentsWrapper = null;
                            try {
                                assignmentsWrapper = AssignmentHolderOperationalButtonsPanel.this.getModelObject().findContainer(FocusType.F_ASSIGNMENT);
                            } catch (SchemaException e) {
                                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
                            }
                            return assignmentsWrapper;
                        }

                        @Override
                        protected List<QName> getSupportedRelations() {
                            return Collections.singletonList(SchemaConstants.ORG_DEFAULT);
                        }

                        @Override
                        protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ArchetypeType>> rowModel) {
                            target.add(getObjectListPanel());
                            tabLabelPanelUpdate(target);
                        }

                        @Override
                        protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<ArchetypeType>> rowModel) {
                            if (rowModel == null) {
                                return Model.of(false);
                            }
                            List selectedObjects = getSelectedObjectsList();
                            return Model.of(selectedObjects == null || selectedObjects.size() == 0 || (rowModel.getObject() != null && rowModel.getObject().isSelected()));
                        }

                        @Override
                        protected ObjectTypes getObjectType() {
                            return ObjectTypes.ARCHETYPE;
                        }

                        @Override
                        protected ObjectQuery addFilterToContentQuery() {
                            ObjectQuery query = super.addFilterToContentQuery();
                            if (query == null) {
                                query = getPrismContext().queryFactory().createQuery();
                            }
                            List<String> archetypeOidsList = getArchetypeOidsListToAssign();
                            ObjectFilter filter = getPrismContext().queryFor(ArchetypeType.class).id(archetypeOidsList.toArray(new String[0])).buildFilter();
                            query.addFilter(filter);
                            return query;
                        }
                    };
                }
            });
            return tabs;
        }

        @Override
        protected IModel<String> getWarningMessageModel() {
            return createStringResource("PageAdminObjectDetails.button.changeArchetype.warningMessage");
        }
    };
    changeArchetypePopup.setOutputMarkupPlaceholderTag(true);
    getPageBase().showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ArrayList(java.util.ArrayList) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) AssignmentPopupDto(com.evolveum.midpoint.gui.api.component.AssignmentPopupDto) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with AssignmentObjectRelation

use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.

the class AssignmentPopup method newButtonDescription.

private List<CompositedIconButtonDto> newButtonDescription() {
    if (getModelObject() == null) {
        return null;
    }
    List<AssignmentObjectRelation> relations = getModelObject().getAssignmentObjectRelation();
    if (relations == null) {
        return null;
    }
    List<CompositedIconButtonDto> buttonDtoList = new ArrayList<>();
    relations.forEach(relation -> buttonDtoList.add(createCompositedButtonForAssignmentRelation(relation)));
    if (isGenericNewObjectButtonVisible()) {
        DisplayType defaultButtonDisplayType = GuiDisplayTypeUtil.createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green", createStringResource("AssignmentPanel.defaultAssignment").getString(), createStringResource("AssignmentPanel.newAssignmentTitle", "", "").getString());
        // AssignmentPanel.this.createStringResource(isInducement() ?
        // "AssignmentPanel.newInducementTitle" : "AssignmentPanel.newAssignmentTitle", "", "").getString());
        CompositedIconButtonDto defaultButton = new CompositedIconButtonDto();
        CompositedIconBuilder builder = new CompositedIconBuilder();
        builder.setBasicIcon(WebComponentUtil.getIconCssClass(defaultButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(defaultButtonDisplayType)).appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_PLUS_CIRCLE, "green"), IconCssStyle.BOTTOM_RIGHT_STYLE);
        defaultButton.setAdditionalButtonDisplayType(defaultButtonDisplayType);
        defaultButton.setCompositedIcon(builder.build());
        buttonDtoList.add(defaultButton);
    }
    return buttonDtoList;
}
Also used : CompositedIconButtonDto(com.evolveum.midpoint.web.component.CompositedIconButtonDto) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Aggregations

AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)29 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)18 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)13 ArrayList (java.util.ArrayList)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 WebPage (org.apache.wicket.markup.html.WebPage)8 QName (javax.xml.namespace.QName)7 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)7 IModel (org.apache.wicket.model.IModel)7 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)6 List (java.util.List)6 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)5 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)5 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 MultiCompositedButtonPanel (com.evolveum.midpoint.web.component.MultiCompositedButtonPanel)4 MultiFunctinalButtonDto (com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)4