Package org.olat.core.util.notifications

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


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

    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String displayname = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(p.getResId());
        if(displayname == null) {
          if(!checkPublisher(subscriber.getPublisher())) {
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
        }
        DialogElementsPropertyManager mgr = DialogElementsPropertyManager.getInstance();
        DialogPropertyElements elements = mgr.findDialogElements(p.getResId(), p.getSubidentifier());
        final List<DialogElement> dialogElements = elements.getDialogPropertyElements();
        final Translator translator = Util.createPackageTranslator(FileUploadNotificationHandler.class, locale);

        si = new SubscriptionInfo(new TitleItem(translator.translate("notifications.header", new String[]{displayname}), CSSS_CLASS_UPLOAD_ICON), null);
        SubscriptionListItem subListItem;
        for (DialogElement element : dialogElements) {
          // do only show entries newer then the ones already seen
          if (element.getDate().after(compareDate)) {
            String filename = element.getFilename();
            String creator = element.getAuthor();
            Identity ident = ManagerFactory.getManager().findIdentityByName(creator);
            Date modDate = element.getDate();

            String desc = translator.translate("notifications.entry", new String[] { filename, NotificationHelper.getFormatedName(ident) });
            String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, p.getBusinessPath());
            String cssClass = CSSHelper.createFiletypeIconCssClassFor(filename);

            subListItem = new SubscriptionListItem(desc, urlToSend, modDate, cssClass);
            si.addSubscriptionListItem(subListItem);
          }
        }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
View Full Code Here


  public SubscriptionInfo createSubscriptionInfo(final Subscriber subscriber, Locale locale, Date compareDate) {
    try {
      Publisher p = subscriber.getPublisher();
      Date latestNews = p.getLatestNewsDate();
     
      SubscriptionInfo si;
      // there could be news for me, investigate deeper
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String businessControlString = "";
        Long forumKey = Long.valueOf(0);
        try {
          forumKey = Long.parseLong(p.getData());
        } catch (NumberFormatException e) {
          logError("Could not parse forum key!", e);
          NotificationsManager.getInstance().deactivate(p);
          return NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
        final List<Message> mInfos = ForumManager.getInstance().getNewMessageInfo(forumKey, compareDate);
        final Translator translator = Util.createPackageTranslator(ForumNotificationsHandler.class, locale);
       
        businessControlString = p.getBusinessPath() + "[Message:";
       
        si = new SubscriptionInfo(getTitleItem(p, translator), null);
        for (Message mInfo : mInfos) {
          String title = mInfo.getTitle();
          Identity creator = mInfo.getCreator();
          Identity modifier = mInfo.getModifier();
          Date modDate = mInfo.getLastModified();
         
          String name;
          if(modifier != null) {
            name = NotificationHelper.getFormatedName(modifier);
          } else {
            name = NotificationHelper.getFormatedName(creator);
          }
          String desc = translator.translate("notifications.entry", new String[] { title, name })
          String urlToSend = null;
          if(p.getBusinessPath() != null) {
            urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessControlString + mInfo.getKey().toString() + "]");
          }
         
          SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, modDate, ForumHelper.CSS_ICON_CLASS_MESSAGE);
          si.addSubscriptionListItem(subListItem);
        }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
      return si;
View Full Code Here

  public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, final Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();

    final Date latestNews = p.getLatestNewsDate();
    Long resId = p.getResId();
    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    logDebug("compareDate=" + compareDate + " ; latestNews=" + latestNews, null);
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        OLATResourceable ores = null;
        if (p.getResName().equals( CourseModule.getCourseTypeName() ) ) {
          // resId = CourseResourceableId           p.getSubidentifier() = wikiCourseNode.getIdent()
          ICourse course = CourseFactory.loadCourse(resId);
          CourseEnvironment cenv = course.getCourseEnvironment();
          CourseNode courseNode = cenv.getRunStructure().getNode(p.getSubidentifier());
          if(courseNode == null){
            //OLAT-3356 because removing wikicoursenodes was not propagated to
            // disable subcriptions, we may end up here with a NULL wikicoursenode
            // Best we can do here -> return noSubsInfo and clean up
            NotificationsManager.getInstance().deactivate(p);
            // return nothing available
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
          ModuleConfiguration config = ((WikiCourseNode)courseNode).getModuleConfiguration();
          RepositoryEntry re = WikiEditController.getWikiRepoReference(config, true);
          resId = re.getOlatResource().getResourceableId();
          logDebug("resId=" + resId, null);
          ores = OresHelper.createOLATResourceableInstance(WikiResource.TYPE_NAME, resId);
          businessControlString = p.getBusinessPath() + "[path=";
        } else {
          // resName = 'BusinessGroup' or 'FileResource.WIKI'
          logDebug("p.getResName()=" + p.getResName(), null);
          ores = OresHelper.createOLATResourceableInstance(p.getResName(), resId);
          businessControlString = p.getBusinessPath() + "[path=";
        }
       
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
        final List<WikiPage> pages = wiki.getPagesByDate();
        Translator translator = Util.createPackageTranslator(WikiPageChangeOrCreateNotificationHandler.class, locale);
       
        TitleItem title = getTitleItem(p, translator);
        si = new SubscriptionInfo(title, null);
          SubscriptionListItem subListItem;
            for (Iterator<WikiPage> it = pages.listIterator(); it.hasNext();) {           
              WikiPage element = it.next();
             
              // do only show entries newer then the ones already seen
              Date modDate = new Date(element.getModificationTime());
              logDebug("modDate=" + modDate + " ; compareDate=" + compareDate, null);
              if (modDate.after(compareDate)) {
                if((element.getPageName().startsWith("O_") || element.getPageName().startsWith(WikiPage.WIKI_MENU_PAGE)) &&
                    (element.getModifyAuthor() <= 0)) {
                    //theses pages are created sometimes automatically. Check if this is the case
                    continue;
                }

                //build Businesscontrol-Path           
                String bControlString = businessControlString + element.getPageName() + "]";           
                String urlToSend = null;
                if(p.getBusinessPath() != null) {
                  urlToSend = NotificationHelper.getURLFromBusinessPathString(p, bControlString);
                }
               
                // string[] gets filled into translation key by adding {0...n} to
                // the string
                Identity ident = ManagerFactory.getManager().loadIdentityByKey(Long.valueOf(element.getModifyAuthor()));
                String desc = translator.translate("notifications.entry", new String[] { element.getPageName(), NotificationHelper.getFormatedName(ident)});             
                subListItem = new SubscriptionListItem(desc, urlToSend, modDate, CSS_CLASS_WIKI_PAGE_CHANGED_ICON);
                si.addSubscriptionListItem(subListItem);
              } else {
                //there are no more new pages so we stop here
                break;
              }
            }
View Full Code Here

  /**
   * @see org.olat.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.notifications.Subscriber,
   *      java.util.Locale, java.util.Date)
   */
  public SubscriptionInfo createSubscriptionInfo(final Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    if(!NotificationsUpgradeHelper.checkCourse(p)) {
      //course don't exist anymore
      NotificationsManager.getInstance().deactivate(p);
      return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
   
    try {
      Date latestNews = p.getLatestNewsDate();
      Identity identity = subscriber.getIdentity();

      // 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 courseId = new Long(p.getData());
        final ICourse course = loadCourseFromId(courseId);
        if (course != null) {
          // course admins or users with the course right to have full access to
          // the assessment tool will have full access to user tests
          CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
          final boolean hasFullAccess = (cgm.isIdentityCourseAdministrator(identity) ? true : cgm.hasRight(identity,
              CourseRights.RIGHT_ASSESSMENT));
          final List<Identity> coachedUsers = new ArrayList<Identity>();
          if (!hasFullAccess) {
            // initialize list of users, only when user has not full access
            List<BusinessGroup> coachedGroups = cgm.getOwnedLearningGroupsFromAllContexts(identity);
            Manager securityManager = ManagerFactory.getManager();
            for (Iterator<BusinessGroup> iter = coachedGroups.iterator(); iter.hasNext();) {
              BusinessGroup group = iter.next();
              coachedUsers.addAll(securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup()));
            }
          }

          List<IQTESTCourseNode> testNodes = getCourseTestNodes(course);
          Translator translator = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale);

          String title = translator.translate("notifications.header", new String[]{course.getCourseTitle()});
          si = new SubscriptionInfo(new TitleItem(title, CSS_CLASSS_IQTEST_ICON), null);

          for (Iterator<IQTESTCourseNode> i = testNodes.iterator(); i.hasNext();) {
            IQTESTCourseNode test = i.next();

            QTIResultManager qrm = QTIResultManager.getInstance();
            List testResultSets = qrm.getResultSets(course.getResourceableId(), test.getIdent(),
                test.getReferencedRepositoryEntry().getKey(), null);

            for (Iterator j = testResultSets.iterator(); j.hasNext();) {
              QTIResultSet qrs = (QTIResultSet) j.next();
              // - modify date on test set must be newer than last visit of
              // assessment tool
              // - user must either be course administrator (access to all
              // users granted)
              // or in a course right group with the assessment tool right or
              // a course
              // coach. in the second case, only tests of users are shown that
              // the coach does actually
              // coach himself. he does not have access to other users
              Date modDate = qrs.getLastModified();
              if (modDate.after(compareDate) && (hasFullAccess || PersistenceHelper.listContainsObjectByKey(coachedUsers, qrs.getIdentity()))) {
                String score = (new Float(qrs.getScore())).toString();
                String desc = translator.translate("notifications.entry", new String[] { test.getShortTitle(),
                    NotificationHelper.getFormatedName(qrs.getIdentity()), score });

                String urlToSend = null;
                if(p.getBusinessPath() != null) {
                  String businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + qrs.getIdentity().getKey() + "][CourseNode:" + test.getIdent() + "]";
                  urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath);
                }
                SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, modDate, CSS_CLASS_USER_ICON);
                si.addSubscriptionListItem(subListItem);
              }
            }
          }
        }
      } else {
View Full Code Here

 
  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);
        String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(p.getResId());
        if(displayName == null) {
          if(!checkPublisher(p)) {
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
        }
       
        si = new SubscriptionInfo(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(filePath);
             
              Date modDate = fi.getLastModified();
              String desc = translator.translate(getNotificationEntryKey(), new String[] { filePath, fullUserName });
              String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, p.getBusinessPath());
             
              String iconCssClass =  null;
              if (metaInfo != null) {
                iconCssClass = metaInfo.getIconCssClass();
              }
              subListItem = new SubscriptionListItem(desc, urlToSend, modDate, iconCssClass);
              si.addSubscriptionListItem(subListItem);           
            }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
    } catch (Exception e) {
View Full Code Here

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

    SubscriptionInfo si;
    Translator translator = Util.createPackageTranslator(this.getClass(), locale);
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        identities = UsersSubscriptionManager.getInstance().getNewIdentityCreated(compareDate);
        if (identities.isEmpty()) {
          si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        } else {
          translator = Util.createPackageTranslator(this.getClass(), locale);
          si = new SubscriptionInfo(new TitleItem(getItemTitle(translator), CSSHelper.CSS_CLASS_GROUP), null);
          SubscriptionListItem subListItem;
          for (Identity newUser : identities) {
            String desc = translator.translate("notifications.entry", new String[] { NotificationHelper.getFormatedName(newUser) });
            String businessPath = "[Identity:" + newUser.getKey() + "]";
            String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath);
            Date modDate = newUser.getCreationDate();
            subListItem = new SubscriptionListItem(desc, urlToSend, modDate, CSSHelper.CSS_CLASS_USER);
            si.addSubscriptionListItem(subListItem);
          }
        }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
View Full Code Here

*/
public class DENCourseNodeNotificationHandler implements NotificationsHandler {
  private static final OLog log = Tracing.createLoggerFor(DENCourseNodeNotificationHandler.class);

  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
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        Long courseId = new Long(p.getData());
        final ICourse course = loadCourseFromId(courseId);
        if (course != null) {
          final List<DENCourseNode> denNodes = getCourseDENNodes(course);
          final Translator trans = Util.createPackageTranslator(DENCourseNodeNotificationHandler.class, locale);

          String cssClass = new DENCourseNodeConfiguration().getIconCSSClass();
          si = new SubscriptionInfo(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, modDate, cssClass);
            si.addSubscriptionListItem(subListItem);
          }
        }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
View Full Code Here

    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();

    String businessPath = p.getBusinessPath() + "[path=";
   
    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String folderRoot = p.getData();
        final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
        final Translator translator = Util.createPackageTranslator(FolderNotificationsHandler.class, locale);

        si = new SubscriptionInfo(getTitleItem(p, translator), null);
        SubscriptionListItem subListItem;
        for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext();) {
          FileInfo fi = it_infos.next();
          String title = fi.getRelPath();
          MetaInfo metaInfo = fi.getMetaInfo();
          String iconCssClass =  null;
          if (metaInfo != null) {
            if (metaInfo.getTitle() != null) {
              title += " (" + metaInfo.getTitle() + ")";
            }
            iconCssClass = metaInfo.getIconCssClass();
          }
          Identity ident = fi.getAuthor();
          Date modDate = fi.getLastModified();

          String desc = translator.translate("notifications.entry", new String[] { title, NotificationHelper.getFormatedName(ident) });
          String urlToSend = null;
          if(p.getBusinessPath() != null) {
            urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath + fi.getRelPath() + "]");
          }
          subListItem = new SubscriptionListItem(desc, urlToSend, modDate, iconCssClass);
          si.addSubscriptionListItem(subListItem);
        }
      } else {
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
      }
    } catch (Exception e) {
View Full Code Here

      Publisher pub = subscriber.getPublisher();
      NotificationsHandler notifHandler = getNotificationsHandler(pub);
      // do not create subscription item when deleted
      if (isPublisherValid(pub)) {
        if (isLogDebugEnabled()) logDebug("NotifHandler: " + notifHandler.getClass().getName() + " compareDate: " + latestEmailed.toString() + " now: " + new Date().toString(), null);
        SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, latestEmailed);
        if (subsInfo.hasNews()) {
          String title = getFormatedTitle(subsInfo, subscriber, locale, mimeTypeTitle);
         
          String itemLink = null;
          if(subsInfo.getCustomUrl() != null) {
            itemLink = subsInfo.getCustomUrl();
          }
          if(itemLink == null && pub.getBusinessPath() != null) {
            itemLink = NotificationHelper.getURLFromBusinessPathString(pub, pub.getBusinessPath());
          }
         
          String description = subsInfo.getSpecificInfo(mimeTypeContent, locale);
          si = new SubscriptionItem(title, itemLink, description);
        }
      }
      return si;
    } catch (Exception e) {
View Full Code Here

    // calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones
    for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext();) {
      Subscriber subscriber = it_subs.next();
      Publisher pub = subscriber.getPublisher();
      NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
      SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, compareDate);
      if (!subsInfo.hasNews()) {
        it_subs.remove();
      }
    }
    return convertNotificationToPortletEntryList(notificationsList);
  }
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.