Search in sources :

Example 26 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class WebComponentUtil method getReferencedObjectDisplayNamesAndNames.

public static String getReferencedObjectDisplayNamesAndNames(Referencable ref, boolean showTypes, boolean translate) {
    if (ref == null) {
        return "";
    }
    String name = ref.getTargetName() == null ? "" : (translate ? ref.getTargetName().getOrig() : "");
    StringBuilder sb = new StringBuilder(name);
    if (showTypes) {
        sb.append(" (");
        ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
        ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type);
        if (descriptor == null) {
            return null;
        }
        sb.append(emptyIfNull(createStringResourceStatic(null, descriptor.getLocalizationKey()).getString())).append(")");
    }
    return sb.toString();
}
Also used : ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 27 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class AbstractAssignmentTypePanel method newAssignmentClickPerformed.

protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
    AssignmentPopup popupPanel = new AssignmentPopup(getPageBase().getMainPopupBodyId(), createAssignmentPopupModel()) {

        private static final long serialVersionUID = 1L;

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

        @Override
        protected List<ObjectTypes> getObjectTypesList() {
            return AbstractAssignmentTypePanel.this.getObjectTypesList();
        }

        @Override
        protected ObjectFilter getSubtypeFilter() {
            return AbstractAssignmentTypePanel.this.getSubtypeFilter();
        }

        @Override
        protected boolean isEntitlementAssignment() {
            return AbstractAssignmentTypePanel.this.isEntitlementAssignment();
        }

        @Override
        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
            return AbstractAssignmentTypePanel.this.getContainerModel().getObject();
        }

        @Override
        protected <F extends AssignmentHolderType> PrismObject<F> getFocusObject() {
            return AbstractAssignmentTypePanel.this.getFocusObject();
        }
    };
    popupPanel.setOutputMarkupId(true);
    popupPanel.setOutputMarkupPlaceholderTag(true);
    getPageBase().showMainPopup(popupPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) List(java.util.List) ArrayList(java.util.ArrayList) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 28 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes 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 29 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class AssignmentPopup method mergeNewAssignmentTargetTypeLists.

private List<ObjectTypes> mergeNewAssignmentTargetTypeLists(List<QName> allowedByAssignmentTargetSpecification, List<ObjectTypes> availableTypesList) {
    if (CollectionUtils.isEmpty(allowedByAssignmentTargetSpecification)) {
        return availableTypesList;
    }
    if (CollectionUtils.isEmpty(availableTypesList)) {
        return allowedByAssignmentTargetSpecification.stream().map(spec -> ObjectTypes.getObjectTypeFromTypeQName(spec)).collect(Collectors.toList());
    }
    List<ObjectTypes> mergedList = new ArrayList<>();
    allowedByAssignmentTargetSpecification.forEach(qnameValue -> {
        ObjectTypes objectTypes = ObjectTypes.getObjectTypeFromTypeQName(qnameValue);
        for (ObjectTypes availableObjectTypes : availableTypesList) {
            if (availableObjectTypes.getClassDefinition().equals(objectTypes.getClassDefinition())) {
                mergedList.add(objectTypes);
                break;
            }
        }
    });
    return mergedList;
}
Also used : Form(org.apache.wicket.markup.html.form.Form) java.util(java.util) GuiDisplayTypeUtil(com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) StringResourceModel(org.apache.wicket.model.StringResourceModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) AssignmentCandidatesSpecification(com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification) Trace(com.evolveum.midpoint.util.logging.Trace) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) CollectionUtils(org.apache.commons.collections4.CollectionUtils) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Popupable(com.evolveum.midpoint.web.component.dialog.Popupable) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CompositedIconButtonDto(com.evolveum.midpoint.web.component.CompositedIconButtonDto) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collectors(java.util.stream.Collectors) MultiCompositedButtonPanel(com.evolveum.midpoint.web.component.MultiCompositedButtonPanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) QName(javax.xml.namespace.QName) WebPage(org.apache.wicket.markup.html.WebPage) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 30 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ChooseMemberPopup method createAssignmentTabs.

protected List<ITab> createAssignmentTabs(AssignmentObjectRelation relationSpec) {
    List<ITab> tabs = new ArrayList<>();
    List<QName> objectTypes = relationSpec != null && CollectionUtils.isNotEmpty(relationSpec.getObjectTypes()) ? relationSpec.getObjectTypes() : getAvailableObjectTypes();
    List<ObjectReferenceType> archetypeRefList = relationSpec != null && !CollectionUtils.isEmpty(relationSpec.getArchetypeRefs()) ? relationSpec.getArchetypeRefs() : getArchetypeRefList();
    tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.USER"), new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(UserType.COMPLEX_TYPE))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new MemberPopupTabPanel<UserType>(panelId, relationsConfig, archetypeRefList) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<UserType>> rowModel) {
                    tabLabelPanelUpdate(target);
                }

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

                @Override
                protected T getAbstractRoleTypeObject() {
                    return ChooseMemberPopup.this.getAssignmentTargetRefObject();
                }
            };
        }

        @Override
        public String getCount() {
            return Integer.toString(getTabPanelSelectedCount(getPanel()));
        }
    });
    tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.ROLE"), new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(RoleType.COMPLEX_TYPE))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new MemberPopupTabPanel<RoleType>(panelId, relationsConfig, archetypeRefList) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<RoleType>> rowModel) {
                    tabLabelPanelUpdate(target);
                }

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

                @Override
                protected T getAbstractRoleTypeObject() {
                    return ChooseMemberPopup.this.getAssignmentTargetRefObject();
                }
            };
        }

        @Override
        public String getCount() {
            return Integer.toString(getTabPanelSelectedCount(getPanel()));
        }
    });
    tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.ORG"), new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(OrgType.COMPLEX_TYPE))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new MemberPopupTabPanel<OrgType>(panelId, relationsConfig, archetypeRefList) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<OrgType>> rowModel) {
                    selectedOrgsListUpdate(rowModel);
                    tabLabelPanelUpdate(target);
                }

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

                @Override
                protected T getAbstractRoleTypeObject() {
                    return ChooseMemberPopup.this.getAssignmentTargetRefObject();
                }

                @Override
                protected List<OrgType> getPreselectedObjects() {
                    return selectedOrgsList;
                }
            };
        }

        @Override
        public String getCount() {
            return Integer.toString(selectedOrgsList.size());
        }
    });
    if (archetypeRefList == null || archetypeRefList.isEmpty()) {
        tabs.add(new CountablePanelTab(createStringResource("TypedAssignablePanel.orgTreeView"), new VisibleBehaviour(() -> isOrgTreeVisible() && (objectTypes == null || objectTypes.contains(OrgType.COMPLEX_TYPE)))) {

            private static final long serialVersionUID = 1L;

            @Override
            public WebMarkupContainer createPanel(String panelId) {
                return new OrgTreeMemberPopupTabPanel(panelId, relationsConfig, archetypeRefList) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    protected T getAbstractRoleTypeObject() {
                        return ChooseMemberPopup.this.getAssignmentTargetRefObject();
                    }

                    @Override
                    protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<OrgType>> rowModel) {
                        selectedOrgsListUpdate(rowModel);
                        tabLabelPanelUpdate(target);
                    }

                    @Override
                    protected List<OrgType> getPreselectedObjects() {
                        return selectedOrgsList;
                    }
                };
            }

            @Override
            public String getCount() {
                return Integer.toString(selectedOrgsList.size());
            }
        });
    }
    tabs.add(new CountablePanelTab(getPageBase().createStringResource("ObjectTypes.SERVICE"), new VisibleBehaviour(() -> objectTypes == null || objectTypes.contains(ServiceType.COMPLEX_TYPE))) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new MemberPopupTabPanel<ServiceType>(panelId, relationsConfig, archetypeRefList) {

                private static final long serialVersionUID = 1L;

                @Override
                protected T getAbstractRoleTypeObject() {
                    return ChooseMemberPopup.this.getAssignmentTargetRefObject();
                }

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

                @Override
                protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ServiceType>> rowModel) {
                    tabLabelPanelUpdate(target);
                }
            };
        }

        @Override
        public String getCount() {
            return Integer.toString(getTabPanelSelectedCount(getPanel()));
        }
    });
    return tabs;
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ArrayList(java.util.ArrayList) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)46 QName (javax.xml.namespace.QName)16 ArrayList (java.util.ArrayList)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 List (java.util.List)6 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)5 AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3