use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class PortfolioNotificationsHandler method getSectionNotifications.
public List<SubscriptionListItem> getSectionNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
StringBuilder sb = new StringBuilder();
sb.append("select section").append(" from pfsection as section").append(" inner join fetch section.binder as binder").append(" where binder.key=:binderKey and section.lastModified>=:compareDate");
List<Section> sections = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Section.class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
Set<Long> uniqueSectionKeys = new HashSet<>();
Set<Long> uniqueCreateSectionKeys = new HashSet<>();
List<SubscriptionListItem> items = new ArrayList<>(sections.size());
for (Section section : sections) {
// section
Long sectionKey = section.getKey();
String sectionTitle = section.getTitle();
Date sectionCreationDate = section.getCreationDate();
Date sectionLastModified = section.getLastModified();
if (secCallback.canViewElement(section)) {
if (isSameDay(sectionCreationDate, sectionLastModified)) {
if (!uniqueCreateSectionKeys.contains(sectionKey)) {
uniqueCreateSectionKeys.add(sectionKey);
SubscriptionListItem item = sectionCreateItem(sectionKey, sectionTitle, sectionCreationDate, rootBusinessPath, translator);
items.add(item);
}
} else if (!uniqueSectionKeys.contains(sectionKey)) {
uniqueSectionKeys.add(sectionKey);
SubscriptionListItem item = sectionModifiedItem(sectionKey, sectionTitle, sectionLastModified, rootBusinessPath, translator);
items.add(item);
}
}
}
return items;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class PortfolioNotificationsHandler method getEvaluationNotifications.
public List<SubscriptionListItem> getEvaluationNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
StringBuilder sb = new StringBuilder();
sb.append("select page, evasession").append(" from pfpage as page").append(" inner join fetch page.section as section").append(" inner join fetch section.binder as binder").append(" left join evaluationformsession as evasession on (page.body.key = evasession.pageBody.key)").append(" where binder.key=:binderKey and evasession.status='done' and evasession.submissionDate>=:compareDate");
List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
List<SubscriptionListItem> items = new ArrayList<>(objects.size());
for (Object[] object : objects) {
// page
Page page = (Page) object[0];
Long pageKey = page.getKey();
String pageTitle = page.getTitle();
// session
EvaluationFormSession evaluationSession = (EvaluationFormSession) object[1];
Date submissionDate = evaluationSession.getSubmissionDate();
Date firstSubmissionDate = evaluationSession.getFirstSubmissionDate();
if (submissionDate != null && secCallback.canViewElement(page)) {
if (submissionDate.compareTo(firstSubmissionDate) == 0) {
SubscriptionListItem item = evaluationNewItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
items.add(item);
} else {
SubscriptionListItem item = evaluationModifiedItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
items.add(item);
}
}
}
return items;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class HistoryController method updateChangeLog.
protected void updateChangeLog() {
Date date = dateChooser.getDate();
List<SubscriptionListItem> items = notificationsHandler.getAllItems(binder, secCallback, date, getLocale());
Formatter formatter = Formatter.getInstance(getLocale());
List<SubscriptionListItemWrapper> wrappers = new ArrayList<>(items.size());
for (SubscriptionListItem item : items) {
String dateString = formatter.formatDate(item.getDate());
String linkName = "subscrIL_" + (counter++);
String linkLabel = StringHelper.escapeHtml(item.getDescription());
FormLink link = uifactory.addFormLink(linkName, linkLabel, null, flc, Link.NONTRANSLATED);
link.setUserObject(item.getBusinessPath());
SubscriptionListItemWrapper bundle = new SubscriptionListItemWrapper(linkName, dateString, item.getIconCssClass());
wrappers.add(bundle);
}
flc.contextPut("subscriptionItems", wrappers);
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class EPNotificationManager method getCommentNotifications.
public List<SubscriptionListItem> getCommentNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
List<EPCommentNotification> comments = getCommentNotifications(mapKey, compareDate);
List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
for (EPCommentNotification comment : comments) {
SubscriptionListItem item;
if (comment.getPageKey() == null) {
String[] title = new String[] { comment.getMapTitle(), userManager.getUserDisplayName(comment.getAuthor()) };
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(rootBusinessPath);
item = new SubscriptionListItem(translator.translate("li.newcomment", title), linkUrl, rootBusinessPath, comment.getCreationDate(), "o_info_icon");
} else {
String bPath = rootBusinessPath + "[EPPage:" + comment.getPageKey() + "]";
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
String[] title = new String[] { comment.getTitle(), userManager.getUserDisplayName(comment.getAuthor()) };
item = new SubscriptionListItem(translator.translate("li.newcomment", title), linkUrl, bPath, comment.getCreationDate(), "o_info_icon");
item.setUserObject(comment.getPageKey());
}
items.add(item);
}
return items;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class EPNotificationManager method getArtefactNotifications.
public List<SubscriptionListItem> getArtefactNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
List<EPArtefactNotification> links = getArtefactNotifications(mapKey, compareDate);
List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
for (EPArtefactNotification link : links) {
Long pageKey = link.getPageKey();
String targetTitle = link.getStructureTitle();
String[] title = new String[] { StringHelper.escapeHtml(userManager.getUserDisplayName(link.getAuthor())), StringHelper.escapeHtml(link.getArtefactTitle()), StringHelper.escapeHtml(targetTitle) };
String bPath = rootBusinessPath + "[EPPage:" + pageKey + "]";
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.newartefact", title), linkUrl, bPath, link.getCreationDate(), "o_icon_eportfolio_link");
item.setUserObject(pageKey);
items.add(item);
}
return items;
}
Aggregations