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;
}
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;
}
Aggregations