/** * 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); } }
/** * Method declaration * * @param id * @param percent * @throws TodoException * @see */ public void setToDoPercentCompleted(String id, String percent) throws TodoException { SilverTrace.info( "todo", "ToDoSessionController.setToDoPercentCompleted()", "root.MSG_GEN_ENTER_METHOD"); ToDoHeader todo = getToDoHeader(id); try { todo.setPercentCompleted(new Integer(percent).intValue()); } catch (Exception e) { SilverTrace.warn( "todo", "ToDoSessionController.setToDoPercentCompleted()", "todo.MSG_CANT_SET_TODO_PERCENTCOMPLETED"); } try { calendarBm.updateToDo(todo); SilverTrace.info( "todo", "ToDoSessionController.setToDoPercentCompleted()", "root.MSG_GEN_EXIT_METHOD"); } catch (Exception e) { throw new TodoException( "ToDoSessionController.setToDoPercentCompleted()", SilverpeasException.ERROR, "todo.MSG_CANT_UPDATE_TODO_DETAIL", e); } }
/** * Method declaration * * @param id * @throws TodoException * @see */ public void reopenToDo(String id) throws TodoException { SilverTrace.info("todo", "ToDoSessionController.reopenToDo()", "root.MSG_GEN_ENTER_METHOD"); ToDoHeader todo = getToDoHeader(id); todo.setCompletedDate(null); try { calendarBm.updateToDo(todo); SilverTrace.info("todo", "ToDoSessionController.reopenToDo()", "root.MSG_GEN_EXIT_METHOD"); } catch (Exception e) { throw new TodoException( "ToDoSessionController.reopenToDo()", SilverpeasException.ERROR, "todo.MSG_CANT_UPDATE_TODO_DETAIL", e); } }
/** * Method declaration * * @param id * @param name * @param description * @param priority * @param classification * @param startDay * @param startHour * @param endDay * @param endHour * @param percent * @throws TodoException * @see */ public void updateToDo( String id, String name, String description, String priority, String classification, Date startDay, String startHour, Date endDay, String endHour, String percent) throws TodoException { SilverTrace.info("todo", "ToDoSessionController.updateToDo()", "root.MSG_GEN_ENTER_METHOD"); ToDoHeader todo = getToDoHeader(id); todo.setName(name); todo.setDescription(description); try { todo.getPriority().setValue(new Integer(priority).intValue()); } catch (Exception e) { SilverTrace.warn( "todo", "ToDoSessionController.updateToDo()", "todo.MSG_CANT_SET_TODO_PRIORITY"); } try { todo.setPercentCompleted(new Integer(percent).intValue()); } catch (Exception e) { SilverTrace.warn( "todo", "ToDoSessionController.updateToDo()", "todo.MSG_CANT_SET_TODO_PERCENTCOMPLETED"); } try { todo.getClassification().setString(classification); todo.setStartDate(startDay); todo.setStartHour(startHour); todo.setEndDate(endDay); todo.setEndHour(endHour); calendarBm.updateToDo(todo); SilverTrace.info("todo", "ToDoSessionController.updateToDo()", "root.MSG_GEN_EXIT_METHOD"); } catch (Exception e) { throw new TodoException( "ToDoSessionController.updateToDo()", SilverpeasException.ERROR, "todo.MSG_CANT_UPDATE_TODO_DETAIL", e); } }
/** * Method declaration * * @param name * @param description * @param priority * @param classification * @param startDay * @param startHour * @param endDay * @param endHour * @param percent * @return * @throws TodoException * @see */ public String addToDo( String name, String description, String priority, String classification, Date startDay, String startHour, Date endDay, String endHour, String percent) throws TodoException { String result = null; SilverTrace.info("todo", "ToDoSessionController.addToDo()", "root.MSG_GEN_ENTER_METHOD"); ToDoHeader todo = new ToDoHeader(name, getUserId()); todo.setDescription(description); try { todo.getPriority().setValue(new Integer(priority).intValue()); } catch (Exception e) { SilverTrace.warn( "todo", "ToDoSessionController.addToDo()", "todo.MSG_CANT_SET_TODO_PRIORITY"); } try { todo.setPercentCompleted(new Integer(percent).intValue()); } catch (Exception e) { SilverTrace.warn( "todo", "ToDoSessionController.addToDo()", "todo.MSG_CANT_SET_TODO_PERCENTCOMPLETED"); } try { todo.getClassification().setString(classification); todo.setStartDate(startDay); todo.setStartHour(startHour); todo.setEndDate(endDay); todo.setEndHour(endHour); result = calendarBm.addToDo(todo); } catch (Exception e) { throw new TodoException( "ToDoSessionController.addToDo()", SilverpeasException.ERROR, "todo.MSG_CANT_ADD_TODO", e); } SilverTrace.info("todo", "ToDoSessionController.addToDo()", "root.MSG_GEN_EXIT_METHOD"); return result; }
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); } }
/** * Method declaration * * @param id * @throws TodoException * @see */ public void closeToDo(String id) throws TodoException { SilverTrace.info("todo", "ToDoSessionController.closeToDo()", "root.MSG_GEN_ENTER_METHOD"); ToDoHeader todo = getToDoHeader(id); todo.setCompletedDate(new java.util.Date()); try { calendarBm.updateToDo(todo); } catch (Exception e) { throw new TodoException( "ToDoSessionController.closeToDo()", SilverpeasException.ERROR, "todo.MSG_CANT_UPDATE_TODO_DETAIL", e); } notifyAttendees( id, "Cloture de la tache '" + todo.getName() + "'", "La tache intitulé '" + todo.getName() + "' a été cloturée.\n"); SilverTrace.info("todo", "ToDoSessionController.closeToDo()", "root.MSG_GEN_EXIT_METHOD"); }
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); } }
private static ToDoHeader todoDetailToHeader(final TodoDetail detail) { ToDoHeader head = new ToDoHeader(); head.setName(detail.getName()); head.setId(detail.getId()); head.setDescription(detail.getDescription()); head.setDelegatorId(detail.getDelegatorId()); head.setStartDate(detail.getStartDate()); head.setEndDate(detail.getEndDate()); head.setDuration((int) detail.getDuration()); head.setPercentCompleted(detail.getPercentCompleted()); head.setComponentId(detail.getComponentId()); head.setSpaceId(detail.getSpaceId()); head.setExternalId(detail.getExternalId()); return head; }
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; }