/**
   * Retourne une Collection de UserDetail des utilisateurs selectionnés via le userPanel
   *
   * @param
   * @return
   * @throws TodoException
   * @see
   */
  public Collection getUserSelected() throws TodoException {
    Selection sel = getSelection();
    ArrayList attendees = new ArrayList();
    Collection oldAttendees = null;

    ToDoHeader todo = getCurrentToDoHeader();
    if (todo.getId() != null) {
      oldAttendees = getToDoAttendees(todo.getId());
    }

    String[] selectedUsers = sel.getSelectedElements();
    if (selectedUsers != null) {
      for (int i = 0; i < selectedUsers.length; i++) {
        Attendee newAttendee = null;
        if (oldAttendees != null) {
          Iterator attI = oldAttendees.iterator();
          while (attI.hasNext()) {
            Attendee attendee = (Attendee) attI.next();
            if (attendee.getUserId().equals(selectedUsers[i])) {
              newAttendee = attendee;
            }
          } // fin while
        } // fin if

        if (newAttendee == null) {
          newAttendee = new Attendee(selectedUsers[i]);
        }
        attendees.add(newAttendee);
      } // fin for
    } // fin if

    return attendees;
  }
  public void removeAttendeeToEntryFromExternal(
      String componentId, String externalId, String userId) {
    SilverTrace.info(
        "calendar",
        "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId, String userId)",
        "root.MSG_GEN_ENTER_METHOD",
        "componentId=" + componentId + ", externalId=" + externalId + ", userId = " + userId);
    try {
      Attendee attendee = new Attendee();
      attendee.setUserId(userId);

      Collection<ToDoHeader> headers =
          getCalendarBm().getExternalTodos("useless", componentId, externalId);
      for (ToDoHeader header : headers) {
        if (header != null) {
          getCalendarBm().removeToDoAttendee(header.getId(), attendee);
        }
      }
    } catch (Exception e) {
      SilverTrace.error(
          "calendar",
          "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId)",
          "calendar.MSG_CANT_REMOVE",
          "return null",
          e);
    }
  }
 private static TodoDetail todoHeaderToDetail(final ToDoHeader header) {
   TodoDetail detail = new TodoDetail();
   detail.setName(header.getName());
   detail.setId(header.getId());
   detail.setDescription(header.getDescription());
   detail.setDelegatorId(header.getDelegatorId());
   // detail.setPriority(header.getPriority());
   detail.setStartDate(header.getStartDate());
   detail.setEndDate(header.getEndDate());
   detail.setDuration(header.getDuration());
   detail.setPercentCompleted(header.getPercentCompleted());
   detail.setComponentId(header.getComponentId());
   detail.setSpaceId(header.getSpaceId());
   detail.setExternalId(header.getExternalId());
   return detail;
 }
 public void removeEntriesFromExternal(String spaceId, String componentId, String externalId) {
   SilverTrace.info(
       "calendar",
       "TodoBackboneAcess.removeEntriesFromExternal(String spaceId, String componentId, String externalId)",
       "root.MSG_GEN_ENTER_METHOD",
       "spaceId=" + spaceId + ", componentId=" + componentId + ", externalId=" + externalId);
   try {
     Collection<ToDoHeader> headers =
         getCalendarBm().getExternalTodos(spaceId, componentId, externalId);
     for (ToDoHeader header : headers) {
       getCalendarBm().removeToDo(header.getId());
     }
   } catch (Exception e) {
     SilverTrace.error(
         "calendar",
         "TodoBackboneAcess.removeEntriesFromExternal(String spaceId, String componentId, String externalId)",
         "calendar.MSG_CANT_REMOVE",
         "return null",
         e);
   }
 }
 public void updateEntry(TodoDetail todo) {
   SilverTrace.info(
       "calendar", "TodoBackboneAcess.updateEntry(TodoDetail todo)", "root.MSG_GEN_ENTER_METHOD");
   try {
     ToDoHeader header = todoDetailToHeader(todo);
     getCalendarBm().updateToDo(header);
     if (todo.getAttendees() != null) {
       String[] userIds = new String[todo.getAttendees().size()];
       int posit = 0;
       for (Attendee attendee : todo.getAttendees()) {
         userIds[posit++] = attendee.getUserId();
       }
       getCalendarBm().setToDoAttendees(header.getId(), userIds);
     }
   } catch (Exception e) {
     SilverTrace.error(
         "calendar",
         "TodoBackboneAcess.addEntry(TodoDetail todo)",
         "calendar.MSG_UPDATE_ENTRY_FAILED",
         "id=" + todo.getId(),
         e);
   }
 }