Search in sources :

Example 21 with SubscriptionListItem

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

the class PortfolioNotificationsHandler method getSectionNotifications.

public List<SubscriptionListItem> getSectionNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select section").append(" from pfsection as section").append(" inner join fetch section.binder as binder").append(" where binder.key=:binderKey and section.lastModified>=:compareDate");
    List<Section> sections = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Section.class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
    Set<Long> uniqueSectionKeys = new HashSet<>();
    Set<Long> uniqueCreateSectionKeys = new HashSet<>();
    List<SubscriptionListItem> items = new ArrayList<>(sections.size());
    for (Section section : sections) {
        // section
        Long sectionKey = section.getKey();
        String sectionTitle = section.getTitle();
        Date sectionCreationDate = section.getCreationDate();
        Date sectionLastModified = section.getLastModified();
        if (secCallback.canViewElement(section)) {
            if (isSameDay(sectionCreationDate, sectionLastModified)) {
                if (!uniqueCreateSectionKeys.contains(sectionKey)) {
                    uniqueCreateSectionKeys.add(sectionKey);
                    SubscriptionListItem item = sectionCreateItem(sectionKey, sectionTitle, sectionCreationDate, rootBusinessPath, translator);
                    items.add(item);
                }
            } else if (!uniqueSectionKeys.contains(sectionKey)) {
                uniqueSectionKeys.add(sectionKey);
                SubscriptionListItem item = sectionModifiedItem(sectionKey, sectionTitle, sectionLastModified, rootBusinessPath, translator);
                items.add(item);
            }
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) Section(org.olat.modules.portfolio.Section) Date(java.util.Date) HashSet(java.util.HashSet)

Example 22 with SubscriptionListItem

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

the class PortfolioNotificationsHandler method getEvaluationNotifications.

public List<SubscriptionListItem> getEvaluationNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select page, evasession").append(" from pfpage as page").append(" inner join fetch page.section as section").append(" inner join fetch section.binder as binder").append(" left join evaluationformsession as evasession on (page.body.key = evasession.pageBody.key)").append(" where binder.key=:binderKey and evasession.status='done' and evasession.submissionDate>=:compareDate");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
    List<SubscriptionListItem> items = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        // page
        Page page = (Page) object[0];
        Long pageKey = page.getKey();
        String pageTitle = page.getTitle();
        // session
        EvaluationFormSession evaluationSession = (EvaluationFormSession) object[1];
        Date submissionDate = evaluationSession.getSubmissionDate();
        Date firstSubmissionDate = evaluationSession.getFirstSubmissionDate();
        if (submissionDate != null && secCallback.canViewElement(page)) {
            if (submissionDate.compareTo(firstSubmissionDate) == 0) {
                SubscriptionListItem item = evaluationNewItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
                items.add(item);
            } else {
                SubscriptionListItem item = evaluationModifiedItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
                items.add(item);
            }
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Date(java.util.Date)

Example 23 with SubscriptionListItem

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

the class HistoryController method updateChangeLog.

protected void updateChangeLog() {
    Date date = dateChooser.getDate();
    List<SubscriptionListItem> items = notificationsHandler.getAllItems(binder, secCallback, date, getLocale());
    Formatter formatter = Formatter.getInstance(getLocale());
    List<SubscriptionListItemWrapper> wrappers = new ArrayList<>(items.size());
    for (SubscriptionListItem item : items) {
        String dateString = formatter.formatDate(item.getDate());
        String linkName = "subscrIL_" + (counter++);
        String linkLabel = StringHelper.escapeHtml(item.getDescription());
        FormLink link = uifactory.addFormLink(linkName, linkLabel, null, flc, Link.NONTRANSLATED);
        link.setUserObject(item.getBusinessPath());
        SubscriptionListItemWrapper bundle = new SubscriptionListItemWrapper(linkName, dateString, item.getIconCssClass());
        wrappers.add(bundle);
    }
    flc.contextPut("subscriptionItems", wrappers);
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Formatter(org.olat.core.util.Formatter) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Date(java.util.Date)

Example 24 with SubscriptionListItem

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

the class EPNotificationManager method getCommentNotifications.

public List<SubscriptionListItem> getCommentNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPCommentNotification> comments = getCommentNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPCommentNotification comment : comments) {
        SubscriptionListItem item;
        if (comment.getPageKey() == null) {
            String[] title = new String[] { comment.getMapTitle(), userManager.getUserDisplayName(comment.getAuthor()) };
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(rootBusinessPath);
            item = new SubscriptionListItem(translator.translate("li.newcomment", title), linkUrl, rootBusinessPath, comment.getCreationDate(), "o_info_icon");
        } else {
            String bPath = rootBusinessPath + "[EPPage:" + comment.getPageKey() + "]";
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            String[] title = new String[] { comment.getTitle(), userManager.getUserDisplayName(comment.getAuthor()) };
            item = new SubscriptionListItem(translator.translate("li.newcomment", title), linkUrl, bPath, comment.getCreationDate(), "o_info_icon");
            item.setUserObject(comment.getPageKey());
        }
        items.add(item);
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EPCommentNotification(org.olat.portfolio.model.notification.EPCommentNotification) ArrayList(java.util.ArrayList)

Example 25 with SubscriptionListItem

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

the class EPNotificationManager method getArtefactNotifications.

public List<SubscriptionListItem> getArtefactNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPArtefactNotification> links = getArtefactNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPArtefactNotification link : links) {
        Long pageKey = link.getPageKey();
        String targetTitle = link.getStructureTitle();
        String[] title = new String[] { StringHelper.escapeHtml(userManager.getUserDisplayName(link.getAuthor())), StringHelper.escapeHtml(link.getArtefactTitle()), StringHelper.escapeHtml(targetTitle) };
        String bPath = rootBusinessPath + "[EPPage:" + pageKey + "]";
        String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
        SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.newartefact", title), linkUrl, bPath, link.getCreationDate(), "o_icon_eportfolio_link");
        item.setUserObject(pageKey);
        items.add(item);
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) EPArtefactNotification(org.olat.portfolio.model.notification.EPArtefactNotification)

Aggregations

SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)92 Date (java.util.Date)54 Publisher (org.olat.core.commons.services.notifications.Publisher)36 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)36 ArrayList (java.util.ArrayList)32 Translator (org.olat.core.gui.translator.Translator)30 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)26 Identity (org.olat.core.id.Identity)20 RepositoryEntry (org.olat.repository.RepositoryEntry)20 OLATResourceable (org.olat.core.id.OLATResourceable)12 ICourse (org.olat.course.ICourse)10 FileInfo (org.olat.core.commons.modules.bc.FileInfo)8 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)8 Formatter (org.olat.core.util.Formatter)6 BusinessGroup (org.olat.group.BusinessGroup)6 Page (org.olat.modules.portfolio.Page)6 HashSet (java.util.HashSet)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 CourseNode (org.olat.course.nodes.CourseNode)4 Section (org.olat.modules.portfolio.Section)4