Search in sources :

Example 1 with EPRatingNotification

use of org.olat.portfolio.model.notification.EPRatingNotification in project OpenOLAT by OpenOLAT.

the class EPNotificationManager method getRatingNotifications.

public List<SubscriptionListItem> getRatingNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPRatingNotification> ratings = getRatingNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPRatingNotification rating : ratings) {
        if (rating.getPageKey() == null) {
            String[] title = new String[] { rating.getMapTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(rootBusinessPath);
            if (rating.getLastModified() != null) {
                // there is a modified date, also add this as a listitem
                items.add(new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, rootBusinessPath, rating.getLastModified(), "o_icon_rating_on"));
            }
            items.add(new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, rootBusinessPath, rating.getCreationDate(), "o_icon_rating_on"));
        } else {
            String bPath = rootBusinessPath + "[EPPage:" + rating.getPageKey() + "]";
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            String[] title = new String[] { rating.getTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
            if (rating.getLastModified() != null) {
                // there is a modified date, also add this as a listitem
                SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, bPath, rating.getLastModified(), "o_icon_rating_on");
                item.setUserObject(rating.getPageKey());
                items.add(item);
            }
            SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, bPath, rating.getCreationDate(), "o_icon_rating_on");
            item.setUserObject(rating.getPageKey());
            items.add(item);
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EPRatingNotification(org.olat.portfolio.model.notification.EPRatingNotification) ArrayList(java.util.ArrayList)

Example 2 with EPRatingNotification

use of org.olat.portfolio.model.notification.EPRatingNotification in project OpenOLAT by OpenOLAT.

the class EPNotificationManager method getRatingNotifications.

private List<EPRatingNotification> getRatingNotifications(List<Long> mapKey, Date compareDate) {
    if (mapKey == null || mapKey.isEmpty()) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select notification from ").append(EPRatingNotification.class.getName()).append(" as notification").append(" inner join fetch notification.author").append(" where notification.creationDate>=:currentDate and notification.mapKey in (:mapKey)");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setDate("currentDate", compareDate);
    query.setParameterList("mapKey", mapKey);
    @SuppressWarnings("unchecked") List<EPRatingNotification> notifications = query.list();
    return notifications;
}
Also used : EPRatingNotification(org.olat.portfolio.model.notification.EPRatingNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 3 with EPRatingNotification

use of org.olat.portfolio.model.notification.EPRatingNotification in project openolat by klemens.

the class EPNotificationManager method getRatingNotifications.

private List<EPRatingNotification> getRatingNotifications(List<Long> mapKey, Date compareDate) {
    if (mapKey == null || mapKey.isEmpty()) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select notification from ").append(EPRatingNotification.class.getName()).append(" as notification").append(" inner join fetch notification.author").append(" where notification.creationDate>=:currentDate and notification.mapKey in (:mapKey)");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setDate("currentDate", compareDate);
    query.setParameterList("mapKey", mapKey);
    @SuppressWarnings("unchecked") List<EPRatingNotification> notifications = query.list();
    return notifications;
}
Also used : EPRatingNotification(org.olat.portfolio.model.notification.EPRatingNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 4 with EPRatingNotification

use of org.olat.portfolio.model.notification.EPRatingNotification in project openolat by klemens.

the class EPNotificationManager method getRatingNotifications.

public List<SubscriptionListItem> getRatingNotifications(List<Long> mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPRatingNotification> ratings = getRatingNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPRatingNotification rating : ratings) {
        if (rating.getPageKey() == null) {
            String[] title = new String[] { rating.getMapTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(rootBusinessPath);
            if (rating.getLastModified() != null) {
                // there is a modified date, also add this as a listitem
                items.add(new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, rootBusinessPath, rating.getLastModified(), "o_icon_rating_on"));
            }
            items.add(new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, rootBusinessPath, rating.getCreationDate(), "o_icon_rating_on"));
        } else {
            String bPath = rootBusinessPath + "[EPPage:" + rating.getPageKey() + "]";
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            String[] title = new String[] { rating.getTitle(), userManager.getUserDisplayName(rating.getAuthor()) };
            if (rating.getLastModified() != null) {
                // there is a modified date, also add this as a listitem
                SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.changerating", title), linkUrl, bPath, rating.getLastModified(), "o_icon_rating_on");
                item.setUserObject(rating.getPageKey());
                items.add(item);
            }
            SubscriptionListItem item = new SubscriptionListItem(translator.translate("li.newrating", title), linkUrl, bPath, rating.getCreationDate(), "o_icon_rating_on");
            item.setUserObject(rating.getPageKey());
            items.add(item);
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EPRatingNotification(org.olat.portfolio.model.notification.EPRatingNotification) ArrayList(java.util.ArrayList)

Aggregations

EPRatingNotification (org.olat.portfolio.model.notification.EPRatingNotification)4 ArrayList (java.util.ArrayList)2 DBQuery (org.olat.core.commons.persistence.DBQuery)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2