Search in sources :

Example 1 with AccessCertificationWorkItemType

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

the class AccCertQueryHelper method searchOpenWorkItems.

// public because of testing
// principal == null => take all work items
public List<AccessCertificationWorkItemType> searchOpenWorkItems(ObjectQuery baseWorkItemsQuery, MidPointPrincipal principal, boolean notDecidedOnly, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException {
    // enhance filter with reviewerRef + enabled
    ObjectQuery newQuery;
    ObjectFilter reviewerAndEnabledFilter = getReviewerAndEnabledFilterForWI(principal);
    ObjectFilter filterToAdd;
    if (notDecidedOnly) {
        ObjectFilter noResponseFilter = QueryBuilder.queryFor(AccessCertificationWorkItemType.class, prismContext).item(F_OUTPUT, F_OUTCOME).isNull().buildFilter();
        filterToAdd = AndFilter.createAnd(reviewerAndEnabledFilter, noResponseFilter);
    } else {
        filterToAdd = reviewerAndEnabledFilter;
    }
    newQuery = replaceFilter(baseWorkItemsQuery, filterToAdd);
    // retrieve cases, filtered
    List<AccessCertificationWorkItemType> workItems = repositoryService.searchContainers(AccessCertificationWorkItemType.class, newQuery, options, result);
    return workItems;
}
Also used : ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 2 with AccessCertificationWorkItemType

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

the class CertificationCaseHelper method updateLoadedCertificationWorkItem.

public AccessCertificationWorkItemType updateLoadedCertificationWorkItem(GetCertificationWorkItemResult result, // key=OID:ID
Map<String, PrismContainerValue<AccessCertificationCaseType>> casesCache, // key=OID
Map<String, PrismObject<AccessCertificationCampaignType>> campaignsCache, Collection<SelectorOptions<GetOperationOptions>> options, QueryEngine2 engine, Session session, OperationResult operationResult) throws SchemaException, QueryException {
    String campaignOid = result.getCampaignOid();
    Integer caseId = result.getCaseId();
    Integer workItemId = result.getId();
    String caseKey = campaignOid + ":" + caseId;
    PrismContainerValue<AccessCertificationCaseType> casePcv = casesCache.get(caseKey);
    if (casePcv == null) {
        ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).ownerId(campaignOid).and().id(caseId).build();
        RQuery caseQuery = engine.interpret(query, AccessCertificationCaseType.class, null, false, session);
        List<GetContainerableResult> cases = caseQuery.list();
        if (cases.size() > 1) {
            throw new IllegalStateException("More than one certification case found for campaign " + campaignOid + ", ID " + caseId);
        } else if (cases.isEmpty()) {
            // we need it, because otherwise we have only identifiers for the work item, no data
            throw new IllegalStateException("No certification case found for campaign " + campaignOid + ", ID " + caseId);
        }
        AccessCertificationCaseType _case = updateLoadedCertificationCase(cases.get(0), campaignsCache, null, session, operationResult);
        casePcv = _case.asPrismContainerValue();
        casesCache.put(caseKey, casePcv);
    }
    @SuppressWarnings({ "raw", "unchecked" }) PrismContainerValue<AccessCertificationWorkItemType> workItemPcv = (PrismContainerValue<AccessCertificationWorkItemType>) casePcv.find(new ItemPath(AccessCertificationCaseType.F_WORK_ITEM, workItemId));
    if (workItemPcv == null) {
        throw new IllegalStateException("No work item " + workItemId + " in " + casePcv);
    } else {
        return workItemPcv.asContainerable();
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RQuery(com.evolveum.midpoint.repo.sql.query.RQuery) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 3 with AccessCertificationWorkItemType

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

the class CertWorkItemDtoProvider method internalIterator.

@Override
public Iterator<CertWorkItemDto> internalIterator(long first, long count) {
    LOGGER.trace("begin::iterator() from {} count {}.", first, count);
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
    try {
        ObjectPaging paging = createPaging(first, count);
        Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_OBJECTS);
        ObjectQuery caseQuery = getQuery();
        caseQuery = caseQuery != null ? caseQuery.clone() : getPrismContext().queryFactory().createQuery();
        caseQuery.setPaging(paging);
        Collection<SelectorOptions<GetOperationOptions>> resolveNames = createCollection(createResolveNames());
        AccessCertificationService acs = getPageBase().getCertificationService();
        List<AccessCertificationWorkItemType> workitems = acs.searchOpenWorkItems(caseQuery, notDecidedOnly, allItems, resolveNames, task, result);
        for (AccessCertificationWorkItemType workItem : workitems) {
            getAvailableData().add(new CertWorkItemDto(workItem, getPageBase()));
        }
    } catch (Exception ex) {
        result.recordFatalError(getPageBase().createStringResource("CertCaseDtoProvider.message.internalIterator.fatalError").getString(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list decisions", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    getPageBase().showResult(result, false);
    LOGGER.trace("end::iterator()");
    return getAvailableData().iterator();
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 4 with AccessCertificationWorkItemType

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

the class CertificationCaseHelper method updateLoadedCertificationWorkItem.

public AccessCertificationWorkItemType updateLoadedCertificationWorkItem(GetCertificationWorkItemResult result, // key=OID:ID
Map<String, PrismContainerValue<AccessCertificationCaseType>> casesCache, // key=OID
Map<String, PrismObject<AccessCertificationCampaignType>> campaignsCache, Collection<SelectorOptions<GetOperationOptions>> options, QueryEngine engine, Session session, OperationResult operationResult) throws SchemaException, QueryException {
    String campaignOid = result.getCampaignOid();
    Integer caseId = result.getCaseId();
    Integer workItemId = result.getId();
    String caseKey = campaignOid + ":" + caseId;
    PrismContainerValue<AccessCertificationCaseType> casePcv = casesCache.get(caseKey);
    if (casePcv == null) {
        ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class).ownerId(campaignOid).and().id(caseId).build();
        RQuery caseQuery = engine.interpret(query, AccessCertificationCaseType.class, null, false, session);
        List<GetContainerableResult> cases = caseQuery.list();
        if (cases.size() > 1) {
            throw new IllegalStateException("More than one certification case found for campaign " + campaignOid + ", ID " + caseId);
        } else if (cases.isEmpty()) {
            // we need it, because otherwise we have only identifiers for the work item, no data
            throw new IllegalStateException("No certification case found for campaign " + campaignOid + ", ID " + caseId);
        }
        // TODO really use options of 'null' ?
        AccessCertificationCaseType acase = updateLoadedCertificationCase(cases.get(0), campaignsCache, null, session, operationResult);
        casePcv = acase.asPrismContainerValue();
        casesCache.put(caseKey, casePcv);
    }
    @SuppressWarnings({ "raw", "unchecked" }) PrismContainerValue<AccessCertificationWorkItemType> workItemPcv = (PrismContainerValue<AccessCertificationWorkItemType>) casePcv.find(ItemPath.create(AccessCertificationCaseType.F_WORK_ITEM, workItemId));
    if (workItemPcv == null) {
        throw new IllegalStateException("No work item " + workItemId + " in " + casePcv);
    } else {
        return workItemPcv.asContainerable();
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RQuery(com.evolveum.midpoint.repo.sql.query.RQuery) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 5 with AccessCertificationWorkItemType

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

the class SqaleRepoAddDeleteObjectTest method test842AccessCertificationCampaign.

@Test
public void test842AccessCertificationCampaign() throws Exception {
    OperationResult result = createOperationResult();
    given("access certification campaign");
    String objectName = "acc" + getTestNumber();
    UUID definitionRefOid = UUID.randomUUID();
    QName definitionRefRelationUri = QName.valueOf("{https://some.uri}definition-relation");
    UUID ownerRefOid = UUID.randomUUID();
    QName ownerRefRelationUri = QName.valueOf("{https://strange.uri}owner-relation");
    Instant startTimestamp = Instant.ofEpochMilli(1234);
    Instant validFrom = Instant.ofEpochMilli(444000);
    Instant validityChangeTimestamp = Instant.ofEpochMilli(444001);
    Instant case1CurrentStageCreateTimestamp = Instant.ofEpochMilli(444333);
    Instant case2CurrentStageCreateTimestamp = Instant.ofEpochMilli(2444333);
    Instant remediedTimestamp = Instant.ofEpochMilli(444555);
    Instant currentStageDeadline = Instant.ofEpochMilli(444666);
    Instant validTo = Instant.ofEpochMilli(999000);
    Instant enableTimestamp = Instant.ofEpochMilli(555000);
    Instant disableTimestamp = Instant.ofEpochMilli(555111);
    Instant archiveTimestamp = Instant.ofEpochMilli(555123);
    Instant endTimestamp = Instant.ofEpochMilli(System.currentTimeMillis());
    String disableReason = "Whatever!";
    String case1CurrentStageOutcome = "Bada BOOM";
    String case2CurrentStageOutcome = "Big bada BOOM";
    Integer case1Iteration = 5;
    Integer case2Iteration = 15;
    UUID caseObjectRefOid = UUID.randomUUID();
    QName caseObjectRefRelationUri = QName.valueOf("{https://other.uri}case-object-ref-relation");
    UUID caseOrgRefOid = UUID.randomUUID();
    QName caseOrgRefRelationUri = QName.valueOf("{https://other.uri}case-org-ref-relation");
    String caseOutcome = "... for ever and ever";
    int caseStageNumber = 8;
    UUID caseTargetRefOid = UUID.randomUUID();
    QName caseTargetRefRelationUri = QName.valueOf("{https://some.uri}case-target-ref-relation");
    UUID caseTenantRefOid = UUID.randomUUID();
    QName caseTenantRefRelationUri = QName.valueOf("{https://some.uri}case-tenant-ref-relation");
    Instant wi1CloseTimestamp = Instant.ofEpochMilli(999123);
    Instant wi2CloseTimestamp = Instant.ofEpochMilli(2999123);
    Instant wi3CloseTimestamp = Instant.ofEpochMilli(3999123);
    Instant wi1OutputChangeTimestamp = Instant.ofEpochMilli(999001);
    Instant wi2OutputChangeTimestamp = Instant.ofEpochMilli(2999001);
    Instant wi3OutputChangeTimestamp = Instant.ofEpochMilli(3999001);
    UUID performer1Oid = UUID.randomUUID();
    QName performer1Relation = QName.valueOf("{https://random.org/ns}wi-performer1-rel");
    UUID performer2Oid = UUID.randomUUID();
    QName performer2Relation = QName.valueOf("{https://random.org/ns}wi-performer2-rel");
    UUID performer3Oid = UUID.randomUUID();
    QName performer3Relation = QName.valueOf("{https://random.org/ns}wi-performer3-rel");
    // explicit UUID, to ensure ordering
    UUID wi1AssigneeRef1Oid = UUID.fromString("7508a482-d8d1-11eb-9435-9b077bcc684b");
    QName wi1AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-1-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi1AssigneeRef2Oid = UUID.fromString("77267d0c-d8d1-11eb-9ae9-8fb4530e4e64");
    QName wi1AssigneeRef2Relation = QName.valueOf("{https://random.org/ns}acwi-1-assignee-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi1CandidateRef1Oid = UUID.fromString("754f391a-d8d1-11eb-b269-9b322a63128e");
    QName wi1CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-1-candidate-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2AssigneeRef1Oid = UUID.fromString("75cde882-d8d1-11eb-841f-6b8c0f5075f8");
    QName wi2AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-2-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2CandidateRef1Oid = UUID.fromString("765709aa-d8d1-11eb-9340-33ef5ec6b0e2");
    QName wi2CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-2-candidate-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2CandidateRef2Oid = UUID.fromString("7576bd0a-d8d1-11eb-9171-bf2238c132b7");
    QName wi2CandidateRef2Relation = QName.valueOf("{https://random.org/ns}acwi-2-candidate-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi3AssigneeRef1Oid = UUID.fromString("b9f969b0-d8e4-11eb-aa14-6f0a7aff9550");
    QName wi3AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-3-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi3CandidateRef1Oid = UUID.fromString("bb23b638-d8e4-11eb-9601-872386b50ce3");
    QName wi3CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-3-candidate-1-rel");
    var accessCertificationCampaign = new AccessCertificationCampaignType(prismContext).name(objectName).definitionRef(definitionRefOid.toString(), UserType.COMPLEX_TYPE, definitionRefRelationUri).endTimestamp(MiscUtil.asXMLGregorianCalendar(endTimestamp)).handlerUri("c-handler-uri").iteration(3).ownerRef(ownerRefOid.toString(), UserType.COMPLEX_TYPE, ownerRefRelationUri).stageNumber(2).startTimestamp(MiscUtil.asXMLGregorianCalendar(startTimestamp)).state(AccessCertificationCampaignStateType.IN_REVIEW_STAGE)._case(new AccessCertificationCaseType(prismContext).id(48L).activation(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ARCHIVED).archiveTimestamp(MiscUtil.asXMLGregorianCalendar(archiveTimestamp)).disableReason(disableReason).disableTimestamp(MiscUtil.asXMLGregorianCalendar(disableTimestamp)).effectiveStatus(ActivationStatusType.DISABLED).enableTimestamp(MiscUtil.asXMLGregorianCalendar(enableTimestamp)).validFrom(MiscUtil.asXMLGregorianCalendar(validFrom)).validTo(MiscUtil.asXMLGregorianCalendar(validTo)).validityChangeTimestamp(MiscUtil.asXMLGregorianCalendar(validityChangeTimestamp)).validityStatus(TimeIntervalStatusType.IN)).currentStageOutcome(case1CurrentStageOutcome).iteration(case1Iteration).objectRef(caseObjectRefOid.toString(), ServiceType.COMPLEX_TYPE, caseObjectRefRelationUri).orgRef(caseOrgRefOid.toString(), OrgType.COMPLEX_TYPE, caseOrgRefRelationUri).outcome(caseOutcome).remediedTimestamp(MiscUtil.asXMLGregorianCalendar(remediedTimestamp)).currentStageDeadline(MiscUtil.asXMLGregorianCalendar(currentStageDeadline)).currentStageCreateTimestamp(MiscUtil.asXMLGregorianCalendar(case1CurrentStageCreateTimestamp)).stageNumber(caseStageNumber).targetRef(caseTargetRefOid.toString(), RoleType.COMPLEX_TYPE, caseTargetRefRelationUri).tenantRef(caseTenantRefOid.toString(), OrgType.COMPLEX_TYPE, caseTenantRefRelationUri).workItem(new AccessCertificationWorkItemType(prismContext).id(55L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi1CloseTimestamp)).iteration(81).output(new AbstractWorkItemOutputType().outcome("almost, but not quite, entirely done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi1OutputChangeTimestamp)).performerRef(performer1Oid.toString(), UserType.COMPLEX_TYPE, performer1Relation).stageNumber(21).assigneeRef(wi1AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1AssigneeRef1Relation).assigneeRef(wi1AssigneeRef2Oid.toString(), UserType.COMPLEX_TYPE, wi1AssigneeRef2Relation).candidateRef(wi1CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1CandidateRef1Relation)).workItem(new AccessCertificationWorkItemType(prismContext).id(56L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi2CloseTimestamp)).iteration(82).output(new AbstractWorkItemOutputType().outcome("A tad more than almost, but not quite, entirely done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi2OutputChangeTimestamp)).performerRef(performer2Oid.toString(), UserType.COMPLEX_TYPE, performer2Relation).stageNumber(22).assigneeRef(wi2AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2AssigneeRef1Relation).candidateRef(wi2CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2CandidateRef1Relation).candidateRef(wi2CandidateRef2Oid.toString(), OrgType.COMPLEX_TYPE, wi2CandidateRef2Relation)))._case(new AccessCertificationCaseType(prismContext).id(49L).currentStageOutcome(case2CurrentStageOutcome).iteration(case2Iteration).outcome("whatever").currentStageCreateTimestamp(MiscUtil.asXMLGregorianCalendar(case2CurrentStageCreateTimestamp)).stageNumber(25).targetRef(caseTargetRefOid.toString(), RoleType.COMPLEX_TYPE, caseTargetRefRelationUri).workItem(new AccessCertificationWorkItemType(prismContext).id(59L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi3CloseTimestamp)).iteration(83).output(new AbstractWorkItemOutputType().outcome("certainly not quite done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi3OutputChangeTimestamp)).performerRef(performer3Oid.toString(), UserType.COMPLEX_TYPE, performer3Relation).stageNumber(21).assigneeRef(wi3AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi3AssigneeRef1Relation).candidateRef(wi3CandidateRef1Oid.toString(), OrgType.COMPLEX_TYPE, wi3CandidateRef1Relation)));
    when("adding it to the repository");
    repositoryService.addObject(accessCertificationCampaign.asPrismObject(), null, result);
    then("it is stored and relevant attributes are in columns");
    assertThatOperationResult(result).isSuccess();
    MAccessCertificationCampaign row = selectObjectByOid(QAccessCertificationCampaign.class, accessCertificationCampaign.getOid());
    assertThat(row.definitionRefTargetOid).isEqualTo(definitionRefOid);
    assertThat(row.definitionRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(row.definitionRefRelationId, definitionRefRelationUri);
    assertThat(row.endTimestamp).isEqualTo(endTimestamp);
    assertCachedUri(row.handlerUriId, "c-handler-uri");
    assertThat(row.campaignIteration).isEqualTo(3);
    assertThat(row.ownerRefTargetOid).isEqualTo(ownerRefOid);
    assertThat(row.ownerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(row.ownerRefRelationId, ownerRefRelationUri);
    assertThat(row.stageNumber).isEqualTo(2);
    assertThat(row.startTimestamp).isEqualTo(startTimestamp);
    assertThat(row.state).isEqualTo(AccessCertificationCampaignStateType.IN_REVIEW_STAGE);
    QAccessCertificationCase caseAlias = aliasFor(QAccessCertificationCase.class);
    List<MAccessCertificationCase> caseRows = select(caseAlias, caseAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(caseRows).hasSize(2);
    caseRows.sort(comparing(tr -> tr.cid));
    MAccessCertificationCase caseRow = caseRows.get(0);
    // assigned in advance
    assertThat(caseRow.cid).isEqualTo(48);
    assertThat(caseRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_CASE);
    assertThat(caseRow.administrativeStatus).isEqualTo(ActivationStatusType.ARCHIVED);
    assertThat(caseRow.archiveTimestamp).isEqualTo(archiveTimestamp);
    assertThat(caseRow.disableReason).isEqualTo(disableReason);
    assertThat(caseRow.disableTimestamp).isEqualTo(disableTimestamp);
    assertThat(caseRow.effectiveStatus).isEqualTo(ActivationStatusType.DISABLED);
    assertThat(caseRow.enableTimestamp).isEqualTo(enableTimestamp);
    assertThat(caseRow.validFrom).isEqualTo(validFrom);
    assertThat(caseRow.validTo).isEqualTo(validTo);
    assertThat(caseRow.validityChangeTimestamp).isEqualTo(validityChangeTimestamp);
    assertThat(caseRow.validityStatus).isEqualTo(TimeIntervalStatusType.IN);
    assertThat(caseRow.currentStageOutcome).isEqualTo(case1CurrentStageOutcome);
    assertContainerFullObject(caseRow.fullObject, accessCertificationCampaign.getCase().get(0));
    assertThat(caseRow.campaignIteration).isEqualTo(case1Iteration);
    assertThat(caseRow.objectRefTargetOid).isEqualTo(caseObjectRefOid);
    assertThat(caseRow.objectRefTargetType).isEqualTo(MObjectType.SERVICE);
    assertCachedUri(caseRow.objectRefRelationId, caseObjectRefRelationUri);
    assertThat(caseRow.orgRefTargetOid).isEqualTo(caseOrgRefOid);
    assertThat(caseRow.orgRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(caseRow.orgRefRelationId, caseOrgRefRelationUri);
    assertThat(caseRow.outcome).isEqualTo(caseOutcome);
    assertThat(caseRow.remediedTimestamp).isEqualTo(remediedTimestamp);
    assertThat(caseRow.currentStageDeadline).isEqualTo(currentStageDeadline);
    assertThat(caseRow.currentStageCreateTimestamp).isEqualTo(case1CurrentStageCreateTimestamp);
    assertThat(caseRow.stageNumber).isEqualTo(caseStageNumber);
    assertThat(caseRow.targetRefTargetOid).isEqualTo(caseTargetRefOid);
    assertThat(caseRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);
    assertCachedUri(caseRow.targetRefRelationId, caseTargetRefRelationUri);
    assertThat(caseRow.tenantRefTargetOid).isEqualTo(caseTenantRefOid);
    assertThat(caseRow.tenantRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(caseRow.tenantRefRelationId, caseTenantRefRelationUri);
    caseRow = caseRows.get(1);
    // assigned in advance
    assertThat(caseRow.cid).isEqualTo(49);
    assertThat(caseRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_CASE);
    assertThat(caseRow.administrativeStatus).isNull();
    assertThat(caseRow.archiveTimestamp).isNull();
    assertThat(caseRow.disableReason).isNull();
    assertThat(caseRow.disableTimestamp).isNull();
    assertThat(caseRow.effectiveStatus).isNull();
    assertThat(caseRow.enableTimestamp).isNull();
    assertThat(caseRow.validFrom).isNull();
    assertThat(caseRow.validTo).isNull();
    assertThat(caseRow.validityChangeTimestamp).isNull();
    assertThat(caseRow.validityStatus).isNull();
    assertThat(caseRow.currentStageOutcome).isEqualTo(case2CurrentStageOutcome);
    assertContainerFullObject(caseRow.fullObject, accessCertificationCampaign.getCase().get(1));
    assertThat(caseRow.campaignIteration).isEqualTo(case2Iteration);
    assertThat(caseRow.objectRefTargetOid).isNull();
    assertThat(caseRow.objectRefTargetType).isNull();
    assertThat(caseRow.objectRefRelationId).isNull();
    assertThat(caseRow.orgRefTargetOid).isNull();
    assertThat(caseRow.orgRefTargetType).isNull();
    assertThat(caseRow.orgRefRelationId).isNull();
    assertThat(caseRow.outcome).isEqualTo("whatever");
    assertThat(caseRow.remediedTimestamp).isNull();
    assertThat(caseRow.currentStageDeadline).isNull();
    assertThat(caseRow.currentStageCreateTimestamp).isEqualTo(case2CurrentStageCreateTimestamp);
    assertThat(caseRow.stageNumber).isEqualTo(25);
    assertThat(caseRow.targetRefTargetOid).isEqualTo(caseTargetRefOid);
    assertThat(caseRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);
    assertCachedUri(caseRow.targetRefRelationId, caseTargetRefRelationUri);
    assertThat(caseRow.tenantRefTargetOid).isNull();
    assertThat(caseRow.tenantRefTargetType).isNull();
    assertThat(caseRow.tenantRefRelationId).isNull();
    QAccessCertificationWorkItem wiAlias = aliasFor(QAccessCertificationWorkItem.class);
    List<MAccessCertificationWorkItem> wiRows = select(wiAlias, wiAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(wiRows).hasSize(3);
    wiRows.sort(comparing(tr -> tr.cid));
    MAccessCertificationWorkItem wiRow = wiRows.get(0);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(55);
    assertThat(wiRow.accessCertCaseCid).isEqualTo(48);
    assertThat(wiRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_WORK_ITEM);
    assertThat(wiRow.closeTimestamp).isEqualTo(wi1CloseTimestamp);
    assertThat(wiRow.campaignIteration).isEqualTo(81);
    assertThat(wiRow.outcome).isEqualTo("almost, but not quite, entirely done");
    assertThat(wiRow.outputChangeTimestamp).isEqualTo(wi1OutputChangeTimestamp);
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer1Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer1Relation);
    assertThat(wiRow.stageNumber).isEqualTo(21);
    wiRow = wiRows.get(1);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(56);
    assertThat(wiRow.accessCertCaseCid).isEqualTo(48);
    assertThat(wiRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_WORK_ITEM);
    assertThat(wiRow.closeTimestamp).isEqualTo(wi2CloseTimestamp);
    assertThat(wiRow.campaignIteration).isEqualTo(82);
    assertThat(wiRow.outcome).isEqualTo("A tad more than almost, but not quite, entirely done");
    assertThat(wiRow.outputChangeTimestamp).isEqualTo(wi2OutputChangeTimestamp);
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer2Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer2Relation);
    assertThat(wiRow.stageNumber).isEqualTo(22);
    // Assignee refs
    QAccessCertificationWorkItemReference assigneeRefAlias = QAccessCertificationWorkItemReferenceMapping.getForCaseWorkItemAssignee().defaultAlias();
    List<MAccessCertificationWorkItemReference> assigneeRefRows = select(assigneeRefAlias, assigneeRefAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(assigneeRefRows).hasSize(4);
    assigneeRefRows.sort(comparing(tr -> tr.targetOid));
    MAccessCertificationWorkItemReference assigneeRefRow = assigneeRefRows.get(0);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi3AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi3AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(49);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(59);
    assigneeRefRow = assigneeRefRows.get(1);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi1AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi1AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(55);
    assigneeRefRow = assigneeRefRows.get(2);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi2AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi2AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(56);
    assigneeRefRow = assigneeRefRows.get(3);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi1AssigneeRef2Oid);
    assertCachedUri(assigneeRefRow.relationId, wi1AssigneeRef2Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(55);
    // Candidate refs
    QAccessCertificationWorkItemReference candidateRefAlias = QAccessCertificationWorkItemReferenceMapping.getForCaseWorkItemCandidate().defaultAlias();
    List<MAccessCertificationWorkItemReference> candidateRefRows = select(candidateRefAlias, candidateRefAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(candidateRefRows).hasSize(4);
    candidateRefRows.sort(comparing(tr -> tr.targetOid));
    MAccessCertificationWorkItemReference candidateRefRow = candidateRefRows.get(0);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.ORG);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi3CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi3CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(49);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(59);
    candidateRefRow = candidateRefRows.get(1);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi1CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi1CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(55);
    candidateRefRow = candidateRefRows.get(2);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.ORG);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi2CandidateRef2Oid);
    assertCachedUri(candidateRefRow.relationId, wi2CandidateRef2Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(56);
    candidateRefRow = candidateRefRows.get(3);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi2CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi2CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(56);
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) QName(javax.xml.namespace.QName) Instant(java.time.Instant) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) BigInteger(java.math.BigInteger) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 AccessCertificationService (com.evolveum.midpoint.model.api.AccessCertificationService)2 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 RQuery (com.evolveum.midpoint.repo.sql.query.RQuery)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)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 Containerable (com.evolveum.midpoint.prism.Containerable)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 ItemName (com.evolveum.midpoint.prism.path.ItemName)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1