use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project OpenOLAT by OpenOLAT.
the class EPNotificationManager method getRatingNotifications.
public List<SubscriptionListItem> getRatingNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
List<EPRatingNotification> ratings = getRatingNotifications(mapKey, compareDate);
List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
for (EPRatingNotification rating : ratings) {
if (rating.getPageKey() == null) {
String[] title = new String[] { rating.getMapTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(rootBusinessPath);
if (rating.getLastModified() != null) {
// there is a modified date, also add this as a listitem
items.add(new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, rootBusinessPath, rating.getLastModified(), "o_icon_rating_on"));
}
items.add(new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, rootBusinessPath, rating.getCreationDate(), "o_icon_rating_on"));
} else {
String bPath = rootBusinessPath + "[EPPage:" + rating.getPageKey() + "]";
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
String[] title = new String[] { rating.getTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
if (rating.getLastModified() != null) {
// there is a modified date, also add this as a listitem
SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, bPath, rating.getLastModified(), "o_icon_rating_on");
item.setUserObject(rating.getPageKey());
items.add(item);
}
SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, bPath, rating.getCreationDate(), "o_icon_rating_on");
item.setUserObject(rating.getPageKey());
items.add(item);
}
}
return items;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project OpenOLAT by OpenOLAT.
the class EPNotificationManager method getPageSubscriptionListItem.
public List<SubscriptionListItem> getPageSubscriptionListItem(Long mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
List<EPStructureElementNotification> notifications = getPageNotifications(mapKey, compareDate);
List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
for (EPNotification notification : notifications) {
SubscriptionListItem item = null;
String[] title = new String[] { StringHelper.escapeHtml(notification.getTitle()) };
if ("page".equals(notification.getType())) {
String bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
item = new SubscriptionListItem(translator.translate("li.newpage", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_page");
item.setUserObject(notification.getPageKey());
} else {
String bPath = rootBusinessPath;
if (notification.getPageKey() != null) {
bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
}
String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
item = new SubscriptionListItem(translator.translate("li.newstruct", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_struct");
item.setUserObject(notification.getPageKey());
}
if (item != null) {
items.add(item);
}
}
return items;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project OpenOLAT by OpenOLAT.
the class AbstractTaskNotificationHandler method createSubscriptionInfo.
/**
* @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
* java.util.Locale, java.util.Date)
*/
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
SubscriptionInfo si;
// there could be news for me, investigate deeper
try {
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
String folderRoot = p.getData();
if (isLogDebugEnabled()) {
logDebug("folderRoot=", folderRoot);
}
final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
final Translator translator = Util.createPackageTranslator(AbstractTaskNotificationHandler.class, locale);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance("CourseModule", p.getResId()), false);
if (re == null) {
if (!checkPublisher(p)) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} else if (re.getRepositoryEntryStatus().isClosed()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
String displayName = re.getDisplayname();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate(getNotificationHeaderKey(), new String[] { displayName }), getCssClassIcon()), null);
SubscriptionListItem subListItem;
for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext(); ) {
FileInfo fi = it_infos.next();
MetaInfo metaInfo = fi.getMetaInfo();
String filePath = fi.getRelPath();
if (isLogDebugEnabled())
logDebug("filePath=", filePath);
String fullUserName = getUserNameFromFilePath(metaInfo, filePath);
Date modDate = fi.getLastModified();
String desc = translator.translate(getNotificationEntryKey(), new String[] { filePath, fullUserName });
String businessPath = p.getBusinessPath();
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
String iconCssClass = null;
if (metaInfo != null) {
iconCssClass = metaInfo.getIconCssClass();
}
subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, iconCssClass);
si.addSubscriptionListItem(subListItem);
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} catch (Exception e) {
getLogger().error("Cannot create task notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(p);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project OpenOLAT by OpenOLAT.
the class EPChangelogController method getItemBundlesForSubscriptionItems.
/**
* @param subscriptionItems
* @return
*/
private List<SubscriptionItemBundle> getItemBundlesForSubscriptionItems(List<SubscriptionListItem> subscriptionItems) {
List<SubscriptionItemBundle> bundles = new ArrayList<EPChangelogController.SubscriptionItemBundle>();
Formatter f = Formatter.getInstance(getTranslator().getLocale());
for (int i = 0; i < subscriptionItems.size(); i++) {
SubscriptionListItem listItem = subscriptionItems.get(i);
SubscriptionItemBundle bundle = new SubscriptionItemBundle();
bundle.setDateString(f.formatDate(listItem.getDate()));
String linkName = "subscrIL_" + i;
bundle.setLinkName(linkName);
String text = listItem.getDescription();
FormLink link = uifactory.addFormLink(linkName, text, null, flc, Link.NONTRANSLATED);
link.setUserObject(listItem.getUserObject());
bundle.setCssClass(listItem.getIconCssClass());
bundles.add(bundle);
}
return bundles;
}
use of org.olat.core.commons.services.notifications.model.SubscriptionListItem in project openolat by klemens.
the class SubscriptionInfo method getSpecificInfo.
/**
* looping over List with all contained items for this subs-info
*
* @param mimeType the mimetype of the desired output; supported are currently
* text/plain and text/html
* @return the specific (subscriber and type) info for a notification entry.
* e.g. "5 new posts" for a forum subscription, or "10 new uploads"
* for a folder subscription
*/
public String getSpecificInfo(String mimeType, Locale locale) {
if (!hasNews())
return "";
StringBuilder sb = new StringBuilder();
boolean firstDone = false;
if (mimeType.equals(SubscriptionInfo.MIME_HTML))
sb.append("<ul class='list-unstyled'>");
for (SubscriptionListItem subListItem : subsList) {
if (firstDone && mimeType.equals(SubscriptionInfo.MIME_PLAIN)) {
sb.append("\n");
}
// append list item itself
sb.append(subListItem.getContent(mimeType, locale));
firstDone = true;
}
if (mimeType.equals(SubscriptionInfo.MIME_HTML))
sb.append("</ul>");
return sb.toString();
}
Aggregations