use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class TestPolicyDrivenRoleLifecycle method test070ActivateCorrectHighRiskRole.
@Test
public void test070ActivateCorrectHighRiskRole() throws Exception {
// GIVEN
Task task = getTestTask();
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
when();
Holder<LensContext<?>> contextHolder = new Holder<>();
activateRole(roleCorrectHighRiskOid, contextHolder, task, result);
// THEN
then();
PrismObject<RoleType> roleAfter = getRole(roleCorrectHighRiskOid);
display("role after", roleAfter);
assertEquals("Wrong (changed) lifecycle state", SchemaConstants.LIFECYCLE_DRAFT, roleAfter.asObjectable().getLifecycleState());
dumpRules(contextHolder);
assertEquals("Wrong policy situation", emptyList(), roleAfter.asObjectable().getPolicySituation());
assertEquals("Wrong triggered policy rules", emptyList(), roleAfter.asObjectable().getTriggeredPolicyRule());
Collection<SelectorOptions<GetOperationOptions>> options = schemaService.getOperationOptionsBuilder().build();
List<PrismObject<CaseType>> cases = getCasesForObject(roleCorrectHighRiskOid, RoleType.COMPLEX_TYPE, options, task, result);
display("cases for role", cases);
assertEquals("Wrong # of approval cases for role", 2, cases.size());
CaseType approvalCase = getApprovalCase(cases);
ApprovalContextType wfc = approvalCase.getApprovalContext();
// assertEquals("Modification of correct-high-risk", wfc.getProcessInstanceName()); // MID-4200
assertEquals("wrong # of work items", 1, approvalCase.getWorkItem().size());
CaseWorkItemType workItem = approvalCase.getWorkItem().get(0);
assertEquals("wrong # of approval stages", 2, wfc.getApprovalSchema().getStage().size());
assertEquals("wrong # of attached policy rules", 2, wfc.getPolicyRules().getEntry().size());
caseService.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext), task, result);
approvalCase = modelService.getObject(CaseType.class, approvalCase.getOid(), options, task, result).asObjectable();
List<CaseWorkItemType> openWorkItems = approvalCase.getWorkItem().stream().filter(i -> i.getCloseTimestamp() == null).collect(Collectors.toList());
assertEquals("wrong # of open work items", 1, openWorkItems.size());
workItem = openWorkItems.get(0);
caseService.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext), task, result);
CaseType rootCase = getRootCase(cases);
waitForCaseClose(rootCase, 60000);
PrismObject<RoleType> roleAfterApproval = getRole(roleCorrectHighRiskOid);
display("role after approval", roleAfterApproval);
assertEquals("Wrong (unchanged) lifecycle state", SchemaConstants.LIFECYCLE_ACTIVE, roleAfterApproval.asObjectable().getLifecycleState());
assertEquals("Wrong policy situation", singletonList(SITUATION_ACTIVE_ROLE_WITH_NO_IDENTIFIER), roleAfterApproval.asObjectable().getPolicySituation());
// recording rules = none
assertEquals("Wrong triggered policy rules", emptyList(), roleAfterApproval.asObjectable().getTriggeredPolicyRule());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class CaseStageClosing method determineIfShouldContinue.
private boolean determineIfShouldContinue() {
if (stageDef.getEvaluationStrategy() == LevelEvaluationStrategyType.FIRST_DECIDES) {
if (differentOutcomes.size() > 1) {
LOGGER.warn("Ambiguous outcome with firstDecides strategy in {}: {} response(s), providing outcomes of {}", ApprovalContextUtil.getBriefDiagInfo(operation.getCurrentCase()), answeredWorkItems.size(), differentOutcomes);
answeredWorkItems.sort(Comparator.comparing(item -> XmlTypeConverter.toMillis(item.getCloseTimestamp()), Comparator.nullsLast(Comparator.naturalOrder())));
CaseWorkItemType first = answeredWorkItems.get(0);
boolean shouldContinue = ApprovalUtils.isApproved(first.getOutput());
LOGGER.warn("Possible race condition, so taking the first one: {} ({})", shouldContinue, first);
return shouldContinue;
} else if (differentOutcomes.size() == 1) {
return ApprovalUtils.isApproved(differentOutcomes.iterator().next()) && !differentOutcomes.isEmpty();
} else {
throw new IllegalStateException("No outcomes?");
}
} else {
return allApproved && !answeredWorkItems.isEmpty();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class CaseStageClosing method analyzeOutcomes.
private void analyzeOutcomes() {
allApproved = true;
for (CaseWorkItemType workItem : currentWorkItems) {
allApproved &= ApprovalUtils.isApproved(workItem.getOutput());
if (workItem.getCloseTimestamp() != null && workItem.getPerformerRef() != null) {
answeredWorkItems.add(workItem);
differentOutcomes.add(workItem.getOutput() != null ? workItem.getOutput().getOutcome() : null);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class CaseWorkItemSummaryPanel method getDisplayNameModel.
@Override
protected IModel<String> getDisplayNameModel() {
return new ReadOnlyModel<>(() -> {
CaseWorkItemType caseWorkItemType = CaseWorkItemSummaryPanel.this.getModelObject();
CaseType caseType = CaseTypeUtil.getCase(caseWorkItemType);
return defaultIfNull(WfGuiUtil.getLocalizedProcessName(caseType != null ? caseType.getApprovalContext() : null, CaseWorkItemSummaryPanel.this), caseWorkItemType != null ? WebComponentUtil.getTranslatedPolyString(caseWorkItemType.getName()) : null);
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class CaseWorkItemSummaryPanel method getTitleModel.
@Override
protected IModel<String> getTitleModel() {
return new IModel<String>() {
@Override
public String getObject() {
CaseWorkItemType caseWorkItemType = CaseWorkItemSummaryPanel.this.getModelObject();
CaseType caseType = CaseTypeUtil.getCase(caseWorkItemType);
Task task = CaseWorkItemSummaryPanel.this.getPageBase().createSimpleTask(OPERATION_LOAD_REQUESTOR_REFERENCE);
OperationResult result = new OperationResult(OPERATION_LOAD_REQUESTOR_REFERENCE);
PrismObject<UserType> requester = caseType != null ? WebModelServiceUtils.resolveReferenceNoFetch(caseType.getRequestorRef(), CaseWorkItemSummaryPanel.this.getPageBase(), task, result) : null;
if (requester == null) {
// MID-4539 if we don't have authorization to see requester
return getString("TaskSummaryPanel.requestedBy", getString("TaskSummaryPanel.unknown"));
}
String displayName = WebComponentUtil.getDisplayName(requester, true);
String name = WebComponentUtil.getName(requester, true);
if (displayName != null) {
return getString("TaskSummaryPanel.requestedByWithFullName", displayName, name);
} else {
return getString("TaskSummaryPanel.requestedBy", name);
}
}
};
}
Aggregations