Search in sources :

Example 16 with AccessCertificationWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.

the class CertWorkItemDtoProvider method internalSize.

// TODO replace searchDecisions with countDecisions (when it will be available)
@Override
protected int internalSize() {
    LOGGER.trace("begin::internalSize()");
    int count = 0;
    OperationResult result = new OperationResult(OPERATION_COUNT_OBJECTS);
    try {
        Task task = getPage().createSimpleTask(OPERATION_COUNT_OBJECTS);
        AccessCertificationService acs = getPage().getCertificationService();
        ObjectQuery query = getQuery().clone();
        // when counting decisions we need to exclude offset+size (and sorting info is irrelevant)
        query.setPaging(null);
        List<AccessCertificationWorkItemType> workItems = acs.searchOpenWorkItems(query, notDecidedOnly, null, task, result);
        count = workItems.size();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't count objects.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        getPage().showResult(result);
        throw new RestartResponseException(PageError.class);
    }
    LOGGER.trace("end::internalSize()");
    return count;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) RestartResponseException(org.apache.wicket.RestartResponseException) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 17 with AccessCertificationWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.

the class AbstractCertificationTest method recordDecision.

protected void recordDecision(String campaignOid, AccessCertificationCaseType _case, AccessCertificationResponseType response, String comment, String reviewerOid, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
    Authentication originalAuthentication = null;
    String realReviewerOid;
    if (reviewerOid != null) {
        originalAuthentication = SecurityContextHolder.getContext().getAuthentication();
        login(getUser(reviewerOid));
        realReviewerOid = reviewerOid;
    } else {
        realReviewerOid = securityEnforcer.getPrincipal().getOid();
    }
    List<AccessCertificationWorkItemType> workItems = _case.getWorkItem().stream().filter(wi -> ObjectTypeUtil.containsOid(wi.getAssigneeRef(), realReviewerOid)).filter(wi -> wi.getStageNumber() == _case.getStageNumber()).collect(Collectors.toList());
    assertEquals("Wrong # of current work items for " + realReviewerOid + " in " + _case, 1, workItems.size());
    long id = _case.asPrismContainerValue().getId();
    certificationManager.recordDecision(campaignOid, id, workItems.get(0).getId(), response, comment, task, result);
    if (reviewerOid != null) {
        SecurityContextHolder.getContext().setAuthentication(originalAuthentication);
    }
}
Also used : java.util(java.util) AssertJUnit(org.testng.AssertJUnit) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) F_CASE(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType.F_CASE) WorkItemTypeUtil(com.evolveum.midpoint.schema.util.WorkItemTypeUtil) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) DummyResource(com.evolveum.icf.dummy.resource.DummyResource) PrismObject(com.evolveum.midpoint.prism.PrismObject) com.evolveum.midpoint.certification.impl(com.evolveum.midpoint.certification.impl) Task(com.evolveum.midpoint.task.api.Task) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) AccessCertificationCampaignStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType) CertCampaignTypeUtil(com.evolveum.midpoint.schema.util.CertCampaignTypeUtil) Collectors(java.util.stream.Collectors) INCLUDE(com.evolveum.midpoint.schema.RetrieveOption.INCLUDE) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) MidPointConstants(com.evolveum.midpoint.schema.constants.MidPointConstants) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) Authentication(org.springframework.security.core.Authentication) OutcomeUtils(com.evolveum.midpoint.certification.api.OutcomeUtils) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) Authentication(org.springframework.security.core.Authentication)

Example 18 with AccessCertificationWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.

the class AccCertCaseOperationsHelper method getDeltasToAdvanceCases.

List<ItemDelta<?, ?>> getDeltasToAdvanceCases(AccessCertificationCampaignType campaign, AccessCertificationStageType stage, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    LOGGER.trace("Advancing reviewers and timestamps for cases in {}", toShortString(campaign));
    List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaign.getOid(), null, null, result);
    List<ItemDelta<?, ?>> rv = new ArrayList<>(caseList.size());
    int stageToBe = campaign.getStageNumber() + 1;
    List<AccessCertificationResponseType> outcomesToStopOn = computationHelper.getOutcomesToStopOn(campaign);
    AccessCertificationReviewerSpecificationType reviewerSpec = reviewersHelper.findReviewersSpecification(campaign, stageToBe, task, result);
    for (AccessCertificationCaseType _case : caseList) {
        if (!computationHelper.computeEnabled(campaign, _case, outcomesToStopOn)) {
            continue;
        }
        Long caseId = _case.asPrismContainerValue().getId();
        assert caseId != null;
        List<ObjectReferenceType> reviewers = reviewersHelper.getReviewersForCase(_case, campaign, reviewerSpec, task, result);
        List<AccessCertificationWorkItemType> workItems = createWorkItems(reviewers, stageToBe);
        _case.getWorkItem().addAll(CloneUtil.cloneCollectionMembers(workItems));
        AccessCertificationResponseType currentOutcome = computationHelper.computeOutcomeForStage(_case, campaign, stageToBe);
        AccessCertificationResponseType overallOutcome = computationHelper.computeOverallOutcome(_case, campaign, currentOutcome);
        rv.addAll(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, caseId, F_WORK_ITEM).add(PrismContainerValue.toPcvList(workItems)).item(F_CASE, caseId, F_CURRENT_STAGE_CREATE_TIMESTAMP).replace(stage.getStartTimestamp()).item(F_CASE, caseId, F_CURRENT_STAGE_DEADLINE).replace(stage.getDeadline()).item(F_CASE, caseId, F_CURRENT_STAGE_OUTCOME).replace(OutcomeUtils.toUri(currentOutcome)).item(F_CASE, caseId, F_OUTCOME).replace(OutcomeUtils.toUri(overallOutcome)).item(F_CASE, caseId, F_STAGE_NUMBER).replace(stageToBe).asItemDeltas());
    }
    LOGGER.debug("Created {} deltas to advance {} cases for campaign {}", rv.size(), caseList.size(), toShortString(campaign));
    return rv;
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta)

Aggregations

AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)15 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)8 Test (org.testng.annotations.Test)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AccessCertificationService (com.evolveum.midpoint.model.api.AccessCertificationService)3 Task (com.evolveum.midpoint.task.api.Task)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 DummyResource (com.evolveum.icf.dummy.resource.DummyResource)1 OutcomeUtils (com.evolveum.midpoint.certification.api.OutcomeUtils)1 com.evolveum.midpoint.certification.impl (com.evolveum.midpoint.certification.impl)1 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1