use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class PageAdminFocus method getForceDeleteDelta.
private ObjectDelta getForceDeleteDelta(ObjectWrapper focusWrapper) throws SchemaException {
List<FocusSubwrapperDto<ShadowType>> accountDtos = getFocusShadows();
List<ReferenceDelta> refDeltas = new ArrayList<ReferenceDelta>();
ObjectDelta<F> forceDeleteDelta = null;
for (FocusSubwrapperDto<ShadowType> accDto : accountDtos) {
if (!accDto.isLoadedOK()) {
continue;
}
if (accDto.getStatus() == UserDtoStatus.DELETE) {
ObjectWrapper accWrapper = accDto.getObject();
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject());
refDeltas.add(refDelta);
} else if (accDto.getStatus() == UserDtoStatus.UNLINK) {
ObjectWrapper accWrapper = accDto.getObject();
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject().getOid());
refDeltas.add(refDelta);
}
}
if (!refDeltas.isEmpty()) {
forceDeleteDelta = ObjectDelta.createModifyDelta(focusWrapper.getObject().getOid(), refDeltas, getCompileTimeClass(), getPrismContext());
}
PrismContainerDefinition def = focusWrapper.getObject().findContainer(UserType.F_ASSIGNMENT).getDefinition();
if (forceDeleteDelta == null) {
forceDeleteDelta = ObjectDelta.createEmptyModifyDelta(getCompileTimeClass(), focusWrapper.getObject().getOid(), getPrismContext());
}
handleAssignmentDeltas(forceDeleteDelta, getFocusAssignments(), def);
return forceDeleteDelta;
}
use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class PageAdminFocus method getShadowModifyDeltas.
private List<ObjectDelta<? extends ObjectType>> getShadowModifyDeltas(OperationResult result) {
List<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
OperationResult subResult = null;
for (FocusSubwrapperDto<ShadowType> account : accounts) {
if (!account.isLoadedOK()) {
continue;
}
try {
ObjectWrapper accountWrapper = account.getObject();
ObjectDelta delta = accountWrapper.getObjectDelta();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from {} as:\n{}", new Object[] { accountWrapper, delta.debugDump(3) });
}
if (!UserDtoStatus.MODIFY.equals(account.getStatus())) {
continue;
}
if (delta.isEmpty() && (accountWrapper.getOldDelta() == null || accountWrapper.getOldDelta().isEmpty())) {
continue;
}
if (accountWrapper.getOldDelta() != null) {
delta = ObjectDelta.summarize(delta, accountWrapper.getOldDelta());
}
// what is this???
// subResult = result.createSubresult(OPERATION_MODIFY_ACCOUNT);
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Modifying account:\n{}", new Object[] { delta.debugDump(3) });
}
deltas.add(delta);
// subResult.recordSuccess();
} catch (Exception ex) {
// if (subResult != null) {
result.recordFatalError("Couldn't compute account delta.", ex);
// }
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't compute account delta", ex);
}
}
return deltas;
}
use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class PageAdminFocus method loadSubwrappers.
private <S extends ObjectType> List<FocusSubwrapperDto<S>> loadSubwrappers(Class<S> type, QName propertyToLoad, boolean noFetch) {
List<FocusSubwrapperDto<S>> list = new ArrayList<>();
ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
PrismObject<F> focus = focusWrapper.getObject();
PrismReference prismReference = focus.findReference(new ItemPath(propertyToLoad));
if (prismReference == null) {
return new ArrayList<>();
}
List<PrismReferenceValue> references = prismReference.getValues();
Task task = createSimpleTask(OPERATION_LOAD_SHADOW);
for (PrismReferenceValue reference : references) {
FocusSubwrapperDto<S> subWrapper = loadSubWrapperDto(type, reference.getOid(), noFetch, task);
if (subWrapper != null) {
list.add(subWrapper);
}
}
return list;
}
use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class PageAdminFocus method prepareUserAccountsDeltaForModify.
private ReferenceDelta prepareUserAccountsDeltaForModify(PrismReferenceDefinition refDef) throws SchemaException {
ReferenceDelta refDelta = new ReferenceDelta(refDef, getPrismContext());
List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
for (FocusSubwrapperDto<ShadowType> accDto : accounts) {
if (accDto.isLoadedOK()) {
ObjectWrapper accountWrapper = accDto.getObject();
accountWrapper.revive(getPrismContext());
ObjectDelta delta = accountWrapper.getObjectDelta();
PrismReferenceValue refValue = new PrismReferenceValue(null, OriginType.USER_ACTION, null);
PrismObject<ShadowType> account;
switch(accDto.getStatus()) {
case ADD:
account = delta.getObjectToAdd();
addDefaultKindAndIntent(account);
WebComponentUtil.encryptCredentials(account, true, getMidpointApplication());
refValue.setObject(account);
refDelta.addValueToAdd(refValue);
break;
case DELETE:
account = accountWrapper.getObject();
refValue.setObject(account);
refDelta.addValueToDelete(refValue);
break;
case MODIFY:
// before
continue;
case UNLINK:
refValue.setOid(delta.getOid());
refValue.setTargetType(ShadowType.COMPLEX_TYPE);
refDelta.addValueToDelete(refValue);
break;
default:
warn(getString("pageAdminFocus.message.illegalAccountState", accDto.getStatus()));
}
}
}
return refDelta;
}
use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method initLayout.
private void initLayout(final PageBase page) {
final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
shadows.setOutputMarkupId(true);
add(shadows);
InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
accountMenu.setVisible(!getObjectWrapper().isReadonly());
shadows.add(accountMenu);
final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
PackageResourceReference packageRef;
final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
final Panel shadowPanel;
if (dto.isLoadedOK()) {
packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
} else {
shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onShowMorePerformed(AjaxRequestTarget target) {
OperationResult fetchResult = dto.getResult();
if (fetchResult != null) {
showResult(fetchResult);
target.add(page.getFeedbackPanel());
}
}
};
}
shadowPanel.setOutputMarkupId(true);
shadowPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
return !shadowWrapper.isMinimalized();
}
});
item.add(shadowPanel);
CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {
private static final long serialVersionUID = 1L;
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
super.onClickPerformed(target);
onExpandCollapse(target, item.getModel());
target.add(shadows);
}
};
if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
}
item.add(shadowHeader);
}
};
AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
if (dto.isLoadedOK()) {
ObjectWrapper<ShadowType> accModel = dto.getObject();
accModel.setSelected(getModelObject());
}
}
target.add(shadows);
}
};
shadows.add(accountCheckAll);
shadows.add(projectionList);
}
Aggregations