Search in sources :

Example 11 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAdminAbstractRole method loadInducements.

// TODO unify with loadAssignments
private List<AssignmentEditorDto> loadInducements() {
    List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
    ObjectWrapper focusWrapper = getObjectWrapper();
    PrismObject<T> focus = focusWrapper.getObject();
    List<AssignmentType> inducements = focus.asObjectable().getInducement();
    for (AssignmentType inducement : inducements) {
        list.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, inducement, this));
    }
    Collections.sort(list);
    return list;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ArrayList(java.util.ArrayList) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper)

Example 12 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAdminFocus method loadDelegatedToMe.

private List<AssignmentEditorDto> loadDelegatedToMe() {
    List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
    ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
    PrismObject<F> focus = focusWrapper.getObject();
    List<AssignmentType> assignments = focus.asObjectable().getAssignment();
    for (AssignmentType assignment : assignments) {
        if (assignment.getTargetRef() != null && UserType.COMPLEX_TYPE.equals(assignment.getTargetRef().getType())) {
            AssignmentEditorDto dto = new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, this);
            dto.setSimpleView(true);
            dto.setEditable(false);
            list.add(dto);
        }
    }
    Collections.sort(list);
    return list;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 13 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageRequestRole method handleAssignmentDeltas.

protected ContainerDelta handleAssignmentDeltas(ObjectDelta<UserType> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition def) throws SchemaException {
    ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());
    for (AssignmentEditorDto assDto : assignments) {
        PrismContainerValue newValue = assDto.getNewValue(getPrismContext());
        switch(assDto.getStatus()) {
            case ADD:
                newValue.applyDefinition(def, false);
                assDelta.addValueToAdd(newValue.clone());
                break;
            case DELETE:
                PrismContainerValue oldValue = assDto.getOldValue();
                oldValue.applyDefinition(def);
                assDelta.addValueToDelete(oldValue.clone());
                break;
            case MODIFY:
                if (!assDto.isModified(getPrismContext())) {
                    LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
                    continue;
                }
                handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
                break;
            default:
                warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
        }
    }
    if (!assDelta.isEmpty()) {
        assDelta = focusDelta.addModification(assDelta);
    }
    return assDelta;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 14 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAssignmentsList method getAssignmentsToRemoveList.

private List<AssignmentEditorDto> getAssignmentsToRemoveList(UserType user) {
    List<AssignmentConflictDto> conflicts = getSessionStorage().getRoleCatalog().getConflictsList();
    List<String> assignmentsToRemoveOids = new ArrayList<>();
    for (AssignmentConflictDto dto : conflicts) {
        if (dto.isRemovedOld()) {
            assignmentsToRemoveOids.add(dto.getExistingAssignmentTargetObj().getOid());
        }
    }
    List<AssignmentEditorDto> assignmentsToDelete = new ArrayList<>();
    for (AssignmentType assignment : user.getAssignment()) {
        if (assignment.getTargetRef() == null) {
            continue;
        }
        if (assignmentsToRemoveOids.contains(assignment.getTargetRef().getOid())) {
            assignmentsToDelete.add(new AssignmentEditorDto(UserDtoStatus.DELETE, assignment, this));
        }
    }
    return assignmentsToDelete;
}
Also used : AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 15 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class UserDelegationsTabPanel method initLayout.

private void initLayout() {
    WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
    delegations.setOutputMarkupId(true);
    add(delegations);
    AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, createStringResource("FocusType.delegations"), delegationsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
            DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, privilegesListModel, pageBase);
            item.add(editor);
        }

        @Override
        public String getExcludeOid() {
            return getObjectWrapper().getOid();
        }

        @Override
        protected List<InlineMenuItem> createAssignmentMenu() {
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item;
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        List<QName> supportedTypes = new ArrayList<>();
                        supportedTypes.add(UserType.COMPLEX_TYPE);
                        ObjectFilter filter = InOidFilter.createInOid(getObjectWrapper().getOid());
                        ObjectFilter notFilter = NotFilter.createNot(filter);
                        ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(pageBase.getMainPopupBodyId(), UserType.class, supportedTypes, false, pageBase, notFilter) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
                                pageBase.hideMainPopup(target);
                                List<ObjectType> newAssignmentsList = new ArrayList<>();
                                newAssignmentsList.add(user);
                                addSelectedAssignablePerformed(target, newAssignmentsList, getPageBase().getMainPopup().getId());
                            }
                        };
                        panel.setOutputMarkupId(true);
                        pageBase.showMainPopup(panel, target);
                    }
                });
                items.add(item);
            }
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        deleteAssignmentPerformed(target);
                    }
                });
                items.add(item);
            }
            return items;
        }

        @Override
        protected String getNoAssignmentsSelectedMessage() {
            return getString("AssignmentTablePanel.message.noDelegationsSelected");
        }

        @Override
        protected String getAssignmentsDeleteMessage(int size) {
            return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", size).getString();
        }

        @Override
        protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, String popupId) {
            ModalWindow window = (ModalWindow) get(popupId);
            if (window != null) {
                window.close(target);
            }
            getPageBase().hideMainPopup(target);
            if (newAssignments.isEmpty()) {
                warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            for (ObjectType object : newAssignments) {
                try {
                    AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), SchemaConstants.ORG_DEPUTY, getPageBase(), (UserType) object);
                    dto.setPrivilegeLimitationList(privilegesListModel.getObject());
                    delegationsModel.getObject().add(dto);
                } catch (Exception e) {
                    error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
                }
            }
            reloadAssignmentsPanel(target);
            reloadMainFormButtons(target);
        }
    };
    delegations.add(panel);
}
Also used : DelegationEditorPanel(com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AssignmentTablePanel(com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow)

Aggregations

AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)18 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ArrayList (java.util.ArrayList)4 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 DelegationEditorPanel (com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel)3 FocusMainPanel (com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel)3 PageAdminObjectDetails (com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails)3 List (java.util.List)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)2 FocusTabVisibleBehavior (com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior)2 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 RoleCatalogStorage (com.evolveum.midpoint.web.session.RoleCatalogStorage)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)2 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)1