Search in sources :

Example 16 with AccessCertificationCaseType

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

Example 17 with AccessCertificationCaseType

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());
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) TypedObjectQuery(com.evolveum.midpoint.prism.query.TypedObjectQuery) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 18 with AccessCertificationCaseType

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());
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 19 with AccessCertificationCaseType

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());
}
Also used : AccessCertificationAssignmentCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationAssignmentCaseType)

Example 20 with AccessCertificationCaseType

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);
        }
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Aggregations

AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)31 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)7 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)5 Task (com.evolveum.midpoint.task.api.Task)5 CertificationHandler (com.evolveum.midpoint.certification.impl.handlers.CertificationHandler)4 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)4 java.util (java.util)4 NotNull (org.jetbrains.annotations.NotNull)4 Test (org.testng.annotations.Test)4 XmlTypeConverter (com.evolveum.midpoint.prism.xml.XmlTypeConverter)3