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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations