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; } }
private void createAnnouncement(Thesis thesis) { if (thesis.getProposedDiscussed() == null) { return; } AnnouncementBoard board = getBoard(DEGREE_ANNOUNCEMENTS_BOARD_NAME, thesis.getDegree().getUnit()); if (board == null) { return; } DateTime now = new DateTime(); Announcement announcement = new Announcement(); announcement.setAnnouncementBoard(board); announcement.setCreator(AccessControl.getPerson()); announcement.setCreationDate(now); announcement.setPlace(thesis.getProposedPlace()); announcement.setVisible(true); announcement.setAuthor(getMessage("system.public.name")); announcement.setAuthorEmail(getMessage("system.public.email")); announcement.setPublicationBegin(now); announcement.setReferedSubjectBegin(thesis.getProposedDiscussed()); MultiLanguageString subject = new MultiLanguageString() .with( Language.pt, getAnnouncementSubject(thesis, "thesis.announcement.subject", Language.pt)) .with( Language.en, getAnnouncementSubject(thesis, "thesis.announcement.subject", Language.en)); MultiLanguageString body = new MultiLanguageString() .with(Language.pt, getAnnouncementBody(thesis, "thesis.announcement.body", Language.pt)) .with( Language.en, getAnnouncementBody(thesis, "thesis.announcement.body", Language.en)); announcement.setSubject(subject); announcement.setBody(body); }