use of com.evolveum.midpoint.web.component.prism.ContainerStatus in project midpoint by Evolveum.
the class PageAdminObjectDetails method loadObjectWrapper.
protected ObjectWrapper<O> loadObjectWrapper(PrismObject<O> objectToEdit) {
Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
OperationResult result = task.getResult();
PrismObject<O> object = null;
Collection<SelectorOptions<GetOperationOptions>> loadOptions = null;
try {
if (!isEditingFocus()) {
if (objectToEdit == null) {
LOGGER.trace("Loading object: New object (creating)");
O focusType = createNewObject();
getMidpointApplication().getPrismContext().adopt(focusType);
object = (PrismObject<O>) focusType.asPrismObject();
} else {
LOGGER.trace("Loading object: New object (supplied): {}", objectToEdit);
object = objectToEdit;
}
} else {
loadOptions = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
String focusOid = getObjectOidParameter();
object = WebModelServiceUtils.loadObject(getCompileTimeClass(), focusOid, loadOptions, this, task, result);
LOGGER.trace("Loading object: Existing object (loadled): {} -> {}", focusOid, object);
}
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get object.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
}
showResult(result, false);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded object:\n{}", object.debugDump());
}
if (object == null) {
if (isEditingFocus()) {
getSession().error(getString("pageAdminFocus.message.cantEditFocus"));
} else {
getSession().error(getString("pageAdminFocus.message.cantNewFocus"));
}
throw new RestartResponseException(getRestartResponsePage());
}
ContainerStatus status = isEditingFocus() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ObjectWrapper<O> wrapper;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
try {
wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, null, null, status, false);
}
wrapper.setLoadOptions(loadOptions);
showResult(wrapper.getResult(), false);
loadParentOrgs(wrapper, task, result);
wrapper.setShowEmpty(!isEditingFocus());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Loaded focus wrapper:\n{}", wrapper.debugDump());
}
return wrapper;
}
use of com.evolveum.midpoint.web.component.prism.ContainerStatus in project midpoint by Evolveum.
the class PageMyPasswordQuestions method loadUserWrapper.
private ObjectWrapper loadUserWrapper(PrismObject<UserType> userToEdit) {
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
PrismObject<UserType> user = null;
Task task = createSimpleTask(OPERATION_LOAD_USER);
try {
Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, task, result);
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user PageMyQuestions", ex);
}
showResult(result, false);
if (user == null) {
throw new RestartResponseException(PageDashboard.class);
}
ContainerStatus status = ContainerStatus.MODIFYING;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
ObjectWrapper wrapper;
try {
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, null, null, status, false);
}
// ObjectWrapper wrapper = new ObjectWrapper("pageUser.userDetails", null, user, status);
showResult(wrapper.getResult(), false);
return wrapper;
}
use of com.evolveum.midpoint.web.component.prism.ContainerStatus in project midpoint by Evolveum.
the class PrismContainerValueWrapperImpl method getChildContainers.
@Override
public List<PrismContainerDefinition<C>> getChildContainers() throws SchemaException {
List<PrismContainerDefinition<C>> childContainers = new ArrayList<>();
for (ItemDefinition<?> def : getContainerDefinition().getDefinitions()) {
if (!(def instanceof PrismContainerDefinition)) {
continue;
}
@SuppressWarnings("unchecked") PrismContainerDefinition<C> containerDef = (PrismContainerDefinition<C>) def;
ContainerStatus objectStatus = findObjectStatus();
boolean allowed = false;
switch(objectStatus) {
case ADDING:
allowed = containerDef.canAdd();
break;
case MODIFYING:
case DELETING:
allowed = containerDef.canModify();
}
// do not allow to add already existing singel value container
if (containerDef.isSingleValue() && findContainer(containerDef.getItemName()) != null) {
allowed = false;
}
if (allowed) {
childContainers.add(containerDef);
}
}
return childContainers;
}
Aggregations