Package org.olat.core.util.notifications

Examples of org.olat.core.util.notifications.SubscriptionInfo


    for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext();) {
      Subscriber subscriber = it_subs.next();
      Publisher pub = subscriber.getPublisher();
      try {
        NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
        SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, compareDate);
        if (!subsInfo.hasNews()) {
          it_subs.remove();
        }
      } catch(Exception e) {
        log.error("Cannot load publisher:" + pub, e);
      }
View Full Code Here


        Publisher pub = subscriber.getPublisher();
        switch (col) {
          case 0:
            Object subsInfoObj = subToSubInfo.get(subscriber);
            if(subsInfoObj instanceof SubscriptionInfo) {
              SubscriptionInfo subsInfo = (SubscriptionInfo)subsInfoObj;
              int newsCount = subsInfo.countSubscriptionListItems();
              if (newsCount == 1) {
                return translate("notificationsPortlet.single.news.in", subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN));                               
              } else {
                return translate("notificationsPortlet.multiple.news.in", new String[]{newsCount + "" , subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN)});               
              }
            }
            return "";
          case 1:         
            String innerType = pub.getType();
View Full Code Here

        PortletEntry entry = getObject(row);
        Subscriber subscriber = (Subscriber) entry.getValue();
        Publisher pub = subscriber.getPublisher();
        switch (col) {
          case 0: {       
            SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
            return subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN);
          }
          case 1: {
            SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
            if (!subsInfo.hasNews()) return "-";
            return subsInfo.getSpecificInfo(SubscriptionInfo.MIME_HTML, locale);
          }
          case 2:
            String innerType = pub.getType();
            String typeName = ControllerFactory.translateResourceableTypeName(innerType, locale);
            return typeName;
View Full Code Here

  public String getNewsAsTxt(Subscriber sub) {
    return getNews(sub, SubscriptionInfo.MIME_PLAIN);
  }

  private String getNews(Subscriber sub, String mimeType) {
    SubscriptionInfo subsInfo = subsInfoMap.get(sub);
    if (subsInfo == null || !subsInfo.hasNews()) return translator.translate("news.no.news");
    return subsInfo.getSpecificInfo(mimeType, translator.getLocale());
  }
View Full Code Here

  public String getTitleAsTxt(Subscriber sub) {
    return getTitle(sub, SubscriptionInfo.MIME_PLAIN);
  }

  private String getTitle(Subscriber sub, String mimeType) {
    SubscriptionInfo subsInfo = subsInfoMap.get(sub);
    if (subsInfo == null) return "";
    return subsInfo.getTitle(mimeType);
  }
View Full Code Here

    if (subsInfo == null) return "";
    return subsInfo.getTitle(mimeType);
  }
 
  public String getCustomUrl(Subscriber sub) {
    SubscriptionInfo subsInfo = subsInfoMap.get(sub);
    return subsInfo.getCustomUrl();
  }
View Full Code Here

public class CalendarNotificationHandler extends LogDelegator implements NotificationsHandler {

  private static final String CSS_CLASS_CALENDAR_ICON = "o_calendar_icon";

  public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();

    // do not try to create a subscription info if state is deleted - results in
    // exceptions, course
    // can't be loaded when already deleted
    if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
      Long id = p.getResId();
      String type = p.getSubidentifier();

      try {
        Translator translator = Util.createPackageTranslator(this.getClass(), locale);
       
        String calType = null;
        String title = null;
        if (type.equals(CalendarController.ACTION_CALENDAR_COURSE)) {
          String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(id);
          calType = CalendarManager.TYPE_COURSE;
          title = translator.translate("cal.notifications.header.course", new String[]{displayName});
        } else if (type.equals(CalendarController.ACTION_CALENDAR_GROUP)) {
          BusinessGroup group = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(id, false);
          calType = CalendarManager.TYPE_GROUP;
          title = translator.translate("cal.notifications.header.group", new String[]{group.getName()});
        }

        if (calType != null) {
          Formatter form = Formatter.getInstance(locale);
          si = new SubscriptionInfo(new TitleItem(title, CSS_CLASS_CALENDAR_ICON), null);
         
          String bPath;
          if(StringHelper.containsNonWhitespace(p.getBusinessPath())) {
            bPath = p.getBusinessPath();
          } else if("CalendarManager.course".equals(p.getResName())) {
            try {
              ICourse course = CourseFactory.loadCourse(p.getResId());
              RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
              bPath = "[RepositoryEntry:" + re.getKey() + "]";//Fallback
            } catch (Exception e) {
              logError("Error processing calendar notifications of publisher:" + p.getKey(), e);
              return NotificationsManager.getInstance().getNoSubscriptionInfo();
            }
          } else {
            //cannot make link without business path
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
 
          Kalendar cal = CalendarManagerFactory.getInstance().getCalendarManager().getCalendar(calType, id.toString());
          Collection<KalendarEvent> calEvents = cal.getEvents();
          for (KalendarEvent kalendarEvent : calEvents) {
            if (showEvent(compareDate, kalendarEvent)) {
              logDebug("found a KalendarEvent: " + kalendarEvent.getSubject() + " with time: " + kalendarEvent.getBegin()
                  + " modified before: " + compareDate.toString(), null);
              // found a modified event in this calendar
              Date modDate = null;
              if(kalendarEvent.getLastModified() > 0) {
                modDate = new Date(kalendarEvent.getLastModified());
              } else if(kalendarEvent.getCreated() > 0) {
                modDate = new Date(kalendarEvent.getCreated());
              } else if(kalendarEvent.getBegin() != null) {
                modDate = kalendarEvent.getBegin();
              }
             
              String subject = kalendarEvent.getSubject();
              String location = kalendarEvent.getLocation() == null ? "" : translator.translate("cal.notifications.location",
                  new String[] { kalendarEvent.getLocation() });
              String dateStr;
              if (kalendarEvent.isAllDayEvent()) {
                dateStr = form.formatDate(kalendarEvent.getBegin());
              } else {
                dateStr = form.formatDate(kalendarEvent.getBegin()) + " - " + form.formatDate(kalendarEvent.getEnd());
              }
              String desc = translator.translate("cal.notifications.entry", new String[] { subject, dateStr, location });
              String businessPath = bPath + "[path=" + kalendarEvent.getID() + ":0]";
              String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath);
              SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, modDate, CSS_CLASS_CALENDAR_ICON);
              si.addSubscriptionListItem(subListItem);
            }
          }
        }
      } catch (Exception e) {
        logError("Unexpected exception", e);
View Full Code Here

TOP

Related Classes of org.olat.core.util.notifications.SubscriptionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.