Search in sources :

Example 1 with CaseState

use of com.evolveum.midpoint.schema.util.cases.CaseState in project midpoint by Evolveum.

the class OpenCaseAction method executeInternal.

@Override
@Nullable
public Action executeInternal(OperationResult result) {
    CaseType currentCase = operation.getCurrentCase();
    CaseState currentState = CaseState.of(currentCase);
    if (!currentState.isCreated()) {
        LOGGER.debug("Case was already opened; its state is {}", currentState);
        return null;
    }
    auditRecords.addCaseOpening(result);
    notificationEvents.add(new CaseOpening(currentCase));
    currentCase.setState(SchemaConstants.CASE_STATE_OPEN);
    // If there are zero stages, the case will be immediately closed by "open stage" action.
    return new OpenStageAction(operation);
}
Also used : CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) CaseState(com.evolveum.midpoint.schema.util.cases.CaseState) CaseOpening(com.evolveum.midpoint.cases.api.events.FutureNotificationEvent.CaseOpening) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with CaseState

use of com.evolveum.midpoint.schema.util.cases.CaseState 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 3 with CaseState

use of com.evolveum.midpoint.schema.util.cases.CaseState in project midpoint by Evolveum.

the class ManualConnectorInstance method queryOperationStatus.

@Override
public OperationResultStatus queryOperationStatus(String asynchronousOperationReference, OperationResult parentResult) throws ObjectNotFoundException, SchemaException {
    OperationResult result = parentResult.createMinorSubresult(OPERATION_QUERY_CASE);
    InternalMonitor.recordConnectorOperation("queryOperationStatus");
    PrismObject<CaseType> aCase;
    try {
        aCase = repositoryService.getObject(CaseType.class, asynchronousOperationReference, null, result);
    } catch (ObjectNotFoundException | SchemaException e) {
        result.recordFatalError(e);
        throw e;
    }
    CaseType caseType = aCase.asObjectable();
    CaseState state = CaseState.of(caseType);
    // They differ only in level of processing carried out by case manager (audit, notifications, etc).
    if (state.isCreated() || state.isOpen()) {
        result.recordSuccess();
        return OperationResultStatus.IN_PROGRESS;
    } else if (state.isClosing() || state.isClosed()) {
        String outcome = caseType.getOutcome();
        OperationResultStatus status = ManualCaseUtils.translateOutcomeToStatus(outcome);
        result.recordSuccess();
        return status;
    } else {
        SchemaException e = new SchemaException("Unknown case state " + state);
        result.recordFatalError(e);
        throw e;
    }
}
Also used : OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) CaseState(com.evolveum.midpoint.schema.util.cases.CaseState) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

CaseState (com.evolveum.midpoint.schema.util.cases.CaseState)3 CaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType)2 Nullable (org.jetbrains.annotations.Nullable)2 CaseOpening (com.evolveum.midpoint.cases.api.events.FutureNotificationEvent.CaseOpening)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 CaseWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1