use of com.qcadoo.mes.states.exception.StateChangeException in project mes by qcadoo.
the class AbstractStateChangeViewClient method changeState.
@Override
public final void changeState(final ViewContextHolder viewContext, final String targetState, final Entity entity) {
try {
LOG.info(String.format("Change state. Entity name : %S id : %d. Target state : %S", entity.getDataDefinition().getName(), entity.getId(), targetState));
StateChangeContext stateChangeContext = stateChangeContextBuilder.build(getStateChangeService().getChangeEntityDescriber(), entity, targetState);
getStateChangeService().changeState(stateChangeContext);
viewClientUtil.refreshComponent(viewContext);
showMessages(viewContext, stateChangeContext);
stateChangeContext = null;
} catch (AnotherChangeInProgressException e) {
viewContext.getMessagesConsumer().addMessage("states.messages.change.failure.anotherChangeInProgress", MessageType.FAILURE);
LOG.info(String.format("Another state change in progress. Entity name : %S id : %d. Target state : %S", entity.getDataDefinition().getName(), entity.getId(), targetState));
} catch (StateTransitionNotAlloweException e) {
viewContext.getMessagesConsumer().addMessage("states.messages.change.failure.transitionNotAllowed", MessageType.FAILURE);
LOG.info(String.format("State change - transition not allowed. Entity name : %S id : %d. Target state : %S", entity.getDataDefinition().getName(), entity.getId(), targetState));
} catch (Exception e) {
throw new StateChangeException(e);
}
}
Aggregations