Search in sources :

Example 1 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class PageAdminFocus method getForceDeleteDelta.

private ObjectDelta getForceDeleteDelta(ObjectWrapper focusWrapper) throws SchemaException {
    List<FocusSubwrapperDto<ShadowType>> accountDtos = getFocusShadows();
    List<ReferenceDelta> refDeltas = new ArrayList<ReferenceDelta>();
    ObjectDelta<F> forceDeleteDelta = null;
    for (FocusSubwrapperDto<ShadowType> accDto : accountDtos) {
        if (!accDto.isLoadedOK()) {
            continue;
        }
        if (accDto.getStatus() == UserDtoStatus.DELETE) {
            ObjectWrapper accWrapper = accDto.getObject();
            ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject());
            refDeltas.add(refDelta);
        } else if (accDto.getStatus() == UserDtoStatus.UNLINK) {
            ObjectWrapper accWrapper = accDto.getObject();
            ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject().getOid());
            refDeltas.add(refDelta);
        }
    }
    if (!refDeltas.isEmpty()) {
        forceDeleteDelta = ObjectDelta.createModifyDelta(focusWrapper.getObject().getOid(), refDeltas, getCompileTimeClass(), getPrismContext());
    }
    PrismContainerDefinition def = focusWrapper.getObject().findContainer(UserType.F_ASSIGNMENT).getDefinition();
    if (forceDeleteDelta == null) {
        forceDeleteDelta = ObjectDelta.createEmptyModifyDelta(getCompileTimeClass(), focusWrapper.getObject().getOid(), getPrismContext());
    }
    handleAssignmentDeltas(forceDeleteDelta, getFocusAssignments(), def);
    return forceDeleteDelta;
}
Also used : FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper)

Example 2 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class PageAdminFocus method getShadowModifyDeltas.

private List<ObjectDelta<? extends ObjectType>> getShadowModifyDeltas(OperationResult result) {
    List<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
    OperationResult subResult = null;
    for (FocusSubwrapperDto<ShadowType> account : accounts) {
        if (!account.isLoadedOK()) {
            continue;
        }
        try {
            ObjectWrapper accountWrapper = account.getObject();
            ObjectDelta delta = accountWrapper.getObjectDelta();
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Account delta computed from {} as:\n{}", new Object[] { accountWrapper, delta.debugDump(3) });
            }
            if (!UserDtoStatus.MODIFY.equals(account.getStatus())) {
                continue;
            }
            if (delta.isEmpty() && (accountWrapper.getOldDelta() == null || accountWrapper.getOldDelta().isEmpty())) {
                continue;
            }
            if (accountWrapper.getOldDelta() != null) {
                delta = ObjectDelta.summarize(delta, accountWrapper.getOldDelta());
            }
            // what is this???
            // subResult = result.createSubresult(OPERATION_MODIFY_ACCOUNT);
            WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Modifying account:\n{}", new Object[] { delta.debugDump(3) });
            }
            deltas.add(delta);
        // subResult.recordSuccess();
        } catch (Exception ex) {
            // if (subResult != null) {
            result.recordFatalError("Couldn't compute account delta.", ex);
            // }
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't compute account delta", ex);
        }
    }
    return deltas;
}
Also used : FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 3 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class PageAdminFocus method loadSubwrappers.

private <S extends ObjectType> List<FocusSubwrapperDto<S>> loadSubwrappers(Class<S> type, QName propertyToLoad, boolean noFetch) {
    List<FocusSubwrapperDto<S>> list = new ArrayList<>();
    ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
    PrismObject<F> focus = focusWrapper.getObject();
    PrismReference prismReference = focus.findReference(new ItemPath(propertyToLoad));
    if (prismReference == null) {
        return new ArrayList<>();
    }
    List<PrismReferenceValue> references = prismReference.getValues();
    Task task = createSimpleTask(OPERATION_LOAD_SHADOW);
    for (PrismReferenceValue reference : references) {
        FocusSubwrapperDto<S> subWrapper = loadSubWrapperDto(type, reference.getOid(), noFetch, task);
        if (subWrapper != null) {
            list.add(subWrapper);
        }
    }
    return list;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class PageAdminFocus method prepareUserAccountsDeltaForModify.

private ReferenceDelta prepareUserAccountsDeltaForModify(PrismReferenceDefinition refDef) throws SchemaException {
    ReferenceDelta refDelta = new ReferenceDelta(refDef, getPrismContext());
    List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
    for (FocusSubwrapperDto<ShadowType> accDto : accounts) {
        if (accDto.isLoadedOK()) {
            ObjectWrapper accountWrapper = accDto.getObject();
            accountWrapper.revive(getPrismContext());
            ObjectDelta delta = accountWrapper.getObjectDelta();
            PrismReferenceValue refValue = new PrismReferenceValue(null, OriginType.USER_ACTION, null);
            PrismObject<ShadowType> account;
            switch(accDto.getStatus()) {
                case ADD:
                    account = delta.getObjectToAdd();
                    addDefaultKindAndIntent(account);
                    WebComponentUtil.encryptCredentials(account, true, getMidpointApplication());
                    refValue.setObject(account);
                    refDelta.addValueToAdd(refValue);
                    break;
                case DELETE:
                    account = accountWrapper.getObject();
                    refValue.setObject(account);
                    refDelta.addValueToDelete(refValue);
                    break;
                case MODIFY:
                    // before
                    continue;
                case UNLINK:
                    refValue.setOid(delta.getOid());
                    refValue.setTargetType(ShadowType.COMPLEX_TYPE);
                    refDelta.addValueToDelete(refValue);
                    break;
                default:
                    warn(getString("pageAdminFocus.message.illegalAccountState", accDto.getStatus()));
            }
        }
    }
    return refDelta;
}
Also used : FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper)

Example 5 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout(final PageBase page) {
    final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
    shadows.setOutputMarkupId(true);
    add(shadows);
    InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
    accountMenu.setVisible(!getObjectWrapper().isReadonly());
    shadows.add(accountMenu);
    final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
            PackageResourceReference packageRef;
            final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
            final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
            final Panel shadowPanel;
            if (dto.isLoadedOK()) {
                packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
                shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
            } else {
                shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onShowMorePerformed(AjaxRequestTarget target) {
                        OperationResult fetchResult = dto.getResult();
                        if (fetchResult != null) {
                            showResult(fetchResult);
                            target.add(page.getFeedbackPanel());
                        }
                    }
                };
            }
            shadowPanel.setOutputMarkupId(true);
            shadowPanel.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
                    ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
                    return !shadowWrapper.isMinimalized();
                }
            });
            item.add(shadowPanel);
            CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClickPerformed(AjaxRequestTarget target) {
                    super.onClickPerformed(target);
                    onExpandCollapse(target, item.getModel());
                    target.add(shadows);
                }
            };
            if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
                shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
            }
            item.add(shadowHeader);
        }
    };
    AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
                if (dto.isLoadedOK()) {
                    ObjectWrapper<ShadowType> accModel = dto.getObject();
                    accModel.setSelected(getModelObject());
                }
            }
            target.add(shadows);
        }
    };
    shadows.add(accountCheckAll);
    shadows.add(projectionList);
}
Also used : Serializable(java.io.Serializable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ImgResources(com.evolveum.midpoint.web.resource.img.ImgResources) ListView(org.apache.wicket.markup.html.list.ListView) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

FocusSubwrapperDto (com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ObjectWrapper (com.evolveum.midpoint.web.component.prism.ObjectWrapper)3 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 Task (com.evolveum.midpoint.task.api.Task)1 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)1 InlineMenu (com.evolveum.midpoint.web.component.menu.cog.InlineMenu)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 ImgResources (com.evolveum.midpoint.web.resource.img.ImgResources)1 Serializable (java.io.Serializable)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1