Search in sources :

Example 1 with ConflictDto

use of com.evolveum.midpoint.web.page.self.dto.ConflictDto in project midpoint by Evolveum.

the class PageAssignmentConflicts method initLayout.

private void initLayout() {
    MidpointForm mainForm = new MidpointForm(ID_MAIN_FORM);
    mainForm.setOutputMarkupId(true);
    add(mainForm);
    RepeatingView conflictsPanel = new RepeatingView(ID_CONFLICTS_PANEL);
    conflictsPanel.setOutputMarkupId(true);
    List<ConflictDto> conflicts = getSessionStorage().getRoleCatalog().getConflictsList();
    for (ConflictDto dto : conflicts) {
        AssignmentConflictPanel panel = new AssignmentConflictPanel(conflictsPanel.newChildId(), Model.of(dto));
        conflictsPanel.add(panel);
    }
    mainForm.add(conflictsPanel);
    AjaxSubmitButton back = new AjaxSubmitButton(ID_BACK, createStringResource("PageAssignmentConflicts.back")) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(back);
    AjaxSubmitButton submit = new AjaxSubmitButton(ID_SUBMIT, createStringResource("PageAssignmentConflicts.submit")) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            processConflictDecisions();
            redirectBack();
        }
    };
    mainForm.add(submit);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ConflictDto(com.evolveum.midpoint.web.page.self.dto.ConflictDto) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) AssignmentConflictPanel(com.evolveum.midpoint.web.page.self.component.AssignmentConflictPanel)

Example 2 with ConflictDto

use of com.evolveum.midpoint.web.page.self.dto.ConflictDto in project midpoint by Evolveum.

the class PageAssignmentsList method fillInFromEvaluatedExclusionTrigger.

private void fillInFromEvaluatedExclusionTrigger(EvaluatedAssignment<UserType> evaluatedAssignment, EvaluatedExclusionTrigger exclusionTrigger, boolean isWarning, Map<String, ConflictDto> conflictsMap) {
    EvaluatedAssignment<F> conflictingAssignment = exclusionTrigger.getConflictingAssignment();
    PrismObject<F> addedAssignmentTargetObj = (PrismObject<F>) evaluatedAssignment.getTarget();
    PrismObject<F> exclusionTargetObj = (PrismObject<F>) conflictingAssignment.getTarget();
    AssignmentConflictDto<F> dto1 = new AssignmentConflictDto<>(exclusionTargetObj, conflictingAssignment.getAssignment(true) != null);
    AssignmentConflictDto<F> dto2 = new AssignmentConflictDto<>(addedAssignmentTargetObj, evaluatedAssignment.getAssignment(true) != null);
    ConflictDto conflict = new ConflictDto(dto1, dto2, isWarning);
    String oid1 = exclusionTargetObj.getOid();
    String oid2 = addedAssignmentTargetObj.getOid();
    if (!conflictsMap.containsKey(oid1 + oid2) && !conflictsMap.containsKey(oid2 + oid1)) {
        conflictsMap.put(oid1 + oid2, conflict);
    } else if (!isWarning) {
        // TODO Kate please review this
        if (conflictsMap.containsKey(oid1 + oid2)) {
            conflictsMap.replace(oid1 + oid2, conflict);
        }
        if (conflictsMap.containsKey(oid2 + oid1)) {
            conflictsMap.replace(oid2 + oid1, conflict);
        }
    }
}
Also used : AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) ConflictDto(com.evolveum.midpoint.web.page.self.dto.ConflictDto)

Example 3 with ConflictDto

use of com.evolveum.midpoint.web.page.self.dto.ConflictDto in project midpoint by Evolveum.

the class PageAssignmentsList method getAssignmentConflicts.

private List<ConflictDto> getAssignmentConflicts() {
    ObjectDelta<UserType> delta;
    OperationResult result = new OperationResult(OPERATION_PREVIEW_ASSIGNMENT_CONFLICTS);
    Task task = createSimpleTask(OPERATION_PREVIEW_ASSIGNMENT_CONFLICTS);
    Map<String, ConflictDto> conflictsMap = new HashMap<>();
    try {
        PrismObject<UserType> user = getTargetUser();
        delta = user.createModifyDelta();
        PrismContainerDefinition def = user.getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT);
        handleAssignmentDeltas(delta, getSessionStorage().getRoleCatalog().getAssignmentShoppingCart(), def);
        PartialProcessingOptionsType partialProcessing = new PartialProcessingOptionsType();
        partialProcessing.setInbound(SKIP);
        partialProcessing.setProjection(SKIP);
        ModelExecuteOptions recomputeOptions = executeOptions().partialProcessing(partialProcessing);
        ModelContext<UserType> modelContext = getModelInteractionService().previewChanges(MiscUtil.createCollection(delta), recomputeOptions, task, result);
        DeltaSetTriple<? extends EvaluatedAssignment> evaluatedAssignmentTriple = modelContext.getEvaluatedAssignmentTriple();
        if (evaluatedAssignmentTriple != null) {
            Collection<? extends EvaluatedAssignment> addedAssignments = evaluatedAssignmentTriple.getPlusSet();
            for (EvaluatedAssignment<UserType> evaluatedAssignment : addedAssignments) {
                for (EvaluatedPolicyRule policyRule : evaluatedAssignment.getAllTargetsPolicyRules()) {
                    if (!policyRule.containsEnabledAction()) {
                        continue;
                    }
                    // everything other than 'enforce' is a warning
                    boolean isWarning = !policyRule.containsEnabledAction(EnforcementPolicyActionType.class);
                    fillInConflictedObjects(evaluatedAssignment, policyRule.getAllTriggers(), isWarning, conflictsMap);
                }
            }
        } else if (!result.isSuccess() && StringUtils.isNotEmpty(getSubresultWarningMessages(result))) {
            getFeedbackMessages().warn(PageAssignmentsList.this, createStringResource("PageAssignmentsList.conflictsWarning").getString() + " " + getSubresultWarningMessages(result));
            conflictProblemExists = true;
        }
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get assignments conflicts. Reason: ", e);
        error("Couldn't get assignments conflicts. Reason: " + e);
    }
    return new ArrayList<>(conflictsMap.values());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) ConflictDto(com.evolveum.midpoint.web.page.self.dto.ConflictDto) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 4 with ConflictDto

use of com.evolveum.midpoint.web.page.self.dto.ConflictDto 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;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) ConflictDto(com.evolveum.midpoint.web.page.self.dto.ConflictDto)

Aggregations

ConflictDto (com.evolveum.midpoint.web.page.self.dto.ConflictDto)4 AssignmentConflictDto (com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto)3 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 AssignmentConflictPanel (com.evolveum.midpoint.web.page.self.component.AssignmentConflictPanel)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)1