class ActionDBAccessorImpl implements ActionDBAccessor {

  @Override
  public List<Long> getRequestsByStatus(RequestStatus status, int maxResults,
    boolean ascOrder) {

    if (null == status) {
      return requestDAO.findAllRequestIds(maxResults, ascOrder);
    }

    EnumSet<HostRoleStatus> taskStatuses = null;
    switch( status ){
      case IN_PROGRESS:
        taskStatuses = HostRoleStatus.IN_PROGRESS_STATUSES;
        break;
      case FAILED:
        taskStatuses = HostRoleStatus.FAILED_STATUSES;
        break;
      case COMPLETED:
        // !!! COMPLETED is special as all tasks in the request must be
        // completed
        return hostRoleCommandDAO.getCompletedRequests(maxResults, ascOrder);
    }

    return hostRoleCommandDAO.getRequestsByTaskStatus(taskStatuses, maxResults,
      ascOrder);
  }

  @Inject public  ActionDBAccessorImpl(@Named("executionCommandCacheSize") long cacheLimit,
                              AmbariEventPublisher eventPublisher);

}