Search in sources :

Example 16 with CaseWorkItemType

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

the class SqaleRepoAddDeleteObjectTest method test850Case.

@Test
public void test850Case() throws Exception {
    OperationResult result = createOperationResult();
    given("case");
    String objectName = "case" + getTestNumber();
    UUID parentOid = UUID.randomUUID();
    QName parentRelation = QName.valueOf("{https://random.org/ns}case-parent-rel");
    UUID objectOid = UUID.randomUUID();
    QName objectRelation = QName.valueOf("{https://random.org/ns}case-object-rel");
    UUID requestorOid = UUID.randomUUID();
    QName requestorRelation = QName.valueOf("{https://random.org/ns}case-requestor-rel");
    UUID targetOid = UUID.randomUUID();
    QName targetRelation = QName.valueOf("{https://random.org/ns}case-target-rel");
    UUID originalAssignee1Oid = UUID.randomUUID();
    QName originalAssignee1Relation = QName.valueOf("{https://random.org/ns}original-assignee1-rel");
    UUID performer1Oid = UUID.randomUUID();
    QName performer1Relation = QName.valueOf("{https://random.org/ns}performer1-rel");
    UUID originalAssignee2Oid = UUID.randomUUID();
    QName originalAssignee2Relation = QName.valueOf("{https://random.org/ns}original-assignee2-rel");
    UUID performer2Oid = UUID.randomUUID();
    QName performer2Relation = QName.valueOf("{https://random.org/ns}performer2-rel");
    // explicit UUID, to ensure ordering
    UUID wi1AssigneeRef1Oid = UUID.fromString("4be487d2-c833-11eb-ba67-6768439d49a8");
    QName wi1AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}wi-1-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi1CandidateRef1Oid = UUID.fromString("ac4d4a54-c834-11eb-ba57-8b9fef95c25d");
    QName wi1CandidateRef1Relation = QName.valueOf("{https://random.org/ns}wi-1-candidate-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi1CandidateRef2Oid = UUID.fromString("9dc675dc-c834-11eb-b31a-17ac6f7bab4f");
    QName wi1CandidateRef2Relation = QName.valueOf("{https://random.org/ns}wi-1-candidate-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi2AssigneeRef1Oid = UUID.fromString("d867f3e0-c830-11eb-b7cf-abba51968ecb");
    QName wi2AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}wi-2-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2AssigneeRef2Oid = UUID.fromString("6a92b1ec-c831-11eb-a075-5f6be1e16c34");
    QName wi2AssigneeRef2Relation = QName.valueOf("{https://random.org/ns}wi-2-assignee-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi2CandidateRef1Oid = UUID.fromString("df6388b8-c834-11eb-946a-efa73de3615b");
    QName wi2CandidateRef1Relation = QName.valueOf("{https://random.org/ns}wi-2-candidate-1-rel");
    CaseType acase = new CaseType(prismContext).name(objectName).state("closed").closeTimestamp(MiscUtil.asXMLGregorianCalendar(321L)).parentRef(parentOid.toString(), CaseType.COMPLEX_TYPE, parentRelation).objectRef(objectOid.toString(), RoleType.COMPLEX_TYPE, objectRelation).requestorRef(requestorOid.toString(), UserType.COMPLEX_TYPE, requestorRelation).targetRef(targetOid.toString(), OrgType.COMPLEX_TYPE, targetRelation).workItem(new CaseWorkItemType(prismContext).id(41L).createTimestamp(MiscUtil.asXMLGregorianCalendar(10000L)).closeTimestamp(MiscUtil.asXMLGregorianCalendar(10100L)).deadline(MiscUtil.asXMLGregorianCalendar(10200L)).originalAssigneeRef(originalAssignee1Oid.toString(), OrgType.COMPLEX_TYPE, originalAssignee1Relation).performerRef(performer1Oid.toString(), UserType.COMPLEX_TYPE, performer1Relation).stageNumber(1).assigneeRef(wi1AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1AssigneeRef1Relation).candidateRef(wi1CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1CandidateRef1Relation).candidateRef(wi1CandidateRef2Oid.toString(), UserType.COMPLEX_TYPE, wi1CandidateRef2Relation).output(new AbstractWorkItemOutputType(prismContext).outcome("OUTCOME one"))).workItem(new CaseWorkItemType(prismContext).id(42L).createTimestamp(MiscUtil.asXMLGregorianCalendar(20000L)).closeTimestamp(MiscUtil.asXMLGregorianCalendar(20100L)).deadline(MiscUtil.asXMLGregorianCalendar(20200L)).originalAssigneeRef(originalAssignee2Oid.toString(), UserType.COMPLEX_TYPE, originalAssignee2Relation).performerRef(performer2Oid.toString(), UserType.COMPLEX_TYPE, performer2Relation).stageNumber(2).assigneeRef(wi2AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2AssigneeRef1Relation).assigneeRef(wi2AssigneeRef2Oid.toString(), UserType.COMPLEX_TYPE, wi2AssigneeRef2Relation).candidateRef(wi2CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2CandidateRef1Relation).output(new AbstractWorkItemOutputType(prismContext).outcome("OUTCOME two")));
    when("adding it to the repository");
    repositoryService.addObject(acase.asPrismObject(), null, result);
    then("it is stored and relevant attributes are in columns");
    assertThatOperationResult(result).isSuccess();
    MCase caseRow = selectObjectByOid(QCase.class, acase.getOid());
    assertThat(caseRow.state).isEqualTo("closed");
    assertThat(caseRow.closeTimestamp).isEqualTo(Instant.ofEpochMilli(321));
    assertThat(caseRow.parentRefTargetOid).isEqualTo(parentOid);
    assertThat(caseRow.parentRefTargetType).isEqualTo(MObjectType.CASE);
    assertCachedUri(caseRow.parentRefRelationId, parentRelation);
    assertThat(caseRow.objectRefTargetOid).isEqualTo(objectOid);
    assertThat(caseRow.objectRefTargetType).isEqualTo(MObjectType.ROLE);
    assertCachedUri(caseRow.objectRefRelationId, objectRelation);
    assertThat(caseRow.requestorRefTargetOid).isEqualTo(requestorOid);
    assertThat(caseRow.requestorRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(caseRow.requestorRefRelationId, requestorRelation);
    assertThat(caseRow.targetRefTargetOid).isEqualTo(targetOid);
    assertThat(caseRow.targetRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(caseRow.targetRefRelationId, targetRelation);
    QCaseWorkItem wiAlias = aliasFor(QCaseWorkItem.class);
    List<MCaseWorkItem> wiRows = select(wiAlias, wiAlias.ownerOid.eq(UUID.fromString(acase.getOid())));
    assertThat(wiRows).hasSize(2);
    wiRows.sort(comparing(tr -> tr.cid));
    MCaseWorkItem wiRow = wiRows.get(0);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(41);
    assertThat(wiRow.ownerOid.toString()).isEqualTo(acase.getOid());
    assertThat(wiRow.containerType).isEqualTo(MContainerType.CASE_WORK_ITEM);
    assertThat(wiRow.createTimestamp).isEqualTo(Instant.ofEpochMilli(10000));
    assertThat(wiRow.closeTimestamp).isEqualTo(Instant.ofEpochMilli(10100));
    assertThat(wiRow.deadline).isEqualTo(Instant.ofEpochMilli(10200));
    assertThat(wiRow.originalAssigneeRefTargetOid).isEqualTo(originalAssignee1Oid);
    assertThat(wiRow.originalAssigneeRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(wiRow.originalAssigneeRefRelationId, originalAssignee1Relation);
    assertThat(wiRow.outcome).isEqualTo("OUTCOME one");
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer1Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer1Relation);
    assertThat(wiRow.stageNumber).isEqualTo(1);
    wiRow = wiRows.get(1);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(42);
    assertThat(wiRow.ownerOid.toString()).isEqualTo(acase.getOid());
    assertThat(wiRow.containerType).isEqualTo(MContainerType.CASE_WORK_ITEM);
    assertThat(wiRow.createTimestamp).isEqualTo(Instant.ofEpochMilli(20000));
    assertThat(wiRow.closeTimestamp).isEqualTo(Instant.ofEpochMilli(20100));
    assertThat(wiRow.deadline).isEqualTo(Instant.ofEpochMilli(20200));
    assertThat(wiRow.originalAssigneeRefTargetOid).isEqualTo(originalAssignee2Oid);
    assertThat(wiRow.originalAssigneeRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.originalAssigneeRefRelationId, originalAssignee2Relation);
    assertThat(wiRow.outcome).isEqualTo("OUTCOME two");
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer2Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer2Relation);
    assertThat(wiRow.stageNumber).isEqualTo(2);
    QCaseWorkItemReference assigneeRefAlias = QCaseWorkItemReferenceMapping.getForCaseWorkItemAssignee().defaultAlias();
    List<MCaseWorkItemReference> assigneeRefRows = select(assigneeRefAlias, assigneeRefAlias.ownerOid.eq(UUID.fromString(acase.getOid())));
    assertThat(assigneeRefRows).hasSize(3);
    assigneeRefRows.sort(comparing(tr -> tr.targetOid));
    MCaseWorkItemReference assigneeRefRow = assigneeRefRows.get(0);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi2AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi2AssigneeRef1Relation);
    assertThat(assigneeRefRow.workItemCid).isEqualTo(42);
    assigneeRefRow = assigneeRefRows.get(2);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi2AssigneeRef2Oid);
    assertCachedUri(assigneeRefRow.relationId, wi2AssigneeRef2Relation);
    assertThat(assigneeRefRow.workItemCid).isEqualTo(42);
    assigneeRefRow = assigneeRefRows.get(1);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi1AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi1AssigneeRef1Relation);
    assertThat(assigneeRefRow.workItemCid).isEqualTo(41);
    QCaseWorkItemReference candidateRefAlias = QCaseWorkItemReferenceMapping.getForCaseWorkItemCandidate().defaultAlias();
    List<MCaseWorkItemReference> candidateRefRows = select(candidateRefAlias, candidateRefAlias.ownerOid.eq(UUID.fromString(acase.getOid())));
    assertThat(candidateRefRows).hasSize(3);
    candidateRefRows.sort(comparing(tr -> tr.targetOid));
    MCaseWorkItemReference candidateRefRow = candidateRefRows.get(0);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi1CandidateRef2Oid);
    assertCachedUri(candidateRefRow.relationId, wi1CandidateRef2Relation);
    assertThat(candidateRefRow.workItemCid).isEqualTo(41);
    candidateRefRow = candidateRefRows.get(1);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi1CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi1CandidateRef1Relation);
    assertThat(candidateRefRow.workItemCid).isEqualTo(41);
    candidateRefRow = candidateRefRows.get(2);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(acase.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.CASE);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.CASE_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi2CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi2CandidateRef1Relation);
    assertThat(candidateRefRow.workItemCid).isEqualTo(42);
}
Also used : MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) 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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 17 with CaseWorkItemType

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

the class TestCaseManagement method test100SearchCases.

@Test
public void test100SearchCases() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    login(userAdministrator);
    SearchResultList<PrismObject<CaseType>> cases = controller.searchObjects(CaseType.class, null, null, task, result);
    assertEquals(3, cases.size());
    SearchResultList<CaseWorkItemType> workItems = controller.searchContainers(CaseWorkItemType.class, null, null, task, result);
    assertEquals(4, workItems.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 18 with CaseWorkItemType

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

the class CloseCaseAction method executeInternal.

@Override
@Nullable
public Action executeInternal(OperationResult result) {
    CaseType currentCase = operation.getCurrentCase();
    XMLGregorianCalendar now = beans.clock.currentTimeXMLGregorianCalendar();
    for (CaseWorkItemType wi : currentCase.getWorkItem()) {
        if (wi.getCloseTimestamp() == null) {
            wi.setCloseTimestamp(now);
        }
    }
    CaseState state = CaseState.of(currentCase);
    if (state.isCreated() || state.isOpen()) {
        currentCase.setOutcome(outcomeUri);
        currentCase.setState(SchemaConstants.CASE_STATE_CLOSING);
    // Auditing and notifications are emitted when the "closing action" in extension is done.
    } else {
        LOGGER.debug("Case {} was already closed; its state is {}", currentCase, state);
        result.recordWarning("Case was already closed");
    }
    return null;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) CaseState(com.evolveum.midpoint.schema.util.cases.CaseState) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with CaseWorkItemType

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

the class CaseManagementHelper method cancelNonApprovalCase.

// should go through case engine
@Deprecated
private void cancelNonApprovalCase(CaseType aCase, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    List<ItemDelta<?, ?>> modifications = new ArrayList<>();
    XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
    for (CaseWorkItemType workItem : aCase.getWorkItem()) {
        if (workItem.getCloseTimestamp() == null) {
            modifications.add(prismContext.deltaFor(CaseType.class).item(CaseType.F_WORK_ITEM, workItem.getId(), CaseWorkItemType.F_CLOSE_TIMESTAMP).replace(now).asItemDelta());
        }
    }
    modifications.addAll(prismContext.deltaFor(CaseType.class).item(CaseType.F_STATE).replace(SchemaConstants.CASE_STATE_CLOSED).item(CaseType.F_CLOSE_TIMESTAMP).replace(now).asItemDeltas());
    repositoryService.modifyObject(CaseType.class, aCase.getOid(), modifications, result);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType)

Example 20 with CaseWorkItemType

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

the class AbstractWfTest method checkVisibleWorkItem.

protected void checkVisibleWorkItem(ExpectedWorkItem expectedWorkItem, int count, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, CommunicationException {
    S_AtomicFilterExit q = QueryUtils.filterForAssignees(prismContext.queryFor(CaseWorkItemType.class), SecurityUtil.getPrincipal(), OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, relationRegistry);
    q = q.and().item(CaseWorkItemType.F_CLOSE_TIMESTAMP).isNull();
    List<CaseWorkItemType> currentWorkItems = modelService.searchContainers(CaseWorkItemType.class, q.build(), null, task, result);
    long found = currentWorkItems.stream().filter(wi -> expectedWorkItem == null || expectedWorkItem.matches(wi)).count();
    assertEquals("Wrong # of matching work items", count, found);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) AssertJUnit(org.testng.AssertJUnit) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) CaseManager(com.evolveum.midpoint.cases.api.CaseManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) TaskManager(com.evolveum.midpoint.task.api.TaskManager) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) CaseWorkItemUtil(com.evolveum.midpoint.schema.util.cases.CaseWorkItemUtil) WorkItemManager(com.evolveum.midpoint.cases.impl.WorkItemManager) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) Clockwork(com.evolveum.midpoint.model.impl.lens.Clockwork) CaseAsserter(com.evolveum.midpoint.test.asserter.CaseAsserter) Map(java.util.Map) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) CaseService(com.evolveum.midpoint.model.api.CaseService) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ClassMode(org.springframework.test.annotation.DirtiesContext.ClassMode) PrismUtil(com.evolveum.midpoint.prism.util.PrismUtil) MiscHelper(com.evolveum.midpoint.wf.impl.util.MiscHelper) IOException(java.io.IOException) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) Task(com.evolveum.midpoint.task.api.Task) File(java.io.File) AbstractModelImplementationIntegrationTest(com.evolveum.midpoint.model.impl.AbstractModelImplementationIntegrationTest) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) List(java.util.List) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) SecurityUtil(com.evolveum.midpoint.security.api.SecurityUtil) CaseEngineImpl(com.evolveum.midpoint.cases.impl.engine.CaseEngineImpl) PrimaryChangeProcessor(com.evolveum.midpoint.wf.impl.processors.primary.PrimaryChangeProcessor) ContextConfiguration(org.springframework.test.context.ContextConfiguration) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Checker(com.evolveum.midpoint.test.Checker) Collections(java.util.Collections) QueryUtils(com.evolveum.midpoint.cases.api.util.QueryUtils) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit)

Aggregations

CaseWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13 Task (com.evolveum.midpoint.task.api.Task)11 List (java.util.List)8 Test (org.testng.annotations.Test)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)6 CaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType)6 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)5 Collectors (java.util.stream.Collectors)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 QName (javax.xml.namespace.QName)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 File (java.io.File)3 Collection (java.util.Collection)3 NotNull (org.jetbrains.annotations.NotNull)3 DirtiesContext (org.springframework.test.annotation.DirtiesContext)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 CaseEngineOperation (com.evolveum.midpoint.cases.api.CaseEngineOperation)2