use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageUser method processDeputyAssignments.
private boolean processDeputyAssignments(boolean previewOnly) {
boolean isAnythingChanged = false;
for (AssignmentEditorDto dto : getObjectDetailsModels().getDelegationsModelObject()) {
if (!UserDtoStatus.MODIFY.equals(dto.getStatus())) {
if (!previewOnly) {
UserType user = dto.getDelegationOwner();
saveDelegationToUser(user.asPrismObject(), dto);
}
isAnythingChanged = true;
}
}
return isAnythingChanged;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageUser method processAdditionalFocalObjectsForPreview.
/**
* for now used only for delegation changes
* @param modelContextMap preview changes deltas
*/
protected void processAdditionalFocalObjectsForPreview(Map<PrismObject<UserType>, ModelContext<? extends ObjectType>> modelContextMap) {
for (AssignmentEditorDto dto : getObjectDetailsModels().getDelegationsModelObject()) {
if (!UserDtoStatus.MODIFY.equals(dto.getStatus())) {
UserType user = dto.getDelegationOwner();
OperationResult result = new OperationResult(OPERATION_PREVIEW_CHANGES);
Task task = createSimpleTask(OPERATION_PREVIEW_CHANGES);
try {
Collection<ObjectDelta<? extends ObjectType>> deltas = prepareDelegationDelta(user.asPrismObject(), dto);
ModelContext<UserType> modelContext = getModelInteractionService().previewChanges(deltas, getDelegationPreviewOptions(), task, result);
modelContextMap.put(user.asPrismObject(), modelContext);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Could not save delegation ", e);
error("Could not save delegation. Reason: " + e);
} finally {
result.recomputeStatus();
}
}
}
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageUser method handleDelegationAssignmentDeltas.
protected void handleDelegationAssignmentDeltas(ObjectDelta<UserType> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition<AssignmentType> def) throws SchemaException {
ContainerDelta<AssignmentType> assDelta = def.createEmptyDelta(def.getItemName());
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue<AssignmentType> newValue = assDto.getNewValue(getPrismContext());
switch(assDto.getStatus()) {
case ADD:
newValue.applyDefinition(def, false);
assDelta.addValueToAdd(newValue.clone());
break;
case DELETE:
PrismContainerValue<AssignmentType> oldValue = assDto.getOldValue();
oldValue.applyDefinition(def, false);
assDelta.addValueToDelete(oldValue.clone());
break;
case MODIFY:
if (!assDto.isModified(getPrismContext())) {
LOGGER.trace("Assignment '{}' not modified.", assDto.getName());
continue;
}
handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
break;
default:
warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
}
}
if (!assDelta.isEmpty()) {
focusDelta.addModification(assDelta);
}
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class UserDelegationsPanel method initLayout.
protected void initLayout() {
WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
delegations.setOutputMarkupId(true);
add(delegations);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, getObjectDetailsModels().getDelegationsModel()) {
private static final long serialVersionUID = 1L;
@Override
public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, getObjectDetailsModels().getPrivilegesListModel());
item.add(editor);
}
@Override
public String getExcludeOid() {
return getObjectWrapper().getOid();
}
public IModel<String> getLabel() {
return createStringResource("FocusType.delegations");
}
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = getPrismContext().queryFactory().createInOid(getObjectWrapper().getOid());
ObjectFilter notFilter = getPrismContext().queryFactory().createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getPageBase().getMainPopupBodyId(), UserType.class, supportedTypes, false, getPageBase(), notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
getPageBase().hideMainPopup(target);
List<ObjectType> newAssignmentsList = new ArrayList<>();
newAssignmentsList.add(user);
addSelectedAssignablePerformed(target, newAssignmentsList, null, getPageBase().getMainPopup().getId());
}
};
panel.setOutputMarkupId(true);
getPageBase().showMainPopup(panel, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
}
return items;
}
@Override
protected String getNoAssignmentsSelectedMessage() {
return getString("AssignmentTablePanel.message.noDelegationsSelected");
}
@Override
protected String getAssignmentsDeleteMessage(AssignmentEditorDto dto) {
return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", getSelectedAssignments().size()).getString();
}
@Override
protected List<AssignmentEditorDto> getAssignmentListToProcess(AssignmentEditorDto dto) {
if (dto != null) {
return Collections.singletonList(dto);
} else {
return getSelectedAssignments();
}
}
@Override
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, QName relation, String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
window.close(target);
}
getPageBase().hideMainPopup(target);
if (newAssignments.isEmpty()) {
warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ObjectType object : newAssignments) {
try {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), WebComponentUtil.getDefaultRelationOrFail(RelationKindType.DELEGATION), getPageBase(), (UserType) object);
dto.setPrivilegeLimitationList(getPrivilegesListModel().getObject());
getDelegationModel().getObject().add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
}
}
reloadAssignmentsPanel(target);
reloadMainFormButtons(target);
}
};
delegations.add(panel);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAssignmentsList method getAssignmentsToRemoveList.
private List<AssignmentEditorDto> getAssignmentsToRemoveList(UserType user) {
List<ConflictDto> conflicts = getSessionStorage().getRoleCatalog().getConflictsList();
List<String> assignmentsToRemoveOids = new ArrayList<>();
for (ConflictDto dto : conflicts) {
if (dto.isResolved()) {
if (dto.getAssignment1().isResolved() && dto.getAssignment1().isOldAssignment()) {
assignmentsToRemoveOids.add(dto.getAssignment1().getAssignmentTargetObject().getOid());
} else if (dto.getAssignment2().isResolved() && dto.getAssignment2().isOldAssignment()) {
assignmentsToRemoveOids.add(dto.getAssignment2().getAssignmentTargetObject().getOid());
}
}
}
List<AssignmentEditorDto> assignmentsToDelete = new ArrayList<>();
for (AssignmentType assignment : user.getAssignment()) {
if (assignment.getTargetRef() == null) {
continue;
}
if (assignmentsToRemoveOids.contains(assignment.getTargetRef().getOid())) {
assignmentsToDelete.add(new AssignmentEditorDto(UserDtoStatus.DELETE, assignment, this));
}
}
return assignmentsToDelete;
}
Aggregations