Search in sources :

Example 11 with Announcement

use of fi.otavanopisto.muikku.plugins.announcer.model.Announcement in project muikku by otavanopisto.

the class AnnouncementController method listActiveByWorkspaceEntities.

public List<Announcement> listActiveByWorkspaceEntities(List<WorkspaceEntity> workspaceEntities) {
    List<Long> workspaceEntityIds = new ArrayList<>(workspaceEntities.size());
    for (WorkspaceEntity workspaceEntity : workspaceEntities) {
        workspaceEntityIds.add(workspaceEntity.getId());
    }
    List<Announcement> result = new ArrayList<>(announcementDAO.listAnnouncements(Collections.emptyList(), workspaceEntities, AnnouncementEnvironmentRestriction.NONE, AnnouncementTimeFrame.CURRENT, false));
    Collections.sort(result, new Comparator<Announcement>() {

        public int compare(Announcement o1, Announcement o2) {
            return o2.getStartDate().compareTo(o1.getStartDate());
        }
    });
    return result;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) Announcement(fi.otavanopisto.muikku.plugins.announcer.model.Announcement) ArrayList(java.util.ArrayList)

Aggregations

Announcement (fi.otavanopisto.muikku.plugins.announcer.model.Announcement)11 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)8 Path (javax.ws.rs.Path)8 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)7 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)5 AnnouncementWorkspace (fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace)5 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)4 AnnouncementUserGroup (fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup)4 ArrayList (java.util.ArrayList)3 DELETE (javax.ws.rs.DELETE)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 UserGroupUserEntity (fi.otavanopisto.muikku.model.users.UserGroupUserEntity)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 AnnouncementEnvironmentRestriction (fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction)1 Date (java.util.Date)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1