Search in sources :

Example 6 with ShadowWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.

the class PageAccount method loadAccount.

private ShadowWrapper loadAccount(PageParameters parameters) {
    Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
    OperationResult result = task.getResult();
    Collection<SelectorOptions<GetOperationOptions>> options = getOperationOptionsBuilder().item(ShadowType.F_RESOURCE_REF).resolve().build();
    StringValue oid = parameters != null ? parameters.get(OnePageParameterEncoder.PARAMETER) : null;
    if (oid == null) {
        getSession().error(getString("pageAccount.message.cantEditAccount"));
        showResult(result);
        throw new RestartResponseException(PageResources.class);
    }
    PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, oid.toString(), options, PageAccount.this, task, result);
    if (account == null) {
        getSession().error(getString("pageAccount.message.cantEditAccount"));
        showResult(result);
        throw new RestartResponseException(PageResources.class);
    }
    PrismObjectWrapperFactory<ShadowType> owf = getRegistry().getObjectWrapperFactory(account.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    context.setShowEmpty(false);
    ShadowWrapper wrapper;
    try {
        wrapper = (ShadowWrapper) owf.createObjectWrapper(account, ItemStatus.NOT_CHANGED, context);
    // TODO: fetch result???
    } catch (SchemaException e) {
        LOGGER.error("Cannot create wrapper for shadow {}", account);
        result.recordFatalError(getString("PageAccount.message.loadAccount.fatalError"));
        throw new RestartResponseException(PageResources.class);
    }
    return wrapper;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PageResources(com.evolveum.midpoint.web.page.admin.resources.PageResources) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) StringValue(org.apache.wicket.util.string.StringValue)

Example 7 with ShadowWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.

the class FocusDetailsModels method getAdditionalModifyDeltas.

@Override
protected List<ObjectDelta<? extends ObjectType>> getAdditionalModifyDeltas(OperationResult result) {
    List<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    List<ShadowWrapper> accounts = projectionModel.getObject();
    for (ShadowWrapper account : accounts) {
        try {
            ObjectDelta<ShadowType> delta = account.getObjectDelta();
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Account delta computed from {} as:\n{}", account, delta.debugDump(3));
            }
            if (!UserDtoStatus.MODIFY.equals(account.getProjectionStatus())) {
                continue;
            }
            if (delta == null || delta.isEmpty()) {
                continue;
            }
            WebComponentUtil.encryptCredentials(delta, true, getPageBase());
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Modifying account:\n{}", delta.debugDump(3));
            }
            deltas.add(delta);
        } catch (Exception ex) {
            result.recordFatalError(getPageBase().getString("PageAdminFocus.message.getShadowModifyDeltas.fatalError"), ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't compute account delta", ex);
        }
    }
    return deltas;
}
Also used : ArrayList(java.util.ArrayList) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 8 with ShadowWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.

the class FocusDetailsModels method loadShadowWrapper.

@NotNull
public ShadowWrapper loadShadowWrapper(PrismObject<ShadowType> projection, boolean noFetch, Task task, OperationResult result) throws SchemaException {
    PrismObjectWrapperFactory<ShadowType> factory = getPageBase().findObjectWrapperFactory(projection.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    context.setCreateIfEmpty(noFetch ? false : true);
    ShadowWrapper wrapper = (ShadowWrapper) factory.createObjectWrapper(projection, ItemStatus.NOT_CHANGED, context);
    wrapper.setProjectionStatus(UserDtoStatus.MODIFY);
    return wrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with ShadowWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.

the class ShadowWrapperFactoryImpl method createObjectWrapper.

@Override
public PrismObjectWrapper<ShadowType> createObjectWrapper(PrismObject<ShadowType> object, ItemStatus status) {
    LOGGER.trace("create shadow wrapper");
    ShadowWrapper shadowWrapper = new ShadowWrapperImpl(object, status);
    LOGGER.trace("Shadow wrapper created: {}", shadowWrapper);
    return shadowWrapper;
}
Also used : ShadowWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.ShadowWrapperImpl) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)

Example 10 with ShadowWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.

the class PageMergeObjects method createMainPanel.

@Override
protected AbstractObjectMainPanel<UserType> createMainPanel(String id) {
    // empty assignments model
    CountableLoadableModel<AssignmentType> assignments = new CountableLoadableModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<AssignmentType> load() {
            return new ArrayList<>();
        }
    };
    // empty policy rules  model
    CountableLoadableModel<AssignmentType> policyRules = new CountableLoadableModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<AssignmentType> load() {
            return new ArrayList<>();
        }
    };
    // empty projections model
    LoadableModel<List<ShadowWrapper>> shadows = new LoadableModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ShadowWrapper> load() {
            return new ArrayList<>();
        }
    };
    return new FocusMainPanel<UserType>(id, getObjectModel(), shadows, this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ITab> createTabs(final PageAdminObjectDetails<UserType> parentPage) {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(parentPage.createStringResource("PageMergeObjects.tabTitle"), new VisibleEnableBehaviour()) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    mergeObjectsPanel = new MergeObjectsPanel<>(panelId, mergeObjectModel, mergeWithObjectModel, type, PageMergeObjects.this);
                    return mergeObjectsPanel;
                }
            });
            return tabs;
        }

        @Override
        protected boolean isPreviewButtonVisible() {
            return false;
        }

        @Override
        protected boolean getOptionsPanelVisibility() {
            return false;
        }
    };
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) MergeObjectsPanel(com.evolveum.midpoint.web.page.admin.users.component.MergeObjectsPanel) ArrayList(java.util.ArrayList) PageAdminObjectDetails(com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) CountableLoadableModel(com.evolveum.midpoint.gui.api.model.CountableLoadableModel) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) CountableLoadableModel(com.evolveum.midpoint.gui.api.model.CountableLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) FocusMainPanel(com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel) ArrayList(java.util.ArrayList) List(java.util.List) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

ShadowWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)10 ArrayList (java.util.ArrayList)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)1 CountableLoadableModel (com.evolveum.midpoint.gui.api.model.CountableLoadableModel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ShadowWrapperImpl (com.evolveum.midpoint.gui.impl.prism.wrapper.ShadowWrapperImpl)1 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 FocusMainPanel (com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel)1