/**
   * Returns true if the user requires ageing.
   *
   * @param user user being reviewed
   * @param currentStep current ageing step of the user
   * @param today today's date
   * @return true if user requires ageing, false if not
   */
  public boolean isAgeingRequired(UserDTO user, AgeingEntityStepDTO currentStep, Date today) {
    Date lastStatusChange =
        user.getLastStatusChange() != null ? user.getLastStatusChange() : user.getCreateDatetime();

    calendar.clear();
    calendar.setTime(lastStatusChange);
    calendar.add(Calendar.DATE, currentStep.getDays());

    if (calendar.getTime().equals(today) || calendar.getTime().before(today)) {
      LOG.debug(
          "User status has expired (last change "
              + lastStatusChange
              + " + "
              + currentStep.getDays()
              + " days is before today "
              + today
              + ")");
      return true;
    }

    LOG.debug(
        "User does not need to be aged (last change "
            + lastStatusChange
            + " + "
            + currentStep.getDays()
            + " days is after today "
            + today
            + ")");
    return false;
  }
  /**
   * Get the status for the next step in the ageing process, based on the users current status.
   *
   * @param steps configured ageing steps
   * @param currentStatusId the current user status
   */
  public UserStatusDTO getNextAgeingStep(Set<AgeingEntityStepDTO> steps, Integer currentStatusId) {
    for (AgeingEntityStepDTO step : steps) {
      Integer stepStatusId = step.getUserStatus().getId();
      if (stepStatusId.compareTo(currentStatusId) > 0) {
        return step.getUserStatus();
      }
    }

    return null;
  }