Search in sources :

Example 1 with AssignmentsPreviewDto

use of com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto in project midpoint by Evolveum.

the class DelegationEditorPanel method getPrivilegesNamesList.

private List<String> getPrivilegesNamesList() {
    List<String> privilegesNamesList = new ArrayList<>();
    List<AssignmentsPreviewDto> dtos = getModel().getObject().getPrivilegeLimitationList();
    if (dtos != null) {
        for (AssignmentsPreviewDto assignmentsPreviewDto : dtos) {
            privilegesNamesList.add(assignmentsPreviewDto.getTargetName());
        }
    }
    return privilegesNamesList;
}
Also used : AssignmentsPreviewDto(com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto) ArrayList(java.util.ArrayList)

Example 2 with AssignmentsPreviewDto

use of com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto in project midpoint by Evolveum.

the class PageAdminFocus method createAssignmentsPreviewDto.

private AssignmentsPreviewDto createAssignmentsPreviewDto(EvaluatedConstruction evaluatedConstruction) {
    AssignmentsPreviewDto dto = new AssignmentsPreviewDto();
    PrismObject<ResourceType> resource = evaluatedConstruction.getResource();
    dto.setTargetOid(resource.getOid());
    dto.setTargetName(PolyString.getOrig(resource.asObjectable().getName()));
    dto.setTargetDescription(resource.asObjectable().getDescription());
    dto.setTargetClass(resource.getCompileTimeClass());
    dto.setDirect(evaluatedConstruction.isDirectlyAssigned());
    dto.setKind(evaluatedConstruction.getKind());
    dto.setIntent(evaluatedConstruction.getIntent());
    return dto;
}
Also used : AssignmentsPreviewDto(com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto)

Example 3 with AssignmentsPreviewDto

use of com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto in project midpoint by Evolveum.

the class AssignmentEditorDto method getAssignmentPrivilegesList.

private List<AssignmentsPreviewDto> getAssignmentPrivilegesList(AssignmentType assignment) {
    List<AssignmentsPreviewDto> list = new ArrayList<>();
    AssignmentSelectorType assignmentSelectorType = assignment.getLimitTargetContent();
    if (assignmentSelectorType != null && assignmentSelectorType.getTargetRef() != null) {
        for (ObjectReferenceType objectRef : assignmentSelectorType.getTargetRef()) {
            AssignmentsPreviewDto dto = new AssignmentsPreviewDto();
            Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(objectRef.getType()).getClassDefinition();
            dto.setTargetClass(targetClass);
            dto.setTargetName(WebModelServiceUtils.resolveReferenceName(objectRef, pageBase, pageBase.createSimpleTask(OPERATION_LOAD_REFERENCE_OBJECT), new OperationResult(OPERATION_LOAD_REFERENCE_OBJECT)));
            dto.setTargetOid(objectRef.getOid());
            list.add(dto);
        }
    }
    return list;
}
Also used : AssignmentsPreviewDto(com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 4 with AssignmentsPreviewDto

use of com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto in project midpoint by Evolveum.

the class PageAdminFocus method recomputeAssignmentsPerformed.

public List<AssignmentsPreviewDto> recomputeAssignmentsPerformed(AjaxRequestTarget target) {
    LOGGER.debug("Recompute user assignments");
    Task task = createSimpleTask(OPERATION_RECOMPUTE_ASSIGNMENTS);
    OperationResult result = new OperationResult(OPERATION_RECOMPUTE_ASSIGNMENTS);
    ObjectDelta<F> delta;
    Set<AssignmentsPreviewDto> assignmentDtoSet = new TreeSet<>();
    try {
        reviveModels();
        ObjectWrapper<F> userWrapper = getObjectWrapper();
        delta = userWrapper.getObjectDelta();
        if (userWrapper.getOldDelta() != null) {
            delta = ObjectDelta.summarize(userWrapper.getOldDelta(), delta);
        }
        switch(userWrapper.getStatus()) {
            case ADDING:
                PrismObject<F> focus = delta.getObjectToAdd();
                prepareObjectForAdd(focus);
                getPrismContext().adopt(focus, getCompileTimeClass());
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Delta before add user:\n{}", new Object[] { delta.debugDump(3) });
                }
                if (!delta.isEmpty()) {
                    delta.revive(getPrismContext());
                } else {
                    result.recordSuccess();
                }
                break;
            case MODIFYING:
                prepareObjectDeltaForModify(delta);
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Delta before modify user:\n{}", new Object[] { delta.debugDump(3) });
                }
                List<ObjectDelta<? extends ObjectType>> accountDeltas = getShadowModifyDeltas(result);
                Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
                if (!delta.isEmpty()) {
                    delta.revive(getPrismContext());
                    deltas.add(delta);
                }
                for (ObjectDelta accDelta : accountDeltas) {
                    if (!accDelta.isEmpty()) {
                        accDelta.revive(getPrismContext());
                        deltas.add(accDelta);
                    }
                }
                break;
            default:
                error(getString("pageAdminFocus.message.unsupportedState", userWrapper.getStatus()));
        }
        ModelContext<UserType> modelContext = null;
        try {
            modelContext = getModelInteractionService().previewChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
        } catch (NoFocusNameSchemaException e) {
            info(getString("pageAdminFocus.message.noUserName"));
            target.add(getFeedbackPanel());
            return null;
        }
        DeltaSetTriple<? extends EvaluatedAssignment> evaluatedAssignmentTriple = modelContext.getEvaluatedAssignmentTriple();
        Collection<? extends EvaluatedAssignment> evaluatedAssignments = evaluatedAssignmentTriple.getNonNegativeValues();
        if (evaluatedAssignments.isEmpty()) {
            info(getString("pageAdminFocus.message.noAssignmentsAvailable"));
            target.add(getFeedbackPanel());
            return null;
        }
        for (EvaluatedAssignment<UserType> evaluatedAssignment : evaluatedAssignments) {
            if (!evaluatedAssignment.isValid()) {
                continue;
            }
            // roles and orgs
            DeltaSetTriple<? extends EvaluatedAssignmentTarget> evaluatedRolesTriple = evaluatedAssignment.getRoles();
            Collection<? extends EvaluatedAssignmentTarget> evaluatedRoles = evaluatedRolesTriple.getNonNegativeValues();
            for (EvaluatedAssignmentTarget role : evaluatedRoles) {
                if (role.isEvaluateConstructions()) {
                    assignmentDtoSet.add(createAssignmentsPreviewDto(role, task, result));
                }
            }
            // all resources
            DeltaSetTriple<EvaluatedConstruction> evaluatedConstructionsTriple = evaluatedAssignment.getEvaluatedConstructions(task, result);
            Collection<EvaluatedConstruction> evaluatedConstructions = evaluatedConstructionsTriple.getNonNegativeValues();
            for (EvaluatedConstruction construction : evaluatedConstructions) {
                assignmentDtoSet.add(createAssignmentsPreviewDto(construction));
            }
        }
        return new ArrayList<>(assignmentDtoSet);
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Could not create assignments preview.", e);
        error("Could not create assignments preview. Reason: " + e);
        target.add(getFeedbackPanel());
    }
    return null;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AssignmentsPreviewDto(com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) EvaluatedAssignmentTarget(com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget) EvaluatedConstruction(com.evolveum.midpoint.model.api.context.EvaluatedConstruction)

Example 5 with AssignmentsPreviewDto

use of com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto in project midpoint by Evolveum.

the class PageAdminFocus method createAssignmentsPreviewDto.

private AssignmentsPreviewDto createAssignmentsPreviewDto(PrismObject<? extends FocusType> targetObject, boolean isDirectlyAssigned, AssignmentType assignment, Task task, OperationResult result) {
    AssignmentsPreviewDto dto = new AssignmentsPreviewDto();
    dto.setTargetOid(targetObject.getOid());
    dto.setTargetName(getNameToDisplay(targetObject));
    dto.setTargetDescription(targetObject.asObjectable().getDescription());
    dto.setTargetClass(targetObject.getCompileTimeClass());
    dto.setTargetType(WebComponentUtil.classToQName(getPrismContext(), targetObject.getCompileTimeClass()));
    dto.setDirect(isDirectlyAssigned);
    if (assignment != null) {
        if (assignment.getTenantRef() != null) {
            dto.setTenantName(nameFromReference(assignment.getTenantRef(), task, result));
            dto.setTenantRef(assignment.getTenantRef());
        }
        if (assignment.getOrgRef() != null) {
            dto.setOrgRefName(nameFromReference(assignment.getOrgRef(), task, result));
            dto.setOrgRef(assignment.getOrgRef());
        }
        if (assignment.getTargetRef() != null) {
            dto.setRelation(assignment.getTargetRef().getRelation());
        }
    }
    return dto;
}
Also used : AssignmentsPreviewDto(com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto)

Aggregations

AssignmentsPreviewDto (com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)2 ArrayList (java.util.ArrayList)2 EvaluatedAssignmentTarget (com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget)1 EvaluatedConstruction (com.evolveum.midpoint.model.api.context.EvaluatedConstruction)1 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)1