use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAdminFocus method handleAssignmentDeltas.
protected ContainerDelta handleAssignmentDeltas(ObjectDelta<F> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition def, boolean isDelegation) throws SchemaException {
ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue newValue = assDto.getNewValue(getPrismContext());
switch(assDto.getStatus()) {
case ADD:
newValue.applyDefinition(def, false);
assDelta.addValueToAdd(newValue.clone());
break;
case DELETE:
PrismContainerValue oldValue = assDto.getOldValue();
if (isDelegation) {
oldValue.applyDefinition(def, false);
} else {
oldValue.applyDefinition(def);
}
assDelta.addValueToDelete(oldValue.clone());
break;
case MODIFY:
if (!assDto.isModified(getPrismContext())) {
LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
continue;
}
handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
break;
default:
warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
}
}
if (!assDelta.isEmpty()) {
assDelta = focusDelta.addModification(assDelta);
}
// todo remove this block [lazyman] after model is updated - it has to
// remove resource from accountConstruction
Collection<PrismContainerValue> values = assDelta.getValues(PrismContainerValue.class);
for (PrismContainerValue value : values) {
AssignmentType ass = new AssignmentType();
ass.setupContainerValue(value);
removeResourceFromAccConstruction(ass);
}
return assDelta;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAdminFocus method loadAssignments.
private List<AssignmentEditorDto> loadAssignments() {
List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
PrismObject<F> focus = focusWrapper.getObject();
List<AssignmentType> assignments = focus.asObjectable().getAssignment();
for (AssignmentType assignment : assignments) {
if (isAssignmentRelevant(assignment)) {
list.add(new AssignmentEditorDto(StringUtils.isEmpty(focusWrapper.getOid()) ? UserDtoStatus.ADD : UserDtoStatus.MODIFY, assignment, this));
}
}
Collections.sort(list);
return list;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAdminFocus method handleAssignmentForAdd.
protected void handleAssignmentForAdd(PrismObject<F> focus, QName containerName, List<AssignmentEditorDto> assignments) throws SchemaException {
PrismObjectDefinition<F> userDef = focus.getDefinition();
PrismContainerDefinition<AssignmentType> assignmentDef = userDef.findContainerDefinition(containerName);
// handle added assignments
// existing user assignments are not relevant -> delete them
PrismContainer<AssignmentType> assignmentContainer = focus.findOrCreateContainer(containerName);
if (assignmentContainer != null && !assignmentContainer.isEmpty()) {
assignmentContainer.clear();
}
// List<AssignmentEditorDto> assignments = getFocusAssignments();
for (AssignmentEditorDto assDto : assignments) {
if (UserDtoStatus.DELETE.equals(assDto.getStatus())) {
continue;
}
AssignmentType assignment = new AssignmentType();
PrismContainerValue<AssignmentType> value = assDto.getNewValue(getPrismContext());
assignment.setupContainerValue(value);
value.applyDefinition(assignmentDef, false);
assignmentContainer.add(assignment.clone().asPrismContainerValue());
// todo remove this block [lazyman] after model is updated - it has
// to remove resource from accountConstruction
removeResourceFromAccConstruction(assignment);
}
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageRequestRole method loadAssignments.
private List<AssignmentEditorDto> loadAssignments() {
List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
List<AssignmentType> assignments = user.asObjectable().getAssignment();
for (AssignmentType assignment : assignments) {
list.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, this));
}
Collections.sort(list);
return list;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAssignmentsList method addAssignmentsToUser.
private List<AssignmentEditorDto> addAssignmentsToUser(UserType user) {
List<String> assignmentsToDeselect = getAssignmentsToDeselectList(user);
List<AssignmentEditorDto> assignmentsToRemove = getAssignmentsToRemoveList(user);
List<AssignmentEditorDto> assignmentsList = new ArrayList<>();
assignmentsList.addAll(assignmentsToRemove);
if (assignmentsModel != null && assignmentsModel.getObject() != null) {
for (AssignmentEditorDto assignmentsToAdd : assignmentsModel.getObject()) {
if (!assignmentsToDeselect.contains(assignmentsToAdd.getTargetRef().getOid())) {
assignmentsToAdd.setStatus(UserDtoStatus.ADD);
assignmentsList.add(assignmentsToAdd);
}
}
}
return assignmentsList;
}
Aggregations