@RequiresSession
  public List<StageEntity> findByRequestIdAndCommandStatuses(Long requestId, Collection<HostRoleStatus> statuses) {
    TypedQuery<StageEntity> query = entityManagerProvider.get().createNamedQuery(
        "StageEntity.findByRequestIdAndCommandStatuses", StageEntity.class);

    query.setParameter("requestId", requestId);
    query.setParameter("statuses", statuses);
    return daoUtils.selectList(query);
  }
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