Search in sources :

Example 1 with AssignmentPopup

use of com.evolveum.midpoint.gui.api.component.AssignmentPopup 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 2 with AssignmentPopup

use of com.evolveum.midpoint.gui.api.component.AssignmentPopup 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 3 with AssignmentPopup

use of com.evolveum.midpoint.gui.api.component.AssignmentPopup in project midpoint by Evolveum.

the class PageAdminObjectDetails method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getMainPopupBodyId(), null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            OperationResult result = new OperationResult(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
            if (newAssignmentsList.size() > 1) {
                result.recordWarning(getString("PageAdminObjectDetails.change.archetype.more.than.one.selected"));
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            AssignmentType oldArchetypAssignment = getOldArchetypeAssignment(result);
            if (oldArchetypAssignment == null) {
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            try {
                ObjectDelta<O> delta = getPrismContext().deltaFor(getCompileTimeClass()).item(AssignmentHolderType.F_ASSIGNMENT).delete(oldArchetypAssignment.clone()).asObjectDelta(getObjectWrapper().getOid());
                delta.addModificationAddContainer(AssignmentHolderType.F_ASSIGNMENT, newAssignmentsList.iterator().next());
                Task task = createSimpleTask(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
                getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
            } catch (Exception e) {
                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage(), e);
                result.recordFatalError(getString("PageAdminObjectDetails.change.archetype.failed", e.getMessage()), e);
            }
            result.computeStatusIfUnknown();
            showResult(result);
            target.add(PageAdminObjectDetails.this.getFeedbackPanel());
            refresh(target);
        }

        @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 = getObjectWrapper().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);
    showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Example 4 with AssignmentPopup

use of com.evolveum.midpoint.gui.api.component.AssignmentPopup in project midpoint by Evolveum.

the class AssignmentPanel 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 AssignmentPanel.this.getObjectTypesList();
        }

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

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

        @Override
        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
            return AssignmentPanel.this.getModelObject();
        }

        @Override
        protected <F extends AssignmentHolderType> PrismObject<F> getFocusObject() {
            return getMultivalueContainerListPanel().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)

Aggregations

AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)2 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)2 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IModel (org.apache.wicket.model.IModel)2 AssignmentPopupDto (com.evolveum.midpoint.gui.api.component.AssignmentPopupDto)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 AuthorizationException (com.evolveum.midpoint.util.exception.AuthorizationException)1