Search in sources :

Example 1 with WorkspaceBasicInfo

use of fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo in project muikku by otavanopisto.

the class AnnouncerRESTService method createRESTModel.

private AnnouncementRESTModel createRESTModel(Announcement announcement, List<AnnouncementUserGroup> announcementUserGroups, List<AnnouncementWorkspace> announcementWorkspaces) {
    AnnouncementRESTModel restModel = new AnnouncementRESTModel();
    restModel.setPublisherUserEntityId(announcement.getPublisherUserEntityId());
    restModel.setCaption(announcement.getCaption());
    restModel.setContent(announcement.getContent());
    restModel.setCreated(announcement.getCreated());
    restModel.setStartDate(announcement.getStartDate());
    restModel.setEndDate(announcement.getEndDate());
    restModel.setId(announcement.getId());
    restModel.setPubliclyVisible(announcement.getPubliclyVisible());
    restModel.setArchived(announcement.getArchived());
    List<Long> userGroupEntityIds = new ArrayList<>();
    for (AnnouncementUserGroup announcementUserGroup : announcementUserGroups) {
        userGroupEntityIds.add(announcementUserGroup.getUserGroupEntityId());
    }
    restModel.setUserGroupEntityIds(userGroupEntityIds);
    List<Long> workspaceEntityIds = new ArrayList<>();
    List<WorkspaceBasicInfo> workspaceBasicInfos = new ArrayList<>();
    for (AnnouncementWorkspace announcementWorkspace : announcementWorkspaces) {
        workspaceEntityIds.add(announcementWorkspace.getWorkspaceEntityId());
        WorkspaceBasicInfo workspaceBasicInfo = workspaceRESTModelController.workspaceBasicInfo(announcementWorkspace.getWorkspaceEntityId());
        if (workspaceBasicInfo != null)
            workspaceBasicInfos.add(workspaceBasicInfo);
        else
            logger.warning(String.format("Logged user couldn't find workspace basic info for workspace"));
    }
    restModel.setWorkspaceEntityIds(workspaceEntityIds);
    restModel.setWorkspaces(workspaceBasicInfos);
    Date date = currentDate();
    if (date.before(announcement.getStartDate())) {
        restModel.setTemporalStatus(AnnouncementTemporalStatus.UPCOMING);
    } else if (date.after(announcement.getEndDate())) {
        restModel.setTemporalStatus(AnnouncementTemporalStatus.ENDED);
    } else {
        restModel.setTemporalStatus(AnnouncementTemporalStatus.ACTIVE);
    }
    return restModel;
}
Also used : AnnouncementUserGroup(fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup) AnnouncementWorkspace(fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace) ArrayList(java.util.ArrayList) WorkspaceBasicInfo(fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo) Date(java.util.Date)

Example 2 with WorkspaceBasicInfo

use of fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo in project muikku by otavanopisto.

the class AnnouncementsViewBackingBean method init.

@RequestAction
public String init() {
    UserEntity loggedUserEntity = sessionController.getLoggedUserEntity();
    if (announcementId != null) {
        currentAnnouncement = announcementController.findById(announcementId);
        if (currentAnnouncement != null) {
            List<AnnouncementWorkspace> announcementWorkspaces = announcementController.listAnnouncementWorkspacesSortByUserFirst(currentAnnouncement, loggedUserEntity);
            currentAnnouncementWorkspaces = new ArrayList<WorkspaceBasicInfo>();
            for (AnnouncementWorkspace aw : announcementWorkspaces) {
                currentAnnouncementWorkspaces.add(workspaceRESTModelController.workspaceBasicInfo(aw.getWorkspaceEntityId()));
            }
        }
    }
    AnnouncementEnvironmentRestriction environment = sessionController.hasEnvironmentPermission(AnnouncerPermissions.LIST_ENVIRONMENT_GROUP_ANNOUNCEMENTS) ? AnnouncementEnvironmentRestriction.PUBLICANDGROUP : AnnouncementEnvironmentRestriction.PUBLIC;
    AnnouncementTimeFrame timeFrame = AnnouncementTimeFrame.CURRENT;
    activeAnnouncements = announcementController.listAnnouncements(true, true, environment, timeFrame, loggedUserEntity, false, false);
    return null;
}
Also used : AnnouncementWorkspace(fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace) AnnouncementTimeFrame(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementTimeFrame) AnnouncementEnvironmentRestriction(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction) WorkspaceBasicInfo(fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Aggregations

AnnouncementWorkspace (fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace)2 WorkspaceBasicInfo (fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceBasicInfo)2 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)1 AnnouncementEnvironmentRestriction (fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction)1 AnnouncementTimeFrame (fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementTimeFrame)1 AnnouncementUserGroup (fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)1