Exemplo n.º 1
0
  /**
   * getSchedulesForRoleAt
   *
   * @param roleId a {@link java.lang.String} object.
   * @param time a {@link java.util.Date} object.
   * @return a {@link java.util.List} object.
   * @throws org.exolab.castor.xml.MarshalException if any.
   * @throws org.exolab.castor.xml.ValidationException if any.
   * @throws java.io.IOException if any.
   */
  public List<Schedule> getSchedulesForRoleAt(String roleId, Date time)
      throws MarshalException, ValidationException, IOException {
    update();

    List<Schedule> schedules = new ArrayList<Schedule>();
    for (Schedule sched : getRole(roleId).getScheduleCollection()) {
      if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) {
        schedules.add(sched);
      }
    }
    return schedules;
  }
Exemplo n.º 2
0
  /**
   * isUserScheduledForRole
   *
   * @param userId a {@link java.lang.String} object.
   * @param roleId a {@link java.lang.String} object.
   * @param time a {@link java.util.Date} object.
   * @return a boolean.
   * @throws org.exolab.castor.xml.MarshalException if any.
   * @throws org.exolab.castor.xml.ValidationException if any.
   * @throws java.io.IOException if any.
   */
  public boolean isUserScheduledForRole(String userId, String roleId, Date time)
      throws MarshalException, ValidationException, IOException {
    update();

    for (Schedule sched : getUserSchedulesForRole(userId, roleId)) {
      if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) {
        return true;
      }
    }

    // if no user is scheduled then the supervisor is schedule by default
    Role role = getRole(roleId);
    if (userId.equals(role.getSupervisor())) {
      for (Schedule sched : role.getScheduleCollection()) {
        if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) {
          // we found another scheduled user
          return false;
        }
      }
      return true;
    }
    return false;
  }