@RequiresSession
  public long getLastRequestId() {
    TypedQuery<Long> query = entityManagerProvider.get().createQuery("SELECT max(stage.requestId) FROM StageEntity stage", Long.class);
    Long result = daoUtils.selectSingle(query);
    if (result != null) {
      return result;
    } else {
      return 0;
    }
  }
Mapping of valid status transitions that that are driven by manual input.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java