use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertOpenerHelper method getDeltasToCreateCases.
/**
* Creates certification cases (in the form of delta list) on first stage opening.
*/
private <F extends FocusType> void getDeltasToCreateCases(AccessCertificationCampaignType campaign, AccessCertificationStageType stage, CertificationHandler handler, ModificationsToExecute modifications, OpeningContext openingContext, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
String campaignShortName = toShortString(campaign);
AccessCertificationScopeType scope = campaign.getScopeDefinition();
LOGGER.trace("Creating cases for scope {} in campaign {}", scope, campaignShortName);
if (scope != null && !(scope instanceof AccessCertificationObjectBasedScopeType)) {
throw new IllegalStateException("Unsupported access certification scope type: " + scope.getClass() + " for campaign " + campaignShortName);
}
AccessCertificationObjectBasedScopeType objectBasedScope = (AccessCertificationObjectBasedScopeType) scope;
assertNoExistingCases(campaign, result);
TypedObjectQuery<F> typedQuery = prepareObjectQuery(objectBasedScope, handler, campaignShortName);
List<AccessCertificationCaseType> caseList = new ArrayList<>();
// create certification cases by executing the query and caseExpression on its results
// here the subclasses of this class come into play
repositoryService.searchObjectsIterative(typedQuery.getObjectClass(), typedQuery.getObjectQuery(), (object, parentResult) -> {
try {
caseList.addAll(handler.createCasesForObject(object, campaign, task, parentResult));
} catch (CommonException | RuntimeException e) {
// TODO process the exception more intelligently
throw new SystemException("Cannot create certification case for object " + toShortString(object.asObjectable()) + ": " + e.getMessage(), e);
}
return true;
}, null, true, result);
AccessCertificationReviewerSpecificationType reviewerSpec = reviewersHelper.findReviewersSpecification(campaign, 1);
assert norm(campaign.getIteration()) == 1;
for (AccessCertificationCaseType acase : caseList) {
ContainerDelta<AccessCertificationCaseType> caseDelta = prismContext.deltaFactory().container().createDelta(F_CASE, AccessCertificationCampaignType.class);
acase.setIteration(1);
acase.setStageNumber(1);
acase.setCurrentStageCreateTimestamp(stage.getStartTimestamp());
acase.setCurrentStageDeadline(stage.getDeadline());
List<ObjectReferenceType> reviewers = reviewersHelper.getReviewersForCase(acase, campaign, reviewerSpec, task, result);
acase.getWorkItem().addAll(createWorkItems(reviewers, 1, 1, acase));
openingContext.workItemsCreated += acase.getWorkItem().size();
openingContext.casesEnteringStage++;
AccessCertificationResponseType currentStageOutcome = computationHelper.computeOutcomeForStage(acase, campaign, 1);
acase.setCurrentStageOutcome(toUri(currentStageOutcome));
acase.setOutcome(toUri(computationHelper.computeOverallOutcome(acase, campaign, 1, currentStageOutcome)));
@SuppressWarnings({ "raw", "unchecked" }) PrismContainerValue<AccessCertificationCaseType> caseCVal = acase.asPrismContainerValue();
caseDelta.addValueToAdd(caseCVal);
LOGGER.trace("Adding certification case:\n{}", caseCVal.debugDumpLazily());
modifications.add(caseDelta);
}
LOGGER.trace("Created {} deltas (in {} batches) to create {} cases ({} work items) for campaign {}", modifications.getTotalDeltasCount(), modifications.batches.size(), caseList.size(), openingContext.workItemsCreated, campaignShortName);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertOpenerHelper method createCasesReiterationDeltas.
private void createCasesReiterationDeltas(AccessCertificationCampaignType campaign, int newIteration, ModificationsToExecute modifications, OperationResult result) throws SchemaException {
ObjectQuery unresolvedCasesQuery = prismContext.queryFor(AccessCertificationCaseType.class).item(AccessCertificationCaseType.F_OUTCOME).eq(SchemaConstants.MODEL_CERTIFICATION_OUTCOME_NO_RESPONSE).build();
List<AccessCertificationCaseType> unresolvedCases = queryHelper.searchCases(campaign.getOid(), unresolvedCasesQuery, null, result);
for (AccessCertificationCaseType aCase : unresolvedCases) {
modifications.add(prismContext.deltaFor(AccessCertificationCampaignType.class).item(F_CASE, aCase.getId(), F_ITERATION).replace(newIteration).item(F_CASE, aCase.getId(), F_STAGE_NUMBER).replace(0).item(F_CASE, aCase.getId(), F_CURRENT_STAGE_OUTCOME).replace().item(F_CASE, aCase.getId(), F_CURRENT_STAGE_DEADLINE).replace().item(F_CASE, aCase.getId(), F_CURRENT_STAGE_CREATE_TIMESTAMP).replace().item(F_CASE, aCase.getId(), F_REVIEW_FINISHED_TIMESTAMP).replace().asItemDeltas());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertCloserHelper method createWorkItemsCloseDeltas.
private void createWorkItemsCloseDeltas(AccessCertificationCampaignType campaign, ModificationsToExecute modifications, XMLGregorianCalendar now, OperationResult result) throws SchemaException {
ObjectQuery query = CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaign.getOid(), prismContext);
List<AccessCertificationWorkItemType> openWorkItems = queryHelper.searchOpenWorkItems(query, null, false, null, result);
LOGGER.debug("There are {} open work items for {}", openWorkItems.size(), ObjectTypeUtil.toShortString(campaign));
for (AccessCertificationWorkItemType workItem : openWorkItems) {
AccessCertificationCaseType aCase = CertCampaignTypeUtil.getCaseChecked(workItem);
modifications.add(prismContext.deltaFor(AccessCertificationCampaignType.class).item(F_CASE, aCase.getId(), F_WORK_ITEM, workItem.getId(), F_CLOSE_TIMESTAMP).replace(now).asItemDelta());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class TestParseCertificationCase method assertJaxb.
private void assertJaxb(AccessCertificationCaseType aCase) throws SchemaException {
PrismAsserts.assertRefEquivalent("Wrong objectRef", getPrismContext().itemFactory().createReferenceValue("ee53eba7-5c16-4c16-ad15-dd6a2360ab1a", UserType.COMPLEX_TYPE), aCase.getObjectRef().asReferenceValue());
PrismAsserts.assertRefEquivalent("Wrong targetRef", getPrismContext().itemFactory().createReferenceValue("ef2bc95b-76e0-48e2-86d6-3d4f02d3e1a2", ResourceType.COMPLEX_TYPE), aCase.getTargetRef().asReferenceValue());
assertTrue(aCase instanceof AccessCertificationAssignmentCaseType);
AccessCertificationAssignmentCaseType assignmentCase = (AccessCertificationAssignmentCaseType) aCase;
assertNotNull("no assignment", assignmentCase.getAssignment());
assertEquals((Long) 1L, assignmentCase.getAssignment().getId());
PrismAsserts.assertRefEquivalent("Wrong resourceRef in assignment", getPrismContext().itemFactory().createReferenceValue("ef2bc95b-76e0-48e2-86d6-3d4f02d3e1a2", ResourceType.COMPLEX_TYPE), assignmentCase.getAssignment().getConstruction().getResourceRef().asReferenceValue());
assertEquals("wrong isInducement", Boolean.FALSE, assignmentCase.isIsInducement());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class CertificationTest method addUnansweredActiveCases.
private void addUnansweredActiveCases(List<AccessCertificationCaseType> expectedCases, List<AccessCertificationCaseType> caseList, AccessCertificationCampaignType campaign) {
for (AccessCertificationCaseType aCase : caseList) {
if (aCase.getStageNumber() != campaign.getStageNumber()) {
continue;
}
if (campaign.getState() != IN_REVIEW_STAGE) {
continue;
}
boolean emptyDecisionFound = false;
for (AccessCertificationWorkItemType workItem : aCase.getWorkItem()) {
if (WorkItemTypeUtil.getOutcome(workItem) == null) {
emptyDecisionFound = true;
break;
}
}
if (emptyDecisionFound) {
LOGGER.info("Expecting case of {}:{}", campaign.getOid(), aCase.getId());
expectedCases.add(aCase);
}
}
}
Aggregations