Search in sources :

Example 31 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext 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 32 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class PrismObjectWrapperFactoryImpl method createValueWrapper.

@Override
public PrismContainerValueWrapper<O> createValueWrapper(PrismContainerWrapper<O> parent, PrismContainerValue<O> value, ValueStatus status, WrapperContext context) throws SchemaException {
    PrismContainerValueWrapper<O> objectValueWrapper = super.createValueWrapper(parent, value, status, context);
    if (CollectionUtils.isEmpty(context.getVirtualContainers())) {
        return objectValueWrapper;
    }
    for (VirtualContainersSpecificationType virtualContainer : context.getVirtualContainers()) {
        if (virtualContainer.getPath() != null) {
            continue;
        }
        MutableComplexTypeDefinition mCtd = getPrismContext().definitionFactory().createComplexTypeDefinition(VIRTUAL_CONTAINER_COMPLEX_TYPE);
        DisplayType display = virtualContainer.getDisplay();
        // TODO: support full polystring -> translations could be defined directly there.
        if (display == null || display.getLabel() == null) {
            mCtd.setDisplayName("N/A");
        } else {
            mCtd.setDisplayName(WebComponentUtil.getOrigStringFromPoly(display.getLabel()));
            mCtd.setHelp(WebComponentUtil.getOrigStringFromPoly(display.getHelp()));
        }
        mCtd.setRuntimeSchema(true);
        MutablePrismContainerDefinition<?> def = getPrismContext().definitionFactory().createContainerDefinition(VIRTUAL_CONTAINER, mCtd);
        def.setMaxOccurs(1);
        if (display != null && display.getLabel() != null) {
            def.setDisplayName(WebComponentUtil.getOrigStringFromPoly(display.getLabel()));
        }
        def.setDynamic(true);
        def.setRuntimeSchema(true);
        ItemWrapperFactory<?, ?, ?> factory = getRegistry().findWrapperFactory(def, null);
        if (factory == null) {
            LOGGER.warn("Cannot find factory for {}. Skipping wrapper creation.", def);
            continue;
        }
        WrapperContext ctx = context.clone();
        ctx.setVirtualItemSpecification(virtualContainer.getItem());
        PrismContainer<?> virtualPrismContainer = def.instantiate();
        ItemStatus virtualContainerStatus = context.getObjectStatus() != null ? context.getObjectStatus() : ItemStatus.NOT_CHANGED;
        ItemWrapper<?, ?> iw = factory.createWrapper(objectValueWrapper, virtualPrismContainer, virtualContainerStatus, ctx);
        if (iw == null) {
            continue;
        }
        if (iw instanceof PrismContainerWrapper) {
            PrismContainerWrapper<?> cw = (PrismContainerWrapper<?>) iw;
            cw.setIdentifier(virtualContainer.getIdentifier());
            cw.setVirtual(true);
            if (virtualContainer.isExpanded() != null) {
                cw.getValues().forEach(vw -> vw.setExpanded(virtualContainer.isExpanded()));
            }
        }
        iw.setVisibleOverwrite(virtualContainer.getVisibility());
        objectValueWrapper.addItem(iw);
    }
    return objectValueWrapper;
}
Also used : ItemStatus(com.evolveum.midpoint.gui.api.prism.ItemStatus) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)

Example 33 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class ValueMetadataWrapperFactoryImpl method createWrapper.

public PrismContainerWrapper<ValueMetadataType> createWrapper(PrismContainerValueWrapper<?> parent, Item childItem, ItemStatus status, WrapperContext context) throws SchemaException {
    WrapperContext ctx = context.clone();
    ctx.setMetadata(true);
    return super.createWrapper(parent, childItem, status, ctx);
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)

Example 34 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class ValueMetadataWrapperFactoryImpl method createValueWrapper.

@Override
public PrismContainerValueWrapper<ValueMetadataType> createValueWrapper(PrismContainerWrapper<ValueMetadataType> parent, PrismContainerValue<ValueMetadataType> value, ValueStatus status, WrapperContext context) throws SchemaException {
    WrapperContext ctx = context.clone();
    ctx.setMetadata(true);
    ctx.setCreateOperational(true);
    PrismContainerValueWrapper<ValueMetadataType> v = super.createValueWrapper(parent, value, status, ctx);
    return v;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType)

Example 35 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class FocusProjectionsPanel method createShadowWrapper.

private ShadowWrapper createShadowWrapper(ShadowType shadow) throws SchemaException {
    Task task = getPageBase().createSimpleTask(OPERATION_ADD_ACCOUNT);
    PrismObjectWrapperFactory<ShadowType> factory = getPageBase().findObjectWrapperFactory(shadow.asPrismContainer().getDefinition());
    WrapperContext context = new WrapperContext(task, task.getResult());
    ShadowWrapper wrapperNew = (ShadowWrapper) factory.createObjectWrapper(shadow.asPrismContainer(), ItemStatus.ADDED, context);
    if (task.getResult() != null && !WebComponentUtil.isSuccessOrHandledError(task.getResult())) {
        getPageBase().showResult(task.getResult(), false);
    }
    wrapperNew.setProjectionStatus(UserDtoStatus.ADD);
    return wrapperNew;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) Task(com.evolveum.midpoint.task.api.Task)

Aggregations

WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)46 Task (com.evolveum.midpoint.task.api.Task)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 Test (org.testng.annotations.Test)15 ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)11 ItemStatus (com.evolveum.midpoint.gui.api.prism.ItemStatus)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)7 RestartResponseException (org.apache.wicket.RestartResponseException)5 PrismObjectWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 QName (javax.xml.namespace.QName)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 NotNull (org.jetbrains.annotations.NotNull)3 PrismObjectWrapperFactory (com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory)2 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)2 ShadowWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)2 PrismPropertyValueWrapper (com.evolveum.midpoint.gui.impl.prism.wrapper.PrismPropertyValueWrapper)2