private AnnouncementBoard getBoard(String name, Unit unit) { for (AnnouncementBoard board : unit.getBoards()) { if (board.getName().equalInAnyLanguage(name)) { return board; } } return null; }
@Override protected AnnouncementBoard getRequestedAnnouncementBoard(HttpServletRequest request) { Unit unit = getUnit(request); if (unit == null) { return null; } else { MultiLanguageString name = getBoardName(request); for (AnnouncementBoard board : unit.getBoardsSet()) { if (board.getReaders() == null && board.getName().equalInAnyLanguage(name)) { return board; } } return null; } }
@Override protected Collection<AnnouncementBoard> boardsToView(HttpServletRequest request) throws Exception { Unit unit = getUnit(request); List<AnnouncementBoard> boards = new ArrayList<AnnouncementBoard>(); if (unit == null) { return boards; } User userView = getUserView(request); for (AnnouncementBoard board : unit.getBoardsSet()) { if (board.getReaders() == null) { boards.add(board); } if (board.getReaders().isMember(userView)) { boards.add(board); } } return boards; }
public ActionForward presentation( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { Unit unit = getUnit(request); UnitSite site = unit.getSite(); AnnouncementBoard announcementsBoard = null; AnnouncementBoard eventsBoard = null; for (AnnouncementBoard unitBoard : unit.getBoards()) { if (unitBoard.isPublicToRead() && unitBoard.getName().equalInAnyLanguage(ANNOUNCEMENTS_NAME)) { announcementsBoard = unitBoard; } if (unitBoard.isPublicToRead() && unitBoard.getName().equalInAnyLanguage(EVENTS_NAME)) { eventsBoard = unitBoard; } } if (announcementsBoard != null) { List<Announcement> announcements = announcementsBoard.getActiveAnnouncements(); announcements = announcements.subList(0, Math.min(announcements.size(), ANNOUNCEMENTS_NUMBER)); request.setAttribute("announcements", announcements); } if (eventsBoard != null) { request.setAttribute("announcementBoard", eventsBoard); YearMonthDay currentDay = new YearMonthDay(); List<Announcement> currentDayAnnouncements = eventsBoard.getActiveAnnouncementsFor(currentDay); List<Announcement> futureAnnouncements = eventsBoard.getActiveAnnouncementsAfter(currentDay); Collections.sort(futureAnnouncements, Announcement.SUBJECT_BEGIN_DATE); request.setAttribute("today-events", currentDayAnnouncements); request.setAttribute("future-events", futureAnnouncements); int eventCount = currentDayAnnouncements.size() + futureAnnouncements.size(); if (eventCount < ANNOUNCEMENTS_NUMBER) { List<Announcement> announcements = eventsBoard.getActiveAnnouncementsBefore(currentDay); announcements = announcements.subList( 0, Math.min(announcements.size(), ANNOUNCEMENTS_NUMBER - eventCount)); request.setAttribute("eventAnnouncements", announcements); } } return mapping.findForward("frontPage-" + site.getLayout()); }