Search in sources :

Example 41 with TitleItem

use of org.olat.core.commons.services.notifications.model.TitleItem in project openolat by klemens.

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;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date)

Example 42 with TitleItem

use of org.olat.core.commons.services.notifications.model.TitleItem in project openolat by klemens.

the class PFNotificationsHandler method createTitleInfo.

@Override
public String createTitleInfo(Subscriber subscriber, Locale locale) {
    Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
    TitleItem title = getTitleItem(subscriber.getPublisher(), translator);
    return title.getInfoContent("text/plain");
}
Also used : Translator(org.olat.core.gui.translator.Translator) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem)

Example 43 with TitleItem

use of org.olat.core.commons.services.notifications.model.TitleItem in project openolat by klemens.

the class PFNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    try {
        final Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
        PFNotifications notifications = new PFNotifications(subscriber, locale, compareDate, pfManager, notificationsManager, userManager);
        List<SubscriptionListItem> items = notifications.getItems();
        if (items.isEmpty()) {
            si = notificationsManager.getNoSubscriptionInfo();
        } else {
            String displayName = notifications.getDisplayname();
            String title = translator.translate("notifications.header", new String[] { displayName });
            si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, CSS_CLASS_ICON), items);
        }
    } catch (Exception e) {
        log.error("Unknown Exception", e);
        si = notificationsManager.getNoSubscriptionInfo();
    }
    return si;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem)

Example 44 with TitleItem

use of org.olat.core.commons.services.notifications.model.TitleItem in project openolat by klemens.

the class ForumNotificationsHandler method createTitleInfo.

@Override
public String createTitleInfo(Subscriber subscriber, Locale locale) {
    Translator translator = Util.createPackageTranslator(ForumNotificationsHandler.class, locale);
    TitleItem title = getTitleItem(subscriber.getPublisher(), translator);
    return title.getInfoContent("text/plain");
}
Also used : Translator(org.olat.core.gui.translator.Translator) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem)

Aggregations

TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)44 Translator (org.olat.core.gui.translator.Translator)34 Publisher (org.olat.core.commons.services.notifications.Publisher)26 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)26 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)26 Date (java.util.Date)24 BusinessGroup (org.olat.group.BusinessGroup)14 RepositoryEntry (org.olat.repository.RepositoryEntry)14 Identity (org.olat.core.id.Identity)12 OLATResourceable (org.olat.core.id.OLATResourceable)10 ICourse (org.olat.course.ICourse)10 BusinessGroupService (org.olat.group.BusinessGroupService)10 CourseNode (org.olat.course.nodes.CourseNode)4 DENCourseNode (de.bps.course.nodes.DENCourseNode)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Kalendar (org.olat.commons.calendar.model.Kalendar)2 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)2 InfoMessage (org.olat.commons.info.InfoMessage)2