Ejemplo n.º 1
0
  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());
  }
Ejemplo n.º 2
0
  protected Unit getUnit(HttpServletRequest request) {
    Unit unit = (Unit) request.getAttribute("unit");

    if (unit == null) {
      FilterFunctionalityContext context =
          (FilterFunctionalityContext) AbstractFunctionalityContext.getCurrentContext(request);
      UnitSite site = (UnitSite) context.getSelectedContainer();
      unit = site.getUnit();
    }

    return unit;
  }
Ejemplo n.º 3
0
  public Unit getUnit(HttpServletRequest request) {
    String parameter = request.getParameter(getContextParamName());

    if (parameter == null) {
      UnitSite site = SiteMapper.getSite(request);
      if (site != null) {
        return site.getUnit();
      }
      UnitAnnouncementBoard board = getDomainObject(request, "announcementBoardId");
      if (board != null) {
        return board.getUnit();
      }
      Announcement announcement = getDomainObject(request, "announcementId");
      if (announcement != null) {
        return ((UnitAnnouncementBoard) announcement.getAnnouncementBoard()).getUnit();
      }
    }

    try {
      return (Unit) FenixFramework.getDomainObject(parameter);
    } catch (NumberFormatException e) {
      return null;
    }
  }
Ejemplo n.º 4
0
 protected void run(UnitSite site, Person person) {
   site.removeManagers(person);
 }