package net.sourceforge.fenixedu.domain.messaging; import java.util.Comparator; import net.sourceforge.fenixedu.domain.organizationalStructure.Party; import net.sourceforge.fenixedu.domain.organizationalStructure.Unit; import net.sourceforge.fenixedu.presentationTier.servlets.filters.ContentInjectionRewriter; import pt.utl.ist.fenix.tools.util.i18n.MultiLanguageString; import com.linkare.commons.metainfo.Linkare; public class UnitAnnouncementBoard extends UnitAnnouncementBoard_Base { @Linkare(author = "Paulo Zenida") public static final MultiLanguageString ANNOUNCEMENTS = MultiLanguageString.i18n().add("pt", "Anúncios").finish(); @Linkare(author = "Paulo Zenida") public static final MultiLanguageString EVENTS = MultiLanguageString.i18n().add("pt", "Eventos").finish(); public static final Comparator BY_UNIT_DEPTH_AND_NAME = new Comparator() { public int compare(UnitAnnouncementBoard o1, UnitAnnouncementBoard o2) { Unit unit1 = o1.getParty(); Unit unit2 = o2.getParty(); int result = unit1.getUnitDepth() - unit2.getUnitDepth(); if (result == 0) { result = o1.getName().compareTo(o2.getName()); return (result == 0) ? o1.getIdInternal().compareTo(o2.getIdInternal()) : result; } else { return (result <= 0) ? -1 : 1; } } }; @Linkare(author = "Paulo Zenida", comments = "Forced the initialization of the name (by default, create the announcements board)") public UnitAnnouncementBoard(Unit unit) { super(); setUnit(unit); setName(ANNOUNCEMENTS); } @Override public void setParty(Party party) { super.setParty((Unit) party); } @Override public Unit getParty() { return (Unit) super.getParty(); } public void setUnit(Unit unit) { this.setParty(unit); } public Unit getUnit() { return getParty(); } @Override public Boolean getInitialAnnouncementsApprovedState() { return isCurrentUserApprover(); } public String getSiteParamForAnnouncementBoard(Announcement announcement) { String base = super.getSiteParamForAnnouncementBoard(announcement); StringBuffer actionPath = new StringBuffer(); actionPath.append("&"); actionPath.append(ContentInjectionRewriter.CONTEXT_ATTRIBUTE_NAME); actionPath.append("="); actionPath.append(this.getUnit().getSite().getReversePath()); return base + actionPath.toString(); } }