Search in sources :

Example 11 with AssignmentObjectRelation

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

the class AbstractRoleMemberPanel method initMemberTable.

private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
    WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
    memberContainer.setOutputMarkupId(true);
    memberContainer.setOutputMarkupPlaceholderTag(true);
    form.add(memberContainer);
    // TODO QName defines a relation value which will be used for new member creation
    MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions(), getPanelConfiguration()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName());
        }

        @Override
        protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
            columns.add(createRelationColumn());
            return columns;
        }

        @Override
        protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
                return false;
            }
            Class<?> objectClass = rowModel.getObject().getValue().getClass();
            return WebComponentUtil.hasDetailsPage(objectClass);
        }

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
            AjaxIconButton assignButton = createAssignButton(buttonId);
            buttonsList.add(1, assignButton);
            return buttonsList;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return createRowActions();
        }

        @Override
        protected String getStorageKey() {
            return AbstractRoleMemberPanel.this.createStorageKey();
        }

        protected PageStorage getPageStorage(String storageKey) {
            return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
        }

        @Override
        protected Search<AH> createSearch(Class<AH> type) {
            return createMemberSearch(type);
        }

        @Override
        protected SelectableBeanObjectDataProvider<AH> createProvider() {
            SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
            provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
            return provider;
        }

        @Override
        public void refreshTable(AjaxRequestTarget target) {
            if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
                clearCache();
            }
            if (reloadPageOnRefresh()) {
                throw new RestartResponseException(getPage().getClass());
            } else {
                super.refreshTable(target);
            }
        }

        @Override
        protected boolean showNewObjectCreationPopup() {
            return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
        }

        @Override
        protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
            List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
            if (refList == null) {
                refList = new ArrayList<>();
            }
            if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
                refList.addAll(relation.getArchetypeRefs());
            }
            ObjectReferenceType membershipRef = new ObjectReferenceType();
            membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
            membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
            membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
            refList.add(membershipRef);
            return refList;
        }

        @Override
        protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
            return loadMultiFunctionalButtonModel(true);
        }

        @Override
        public ContainerPanelConfigurationType getPanelConfiguration() {
            return AbstractRoleMemberPanel.this.getPanelConfiguration();
        }

        @Override
        protected String getTitleForNewObjectButton() {
            return createStringResource("TreeTablePanel.menu.createMember").getString();
        }
    };
    childrenListPanel.setOutputMarkupId(true);
    memberContainer.add(childrenListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RestartResponseException(org.apache.wicket.RestartResponseException) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) Component(org.apache.wicket.Component)

Example 12 with AssignmentObjectRelation

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

the class CreateTemplatePanel method initLayout.

private void initLayout() {
    MultiCompositedButtonPanel buttonsPanel = new MultiCompositedButtonPanel(ID_TEMPLATE, new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            onTemplateChosePerformed(collectionViews, target);
        }
    };
    add(buttonsPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebPage(org.apache.wicket.markup.html.WebPage) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) MultiCompositedButtonPanel(com.evolveum.midpoint.web.component.MultiCompositedButtonPanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Example 13 with AssignmentObjectRelation

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

the class AbstractRoleMemberPanel method loadMultiFunctionalButtonModel.

protected LoadableModel<MultiFunctinalButtonDto> loadMultiFunctionalButtonModel(boolean useDefaultObjectRelations) {
    return new LoadableModel<>(false) {

        @Override
        protected MultiFunctinalButtonDto load() {
            MultiFunctinalButtonDto multiFunctinalButtonDto = new MultiFunctinalButtonDto();
            DisplayType mainButtonDisplayType = getCreateMemberButtonDisplayType();
            CompositedIconBuilder builder = new CompositedIconBuilder();
            Map<IconCssStyle, IconType> layerIcons = WebComponentUtil.createMainButtonLayerIcon(mainButtonDisplayType);
            for (Map.Entry<IconCssStyle, IconType> icon : layerIcons.entrySet()) {
                builder.appendLayerIcon(icon.getValue(), icon.getKey());
            }
            CompositedIconButtonDto mainButton = createCompositedIconButtonDto(mainButtonDisplayType, null, builder.build());
            multiFunctinalButtonDto.setMainButton(mainButton);
            List<AssignmentObjectRelation> loadedRelations = loadMemberRelationsList();
            if (CollectionUtils.isEmpty(loadedRelations) && useDefaultObjectRelations) {
                loadedRelations.addAll(getDefaultNewMemberRelations());
            }
            List<CompositedIconButtonDto> additionalButtons = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(loadedRelations)) {
                List<AssignmentObjectRelation> relations = WebComponentUtil.divideAssignmentRelationsByAllValues(loadedRelations);
                relations.forEach(relation -> {
                    DisplayType additionalButtonDisplayType = GuiDisplayTypeUtil.getAssignmentObjectRelationDisplayType(getPageBase(), relation, "abstractRoleMemberPanel.menu.createMember");
                    CompositedIconButtonDto buttonDto = createCompositedIconButtonDto(additionalButtonDisplayType, relation, createCompositedIcon(relation, additionalButtonDisplayType));
                    additionalButtons.add(buttonDto);
                });
            }
            multiFunctinalButtonDto.setAdditionalButtons(additionalButtons);
            return multiFunctinalButtonDto;
        }
    };
}
Also used : CompositedIconButtonDto(com.evolveum.midpoint.web.component.CompositedIconButtonDto) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle)

Example 14 with AssignmentObjectRelation

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

the class AbstractRoleMemberPanel method loadMultiFunctionalButtonModel.

protected LoadableModel<MultiFunctinalButtonDto> loadMultiFunctionalButtonModel(boolean useDefaultObjectRelations) {
    return new LoadableModel<>(false) {

        @Override
        protected MultiFunctinalButtonDto load() {
            MultiFunctinalButtonDto multiFunctinalButtonDto = new MultiFunctinalButtonDto();
            DisplayType mainButtonDisplayType = getCreateMemberButtonDisplayType();
            CompositedIconBuilder builder = new CompositedIconBuilder();
            Map<IconCssStyle, IconType> layerIcons = WebComponentUtil.createMainButtonLayerIcon(mainButtonDisplayType);
            for (Map.Entry<IconCssStyle, IconType> icon : layerIcons.entrySet()) {
                builder.appendLayerIcon(icon.getValue(), icon.getKey());
            }
            CompositedIconButtonDto mainButton = createCompositedIconButtonDto(mainButtonDisplayType, null, builder.build());
            multiFunctinalButtonDto.setMainButton(mainButton);
            List<AssignmentObjectRelation> loadedRelations = loadMemberRelationsList();
            if (CollectionUtils.isEmpty(loadedRelations) && useDefaultObjectRelations) {
                loadedRelations.addAll(getDefaultNewMemberRelations());
            }
            List<CompositedIconButtonDto> additionalButtons = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(loadedRelations)) {
                List<AssignmentObjectRelation> relations = WebComponentUtil.divideAssignmentRelationsByAllValues(loadedRelations);
                relations.forEach(relation -> {
                    DisplayType additionalButtonDisplayType = GuiDisplayTypeUtil.getAssignmentObjectRelationDisplayType(getPageBase(), relation, "abstractRoleMemberPanel.menu.createMember");
                    CompositedIconButtonDto buttonDto = createCompositedIconButtonDto(additionalButtonDisplayType, relation, createCompositedIcon(relation, additionalButtonDisplayType));
                    additionalButtons.add(buttonDto);
                });
            }
            multiFunctinalButtonDto.setAdditionalButtons(additionalButtons);
            return multiFunctinalButtonDto;
        }
    };
}
Also used : CompositedIconButtonDto(com.evolveum.midpoint.web.component.CompositedIconButtonDto) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle)

Example 15 with AssignmentObjectRelation

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

the class AbstractAssignmentPanel method loadAssignmentTargetRelationsList.

@NotNull
private <AH extends AssignmentHolderType> List<AssignmentObjectRelation> loadAssignmentTargetRelationsList() {
    OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_RELATIONS);
    List<AssignmentObjectRelation> assignmentTargetRelations = new ArrayList<>();
    PrismObject<AH> obj = getFocusObject();
    try {
        AssignmentCandidatesSpecification spec = getPageBase().getModelInteractionService().determineAssignmentTargetSpecification(obj, result);
        assignmentTargetRelations = spec != null ? spec.getAssignmentObjectRelations() : new ArrayList<>();
    } catch (SchemaException | ConfigurationException ex) {
        result.recordPartialError(ex.getLocalizedMessage());
        LOGGER.error("Couldn't load assignment target specification for the object {} , {}", obj.getName(), ex.getLocalizedMessage());
    }
    return assignmentTargetRelations;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentCandidatesSpecification(com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) NotNull(org.jetbrains.annotations.NotNull)

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