use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext 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;
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class MetadataWrapperFactoryImpl method createWrapper.
@Override
public PrismContainerWrapper<C> createWrapper(PrismContainerValueWrapper<?> parent, ItemDefinition<?> def, WrapperContext context) throws SchemaException {
WrapperContext ctx = context.clone();
ctx.setReadOnly(true);
ctx.setMetadata(true);
PrismContainerWrapper<C> wrapper = super.createWrapper(parent, def, ctx);
return wrapper;
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class ExpressionPropertyPanel method expressionValueAddPerformed.
private void expressionValueAddPerformed(AjaxRequestTarget target, ExpressionValueTypes expressionType) {
getPageBase().hideMainPopup(target);
try {
ExpressionType newExpressionValue = new ExpressionType();
if (ExpressionValueTypes.SHADOW_REF_EXPRESSION.equals(expressionType)) {
ExpressionUtil.addShadowRefEvaluatorValue(newExpressionValue, null, getPrismContext());
} else if (ExpressionValueTypes.ASSOCIATION_TARGET_SEARCH_EXPRESSION.equals(expressionType)) {
ExpressionUtil.getOrCreateAssociationTargetSearchValues(newExpressionValue, getPrismContext());
} else if (ExpressionValueTypes.LITERAL_VALUE_EXPRESSION.equals(expressionType)) {
ExpressionUtil.updateLiteralExpressionValue(newExpressionValue, Collections.singletonList(""), getPrismContext());
}
WrapperContext context = new WrapperContext(null, null);
PrismPropertyValue<ExpressionType> expressionValue = getPageBase().getPrismContext().itemFactory().createPropertyValue(newExpressionValue);
PrismPropertyValueWrapper<ExpressionType> newExpressionValueWrapper = getPageBase().createValueWrapper(getModelObject(), expressionValue, ValueStatus.ADDED, context);
getModelObject().getValues().clear();
getModelObject().getValues().add(newExpressionValueWrapper);
getModelObject().getItem().setRealValue(newExpressionValue);
} catch (SchemaException ex) {
LOGGER.error("Unable to create new expression value: {}", ex.getLocalizedMessage());
}
target.add(ExpressionPropertyPanel.this);
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class ConfigurationStep method createConfigContainerWrappers.
// @NotNull
private PrismContainerWrapper<ConnectorConfigurationType> createConfigContainerWrappers() throws SchemaException {
PrismObject<ResourceType> resource = resourceModelNoFetch.getObject();
PrismContainer<ConnectorConfigurationType> configuration = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
if (parentPage.isNewResource()) {
return null;
}
ItemStatus configurationStatus = ItemStatus.NOT_CHANGED;
if (configuration == null) {
PrismObject<ConnectorType> connector = ResourceTypeUtil.getConnectorIfPresent(resource);
if (connector == null) {
throw new IllegalStateException("No resolved connector object in resource object");
}
ConnectorType connectorType = connector.asObjectable();
PrismSchema schema;
try {
schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, parentPage.getPrismContext());
} catch (SchemaException e) {
throw new SystemException("Couldn't parse connector schema: " + e.getMessage(), e);
}
PrismContainerDefinition<ConnectorConfigurationType> definition = ConnectorTypeUtil.findConfigurationContainerDefinition(connectorType, schema);
// Fixing (errorneously) set maxOccurs = unbounded. See MID-2317 and related issues.
PrismContainerDefinition<ConnectorConfigurationType> definitionFixed = definition.clone();
definitionFixed.toMutable().setMaxOccurs(1);
configuration = definitionFixed.instantiate();
configurationStatus = ItemStatus.ADDED;
}
Task task = getPageBase().createSimpleTask(OPERATION_CREATE_CONFIGURATION_WRAPPERS);
WrapperContext ctx = new WrapperContext(task, getResult());
ctx.setReadOnly(parentPage.isReadOnly());
ctx.setShowEmpty(ItemStatus.ADDED == configurationStatus);
return getPageBase().createItemWrapper(configuration, configurationStatus, ctx);
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class ContainerListDataProvider method internalIterator.
@Override
public Iterator<? extends PrismContainerValueWrapper<C>> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", first, count);
getAvailableData().clear();
Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_CONTAINERS);
OperationResult result = task.getResult();
try {
ObjectPaging paging = createPaging(first, count);
ObjectQuery query = getQuery();
if (query == null) {
query = getPrismContext().queryFactory().createQuery();
}
query.setPaging(paging);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} with {}", getType().getSimpleName(), query.debugDump());
}
List<C> list = WebModelServiceUtils.searchContainers(getType(), query, options, result, getPageBase());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} containers", getType().getSimpleName(), list.size());
}
for (C object : list) {
WrapperContext context = new WrapperContext(task, result);
PrismContainerWrapperFactory<C> factory = getPageBase().findContainerWrapperFactory(object.asPrismContainerValue().getDefinition());
getAvailableData().add(factory.createValueWrapper(null, object.asPrismContainerValue(), ValueStatus.NOT_CHANGED, context));
}
} catch (Exception ex) {
result.recordFatalError(getPageBase().createStringResource("ContainerListDataProvider.message.listContainers.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list containers", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageError.class);
}
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
Aggregations