use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState in project camunda-bpm-platform by camunda.
the class PlanItemDefinitionActivityBehavior method ensureTransitionAllowed.
// helper //////////////////////////////////////////////////////////////////////
protected void ensureTransitionAllowed(CmmnActivityExecution execution, CaseExecutionState expected, CaseExecutionState target, String transition) {
String id = execution.getId();
CaseExecutionState currentState = execution.getCurrentState();
// is allowed.
if (execution.isTerminating() || execution.isSuspending()) {
currentState = execution.getPreviousState();
}
// is the case execution already in the target state
if (target.equals(currentState)) {
throw LOG.isAlreadyInStateException(transition, id, target);
} else // is the case execution in the expected state
if (!expected.equals(currentState)) {
throw LOG.unexpectedStateException(transition, id, expected, currentState);
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState in project camunda-bpm-platform by camunda.
the class StageActivityBehavior method handleChildSuspension.
public void handleChildSuspension(CmmnActivityExecution execution, CmmnActivityExecution child) {
// if the given execution is not suspending currently, then ignore this notification.
if (execution.isSuspending() && isAbleToSuspend(execution)) {
String id = execution.getId();
CaseExecutionState currentState = execution.getCurrentState();
if (SUSPENDING_ON_SUSPENSION.equals(currentState)) {
execution.performSuspension();
} else if (SUSPENDING_ON_PARENT_SUSPENSION.equals(currentState)) {
execution.performParentSuspension();
} else {
throw LOG.suspendCaseException(id, currentState);
}
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState in project camunda-bpm-platform by camunda.
the class CaseExecutionStateTransitionCollector method notify.
public void notify(DelegateCaseExecution planItem) throws Exception {
CmmnExecution execution = (CmmnExecution) planItem;
String activityId = execution.getEventSource().getId();
CaseExecutionState previousState = execution.getPreviousState();
String previousStateName = "()";
if (!previousState.equals(CaseExecutionState.NEW)) {
previousStateName = previousState.toString();
}
CaseExecutionState newState = execution.getCurrentState();
String stateTransition = previousStateName + " --" + execution.getEventName() + "(" + activityId + ")--> " + newState;
LOG.debug("collecting state transition: " + stateTransition);
stateTransitions.add(stateTransition);
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method assertHistoricState.
protected void assertHistoricState(String activityId, CaseExecutionState expectedState) {
HistoricCaseActivityInstanceEventEntity historicActivityInstance = (HistoricCaseActivityInstanceEventEntity) queryHistoricActivityCaseInstance(activityId);
int actualStateCode = historicActivityInstance.getCaseActivityInstanceState();
CaseExecutionState actualState = CaseExecutionState.CaseExecutionStateImpl.getStateForCode(actualStateCode);
assertEquals("The state of historic case activity '" + activityId + "' wasn't as expected", expectedState, actualState);
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method assertStateQuery.
protected void assertStateQuery(CaseExecutionState... states) {
CaseExecutionStateCountMap stateCounts = new CaseExecutionStateCountMap();
if (states != null) {
for (CaseExecutionState state : states) {
stateCounts.put(state, stateCounts.get(state) + 1);
}
}
assertCount(stateCounts.count(), historicQuery());
assertCount(stateCounts.unfinished(), historicQuery().notEnded());
assertCount(stateCounts.finished(), historicQuery().ended());
assertCount(stateCounts.get(ACTIVE), historicQuery().active());
assertCount(stateCounts.get(AVAILABLE), historicQuery().available());
assertCount(stateCounts.get(COMPLETED), historicQuery().completed());
assertCount(stateCounts.get(DISABLED), historicQuery().disabled());
assertCount(stateCounts.get(ENABLED), historicQuery().enabled());
assertCount(stateCounts.get(TERMINATED), historicQuery().terminated());
}
Aggregations