use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class PageResource method createTabsPanel.
private AjaxTabbedPanel<ITab> createTabsPanel() {
List<ITab> tabs = new ArrayList<>();
tabs.add(new PanelTab(createStringResource("PageResource.tab.details")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceDetailsTabPanel(panelId, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.content.tasks")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceTasksPanel(panelId, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.content.account")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceContentTabPanel(panelId, ShadowKindType.ACCOUNT, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.content.entitlement")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceContentTabPanel(panelId, ShadowKindType.ENTITLEMENT, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.content.generic")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceContentTabPanel(panelId, ShadowKindType.GENERIC, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.content.others")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceContentTabPanel(panelId, null, resourceModel);
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.connector")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceConnectorPanel(panelId, loadWrapperModel(resourceModel));
}
});
tabs.add(new PanelTab(createStringResource("PageResource.tab.schemaHandling")) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
PrismObjectWrapperFactory<ResourceType> resourceFactory = PageResource.this.findObjectWrapperFactory(resourceModel.getObject().getDefinition());
Task task = createSimpleTask("Create resource wrapper");
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper<ResourceType> resourceWrapper;
try {
resourceWrapper = resourceFactory.createObjectWrapper(resourceModel.getObject(), ItemStatus.NOT_CHANGED, ctx);
} catch (SchemaException e) {
resourceWrapper = null;
}
if (resourceWrapper == null) {
return new WebMarkupContainer(panelId);
}
return new ResourceSchemaHandlingTabPanel(panelId, PrismContainerWrapperModel.fromContainerWrapper(Model.of(resourceWrapper), ResourceType.F_SCHEMA_HANDLING));
}
});
AjaxTabbedPanel<ITab> resourceTabs = new AjaxTabbedPanel<ITab>(ID_TAB_PANEL, tabs) {
private static final long serialVersionUID = 1L;
@Override
protected void onTabChange(int index) {
updateBreadcrumbParameters(PARAMETER_SELECTED_TAB, index);
}
};
resourceTabs.setOutputMarkupId(true);
return resourceTabs;
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class WebComponentUtil method getAssociationExpression.
// TODO refactor..
@Deprecated
public static ExpressionType getAssociationExpression(PrismContainerValueWrapper<AssignmentType> assignmentValueWrapper, boolean createIfNotExist, PrismContext prismContext, PageBase pageBase) {
if (assignmentValueWrapper == null) {
return null;
}
if (createIfNotExist && prismContext == null) {
throw new IllegalArgumentException("createIfNotExist is set but prismContext is null");
}
PrismContainerWrapper<ResourceObjectAssociationType> association;
try {
association = assignmentValueWrapper.findContainer(ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION));
} catch (SchemaException e) {
LOGGER.error("Cannot find association wrapper, reason: {}", e.getMessage(), e);
pageBase.getSession().error("Cannot find association wrapper, reason: " + e.getMessage());
return null;
}
if (association == null || association.getValues() == null || association.getValues().size() == 0) {
return null;
}
PrismContainerValueWrapper<ResourceObjectAssociationType> associationValueWrapper = association.getValues().get(0);
PrismPropertyWrapper<ExpressionType> expressionWrapper;
try {
expressionWrapper = associationValueWrapper.findProperty(ItemPath.create(ResourceObjectAssociationType.F_OUTBOUND, MappingType.F_EXPRESSION));
} catch (SchemaException e) {
LOGGER.error("Cannot find expression wrapper, reason: {}", e.getMessage(), e);
pageBase.getSession().error("Cannot find expression wrapper, reason: " + e.getMessage());
return null;
}
if (expressionWrapper == null) {
return null;
}
List<PrismPropertyValueWrapper<ExpressionType>> expressionValues = expressionWrapper.getValues();
if (expressionValues == null || expressionValues.size() == 0) {
return null;
}
try {
ExpressionType expression = expressionValues.get(0).getRealValue();
if (expression == null && createIfNotExist) {
expression = new ExpressionType();
PrismPropertyValue<ExpressionType> exp = prismContext.itemFactory().createPropertyValue(expression);
WrapperContext context = new WrapperContext(null, null);
PrismPropertyValueWrapper<ExpressionType> val = (PrismPropertyValueWrapper<ExpressionType>) pageBase.createValueWrapper(expressionWrapper, exp, ValueStatus.ADDED, context);
// ValueWrapperOld<ExpressionType> val = new
// ValueWrapperOld<>(expressionWrapper, exp, prismContext);
expressionValues.remove(0);
expressionValues.add(0, val);
}
} catch (SchemaException e) {
// TODO erro handling
return null;
}
return expressionValues.get(0).getRealValue();
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class WebPrismUtil method createNewValueWrapper.
public static <IW extends ItemWrapper, PV extends PrismValue, VW extends PrismValueWrapper> VW createNewValueWrapper(IW itemWrapper, PV newValue, ValueStatus status, ModelServiceLocator modelServiceLocator) throws SchemaException {
LOGGER.debug("Adding value to {}", itemWrapper);
Task task = modelServiceLocator.createSimpleTask(OPERATION_CREATE_NEW_VALUE);
OperationResult result = task.getResult();
WrapperContext context = new WrapperContext(task, result);
context.setObjectStatus(itemWrapper.findObjectStatus());
context.setShowEmpty(true);
context.setCreateIfEmpty(true);
VW newValueWrapper = modelServiceLocator.createValueWrapper(itemWrapper, newValue, status, context);
result.recordSuccess();
return newValueWrapper;
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class WebPrismUtil method createNewValueWrapper.
public static <IW extends ItemWrapper, PV extends PrismValue, VW extends PrismValueWrapper> VW createNewValueWrapper(IW itemWrapper, PV newValue, PageBase pageBase, AjaxRequestTarget target) {
LOGGER.debug("Adding value to {}", itemWrapper);
Task task = pageBase.createSimpleTask(OPERATION_CREATE_NEW_VALUE);
OperationResult result = task.getResult();
VW newValueWrapper = null;
try {
if (!(itemWrapper instanceof PrismContainerWrapper)) {
itemWrapper.getItem().add(newValue);
}
WrapperContext context = new WrapperContext(task, result);
context.setObjectStatus(itemWrapper.findObjectStatus());
context.setShowEmpty(true);
context.setCreateIfEmpty(true);
newValueWrapper = pageBase.createValueWrapper(itemWrapper, newValue, ValueStatus.ADDED, context);
itemWrapper.getValues().add(newValueWrapper);
result.recordSuccess();
} catch (SchemaException e) {
LOGGER.error("Cannot create new value for {}", itemWrapper, e);
result.recordFatalError(pageBase.createStringResource("WebPrismUtil.message.createNewValueWrapper.fatalError", newValue, e.getMessage()).getString(), e);
target.add(pageBase.getFeedbackPanel());
}
return newValueWrapper;
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class PageResource method loadWrapperModel.
private LoadableModel<PrismObjectWrapper<ResourceType>> loadWrapperModel(IModel<PrismObject<ResourceType>> resourceModel) {
return new LoadableModel<>(false) {
@Override
protected PrismObjectWrapper<ResourceType> load() {
PrismObject<ResourceType> resource = resourceModel.getObject();
PrismObjectWrapperFactory<ResourceType> factory = findObjectWrapperFactory(resource.getDefinition());
Task task = createSimpleTask("createWrapper");
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
ctx.setCreateIfEmpty(true);
try {
return factory.createObjectWrapper(resource, ItemStatus.NOT_CHANGED, ctx);
} catch (SchemaException e) {
// TODO:
return null;
}
}
};
}
Aggregations