use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method createOutcomeDeltas.
// computes outcomes at stage close (stage-level and overall) and creates appropriate deltas
List<ItemDelta<?, ?>> createOutcomeDeltas(AccessCertificationCampaignType campaign, OperationResult result) throws ObjectNotFoundException, SchemaException {
List<ItemDelta<?, ?>> rv = new ArrayList<>();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Updating current outcome for cases in {}", toShortString(campaign));
}
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaign.getOid(), null, null, result);
for (AccessCertificationCaseType _case : caseList) {
if (_case.getStageNumber() != campaign.getStageNumber()) {
continue;
}
String newStageOutcome = OutcomeUtils.toUri(computationHelper.computeOutcomeForStage(_case, campaign, campaign.getStageNumber()));
if (!Objects.equals(newStageOutcome, _case.getCurrentStageOutcome())) {
rv.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_CURRENT_STAGE_OUTCOME).replace(newStageOutcome).asItemDelta());
}
rv.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_EVENT).add(new StageCompletionEventType().timestamp(clock.currentTimeXMLGregorianCalendar()).stageNumber(campaign.getStageNumber()).outcome(newStageOutcome)).asItemDelta());
String newOverallOutcome = OutcomeUtils.toUri(computationHelper.computeOverallOutcome(_case, campaign, newStageOutcome));
if (!Objects.equals(newOverallOutcome, _case.getOutcome())) {
rv.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_OUTCOME).replace(newOverallOutcome).asItemDelta());
}
}
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertGeneralHelper method isRevoke.
// TODO move to OutcomeUtils
public boolean isRevoke(AccessCertificationCaseType aCase, AccessCertificationCampaignType campaign) {
AccessCertificationResponseType outcome = OutcomeUtils.fromUri(aCase.getOutcome());
List<AccessCertificationResponseType> revokes;
if (campaign.getRemediationDefinition() != null && !campaign.getRemediationDefinition().getRevokeOn().isEmpty()) {
revokes = campaign.getRemediationDefinition().getRevokeOn();
} else {
revokes = Collections.singletonList(REVOKE);
}
return revokes.contains(outcome);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class CertCaseDtoProvider method internalIterator.
@Override
public Iterator<CertCaseOrWorkItemDto> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", first, count);
getAvailableData().clear();
Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_OBJECTS);
OperationResult result = task.getResult();
try {
ObjectPaging paging = createPaging(first, count);
Collection<SelectorOptions<GetOperationOptions>> resolveNames = createCollection(createResolveNames());
List<AccessCertificationCaseType> caseList = searchCases(campaignOid, paging, resolveNames, getPageBase().getPrismContext(), task, result);
for (AccessCertificationCaseType acase : caseList) {
getAvailableData().add(new CertCaseDto(acase, getPageBase(), task, result));
}
} catch (Exception ex) {
result.recordFatalError(getPageBase().createStringResource("CertCaseDtoProvider.message.internalIterator.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list decisions", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
handleNotSuccessOrHandledErrorInIterator(result);
}
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test331AddedCertificationCaseStoresItFixedId.
@Test
public void test331AddedCertificationCaseStoresItFixedId() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
MAccessCertificationCampaign originalRow = selectObjectByOid(QAccessCertificationCampaign.class, accessCertificationCampaign1Oid);
given("delta adding case for campaign 1");
accCertCampaign1Case2ObjectOid = UUID.randomUUID();
AccessCertificationCaseType caseBefore = new AccessCertificationCaseType(prismContext).id(CAMPAIGN_1_CASE_2_ID).stageNumber(5).iteration(7).objectRef(accCertCampaign1Case2ObjectOid.toString(), UserType.COMPLEX_TYPE).outcome("anyone who is capable of getting themselves made" + " President should on no account be allowed to do the job");
ObjectDelta<AccessCertificationCampaignType> delta = prismContext.deltaFor(AccessCertificationCampaignType.class).item(AccessCertificationCampaignType.F_CASE).add(caseBefore).asObjectDelta(accessCertificationCampaign1Oid);
when("modifyObject is called");
repositoryService.modifyObject(AccessCertificationCampaignType.class, accessCertificationCampaign1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
AccessCertificationCampaignType campaignObjectAfter = repositoryService.getObject(AccessCertificationCampaignType.class, accessCertificationCampaign1Oid, retrieveWithCases(), result).asObjectable();
assertThat(campaignObjectAfter.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
List<AccessCertificationCaseType> casesAfter = campaignObjectAfter.getCase();
assertThat(casesAfter).isNotNull();
assertThat(casesAfter.get(1).getId()).isEqualTo(CAMPAIGN_1_CASE_2_ID);
and("campaign row is created");
MAccessCertificationCampaign row = selectObjectByOid(QAccessCertificationCampaign.class, accessCertificationCampaign1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
and("case row is created");
QAccessCertificationCase a = QAccessCertificationCaseMapping.getAccessCertificationCaseMapping().defaultAlias();
List<MAccessCertificationCase> caseRows = select(a, a.ownerOid.eq(UUID.fromString(accessCertificationCampaign1Oid)));
assertThat(caseRows).hasSize(2);
caseRows.sort(comparing(tr -> tr.cid));
MAccessCertificationCase aRow = caseRows.get(1);
assertThat(aRow.cid).isEqualTo(CAMPAIGN_1_CASE_2_ID);
assertThat(aRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_CASE);
assertThat(aRow.targetRefTargetOid).isNull();
assertThat(aRow.objectRefTargetOid).isEqualTo(accCertCampaign1Case2ObjectOid);
assertThat(aRow.objectRefTargetType).isEqualTo(MObjectType.USER);
assertCachedUri(aRow.objectRefRelationId, relationRegistry.getDefaultRelation());
assertThat(aRow.outcome).isEqualTo("anyone who is capable of getting themselves made" + " President should on no account be allowed to do the job");
assertThat(aRow.stageNumber).isEqualTo(5);
assertThat(aRow.campaignIteration).isEqualTo(7);
assertCertificationCaseFullObject(aRow, caseBefore);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType in project midpoint by Evolveum.
the class AccCertCloserHelper method createCaseDeltasOnStageClose.
// computes cases outcomes (stage-level and overall) at stage close and creates appropriate deltas
private void createCaseDeltasOnStageClose(AccessCertificationCampaignType campaign, ModificationsToExecute modifications, XMLGregorianCalendar now, List<AccessCertificationResponseType> outcomesToStopOn, OperationResult result) throws SchemaException {
LOGGER.debug("Updating current outcome for cases in {}", toShortStringLazy(campaign));
List<AccessCertificationCaseType> caseList = queryHelper.getAllCurrentIterationCases(campaign.getOid(), norm(campaign.getIteration()), null, result);
for (AccessCertificationCaseType aCase : caseList) {
long caseId = aCase.getId();
if (aCase.getReviewFinishedTimestamp() != null) {
LOGGER.trace("Review process of case {} has already finished, skipping to the next one", caseId);
continue;
}
LOGGER.trace("Updating current outcome for case {}", caseId);
AccessCertificationResponseType newStageOutcome = computationHelper.computeOutcomeForStage(aCase, campaign, campaign.getStageNumber());
String newStageOutcomeUri = toUri(newStageOutcome);
String newOverallOutcomeUri = toUri(computationHelper.computeOverallOutcome(aCase, campaign, campaign.getStageNumber(), newStageOutcome));
List<ItemDelta<?, ?>> deltas = new ArrayList<>(prismContext.deltaFor(AccessCertificationCampaignType.class).item(F_CASE, caseId, F_CURRENT_STAGE_OUTCOME).replace(newStageOutcomeUri).item(F_CASE, caseId, F_OUTCOME).replace(newOverallOutcomeUri).item(F_CASE, caseId, F_EVENT).add(new StageCompletionEventType(prismContext).timestamp(clock.currentTimeXMLGregorianCalendar()).stageNumber(campaign.getStageNumber()).iteration(campaign.getIteration()).outcome(newStageOutcomeUri)).asItemDeltas());
LOGGER.trace("Stage outcome = {}, overall outcome = {}", newStageOutcome, newOverallOutcomeUri);
if (outcomesToStopOn.contains(newStageOutcome)) {
deltas.add(prismContext.deltaFor(AccessCertificationCampaignType.class).item(F_CASE, caseId, F_REVIEW_FINISHED_TIMESTAMP).replace(now).asItemDelta());
LOGGER.debug("Marking case {} as review-finished because stage outcome = {}", caseId, newStageOutcome);
}
modifications.add(deltas);
}
}
Aggregations