/** * @see * org.olat.core.gui.control.generic.portal.AbstractPortletRunController#reloadModel(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.generic.portal.SortingCriteria) */ protected void reloadModel(SortingCriteria sortingCriteria) { if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) { Map<Subscriber, SubscriptionInfo> subscriptionMap = NotificationHelper.getSubscriptionMap(getIdentity(), getLocale(), true, compareDate); notificationsList = new ArrayList<Subscriber>(); for (Iterator<Map.Entry<Subscriber, SubscriptionInfo>> it_subs = subscriptionMap.entrySet().iterator(); it_subs.hasNext(); ) { Map.Entry<Subscriber, SubscriptionInfo> sInfo = it_subs.next(); Subscriber subscrer = sInfo.getKey(); SubscriptionInfo infos = sInfo.getValue(); if (infos.hasNews()) { notificationsList.add(subscrer); } } notificationsList = getSortedList(notificationsList, sortingCriteria); List<PortletEntry<Subscriber>> entries = convertNotificationToPortletEntryList(notificationsList); notificationListModel = new NotificationsPortletTableDataModel(entries, getLocale(), subscriptionMap); tableCtr.setTableDataModel(notificationListModel); } else { reloadModel(getPersistentManuallySortedItems()); } }
private List<PortletEntry<Subscriber>> getAllPortletEntries() { notificationsList = man.getValidSubscribers(getIdentity()); // 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); if (notifHandler == null) { it_subs.remove(); } else { SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, getLocale(), compareDate); if (!subsInfo.hasNews()) { it_subs.remove(); } } } return convertNotificationToPortletEntryList(notificationsList); }
/** @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int) */ public final Object getValueAt(int row, int col) { PortletEntry<Subscriber> entry = getObject(row); 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(); return NewControllerFactory.translateResourceableTypeName(innerType, locale); default: return "error"; } }
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()); }