use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class InfoMessageNotificationHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
// can't be loaded when already deleted
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
try {
final Long resId = subscriber.getPublisher().getResId();
final String resName = subscriber.getPublisher().getResName();
String resSubPath = subscriber.getPublisher().getSubidentifier();
String displayName, notificationtitle;
if ("BusinessGroup".equals(resName)) {
BusinessGroupService groupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = groupService.loadBusinessGroup(resId);
displayName = group.getName();
notificationtitle = "notification.title.group";
} else {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(resName, resId), false);
if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
displayName = re.getDisplayname();
notificationtitle = "notification.title";
}
Translator translator = Util.createPackageTranslator(this.getClass(), locale);
String title = translator.translate(notificationtitle, new String[] { displayName });
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, CSS_CLASS_ICON), null);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(resName, resId);
List<InfoMessage> infos = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, null, compareDate, null, 0, 0);
for (InfoMessage info : infos) {
Identity ident = info.getAuthor();
String desc = translator.translate("notifications.entry", new String[] { info.getTitle(), NotificationHelper.getFormatedName(ident) });
String tooltip = info.getMessage();
String infoBusinessPath = info.getBusinessPath() + "[InfoMessage:" + info.getKey() + "]";
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(infoBusinessPath);
Date dateInfo = info.getModificationDate() == null ? info.getCreationDate() : info.getModificationDate();
SubscriptionListItem subListItem = new SubscriptionListItem(desc, tooltip, urlToSend, infoBusinessPath, dateInfo, CSS_CLASS_ICON);
si.addSubscriptionListItem(subListItem);
}
} catch (Exception e) {
log.error("Unexpected exception", e);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class DENCourseNodeNotificationHandler method createSubscriptionInfo.
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
// can't be loaded when already deleted
try {
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
Long courseId = new Long(p.getData());
final ICourse course = loadCourseFromId(courseId);
if (courseStatus(course)) {
final List<DENCourseNode> denNodes = getCourseDENNodes(course);
final Translator trans = Util.createPackageTranslator(DENCourseNodeNotificationHandler.class, locale);
String cssClass = new DENCourseNodeConfiguration().getIconCSSClass();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(trans.translate("notifications.header", new String[] { course.getCourseTitle() }), cssClass), null);
SubscriptionListItem subListItem;
for (DENCourseNode denNode : denNodes) {
String changer = "";
String desc = trans.translate("notifications.entry", new String[] { denNode.getLongTitle(), changer });
Date modDate = new Date();
subListItem = new SubscriptionListItem(desc, null, null, modDate, cssClass);
si.addSubscriptionListItem(subListItem);
}
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} catch (Exception e) {
log.error("Error creating enrollment notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(p);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class FolderNotificationsHandler method getTitleItem.
private TitleItem getTitleItem(Publisher p, Translator translator) {
String title;
try {
String resName = p.getResName();
if ("BusinessGroup".equals(resName)) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(p.getResId());
title = translator.translate("notifications.header.group", new String[] { bg.getName() });
} else if ("CourseModule".equals(resName)) {
String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(p.getResId());
title = translator.translate("notifications.header.course", new String[] { displayName });
} else {
title = translator.translate("notifications.header");
}
} catch (Exception e) {
log.error("", e);
checkPublisher(p);
title = translator.translate("notifications.header");
}
return new TitleItem(title, CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class MailNotificationsHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
if (!mailModule.isInternSystem()) {
return notificationsManager.getNoSubscriptionInfo();
}
String realMail = subscriber.getIdentity().getUser().getPreferences().getReceiveRealMail();
if ("true".equals(realMail)) {
// receive real e-mails
return notificationsManager.getNoSubscriptionInfo();
} else if (!StringHelper.containsNonWhitespace(realMail) && mailModule.isReceiveRealMailUserDefaultSetting()) {
// user has no settings, check the default setting
return notificationsManager.getNoSubscriptionInfo();
}
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
// can't be loaded when already deleted
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
try {
List<DBMailLight> inbox = mailManager.getInbox(subscriber.getIdentity(), Boolean.TRUE, Boolean.FALSE, compareDate, 0, -1);
if (!inbox.isEmpty()) {
Translator translator = Util.createPackageTranslator(MailModule.class, locale);
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate("mail.notification.type"), "o_co_icon"), null);
for (DBMailLight mail : inbox) {
String subject = mail.getSubject();
String businessPath = "[Inbox:0][Inbox:0][DBMail:" + mail.getKey() + "]";
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
SubscriptionListItem subListItem = new SubscriptionListItem(subject, urlToSend, businessPath, mail.getCreationDate(), "o_co_icon");
si.addSubscriptionListItem(subListItem);
}
}
} catch (Exception ex) {
logError("", ex);
}
}
if (si == null) {
si = notificationsManager.getNoSubscriptionInfo();
}
return si;
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class GTANotificationsHandler method createSubscriptionInfo.
@Override
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)) {
GTANotifications notifications = new GTANotifications(subscriber, locale, compareDate, repositoryService, gtaManager, businessGroupService, userManager, courseNodeAssessmentDao);
List<SubscriptionListItem> items = notifications.getItems();
if (items.isEmpty()) {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
} else {
String title = notifications.getNotifificationHeader();
TitleItem titleItem = new TitleItem(title, CSS_CLASS_ICON);
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), titleItem, items);
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} catch (Exception e) {
log.error("Cannot create gtask notifications for subscriber: " + subscriber.getKey(), e);
// checkPublisher(p);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
Aggregations