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);
}
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;
}
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;
}
}
Aggregations