private void reloadOwnerChangeModel(String accountOid, String ownerOid) { ownerChangeModel.reset(); AccountOwnerChangeDto changeDto = ownerChangeModel.getObject(); changeDto.setAccountOid(accountOid); changeDto.setAccountType(ShadowType.COMPLEX_TYPE); changeDto.setOldOwnerOid(ownerOid); }
private void ownerChangePerformed(AjaxRequestTarget target, UserType user) { AccountOwnerChangeDto dto = ownerChangeModel.getObject(); OperationResult result = new OperationResult(OPERATION_CHANGE_OWNER); try { Task task = createSimpleTask(OPERATION_CHANGE_OWNER); if (StringUtils.isNotEmpty(dto.getOldOwnerOid())) { ObjectDelta delta = new ObjectDelta(UserType.class, ChangeType.MODIFY, getPrismContext()); delta.setOid(dto.getOldOwnerOid()); PrismReferenceValue refValue = new PrismReferenceValue(dto.getAccountOid()); refValue.setTargetType(dto.getAccountType()); delta.addModification( ReferenceDelta.createModificationDelete( UserType.class, UserType.F_LINK_REF, getPrismContext(), refValue)); getModelService() .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result); } if (user != null) { ObjectDelta delta = new ObjectDelta(UserType.class, ChangeType.MODIFY, getPrismContext()); delta.setOid(user.getOid()); PrismReferenceValue refValue = new PrismReferenceValue(dto.getAccountOid()); refValue.setTargetType(dto.getAccountType()); delta.addModification( ReferenceDelta.createModificationAdd( UserType.class, UserType.F_LINK_REF, getPrismContext(), refValue)); getModelService() .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result); } result.recomputeStatus(); } catch (Exception ex) { result.recordFatalError("Couldn't submit user.", ex); LoggingUtils.logException(LOGGER, "Couldn't submit user", ex); } showResult(result); target.add(getFeedbackPanel()); }