Search in sources :

Example 1 with AssignmentEditorDto

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;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with AssignmentEditorDto

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;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 3 with AssignmentEditorDto

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);
    }
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 4 with AssignmentEditorDto

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;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 5 with AssignmentEditorDto

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;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Aggregations

AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)28 ArrayList (java.util.ArrayList)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)4 Task (com.evolveum.midpoint.task.api.Task)4 DelegationEditorPanel (com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 List (java.util.List)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)2 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)2 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 FocusTabVisibleBehavior (com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)2 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2