use of fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup 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.announcer.model.AnnouncementUserGroup in project muikku by otavanopisto.
the class AnnouncementUserGroupDAO method create.
public AnnouncementUserGroup create(Announcement announcement, Long userGroupEntityId, Boolean archived) {
AnnouncementUserGroup announcementUserGroup = new AnnouncementUserGroup();
announcementUserGroup.setAnnouncement(announcement);
announcementUserGroup.setUserGroupEntityId(userGroupEntityId);
announcementUserGroup.setArchived(archived);
return persist(announcementUserGroup);
}
use of fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup in project muikku by otavanopisto.
the class AnnouncementUserGroupDAO method listByArchived.
public List<AnnouncementUserGroup> listByArchived(Boolean archived) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<AnnouncementUserGroup> criteria = criteriaBuilder.createQuery(AnnouncementUserGroup.class);
Root<AnnouncementUserGroup> root = criteria.from(AnnouncementUserGroup.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(AnnouncementUserGroup_.archived), archived));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations