Search in sources :

Example 1 with F_EVENT

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_EVENT 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;
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectTypeUtil.toShortString(com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)

Example 2 with F_EVENT

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_EVENT 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);
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta)

Aggregations

ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)2 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)1