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);
}
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);
}
}
}
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());
}
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;
}
Aggregations