Search in sources :

Example 1 with EPStructureElementNotification

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

the class EPNotificationManager method getPageSubscriptionListItem.

public List<SubscriptionListItem> getPageSubscriptionListItem(Long mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPStructureElementNotification> notifications = getPageNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPNotification notification : notifications) {
        SubscriptionListItem item = null;
        String[] title = new String[] { StringHelper.escapeHtml(notification.getTitle()) };
        if ("page".equals(notification.getType())) {
            String bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            item = new SubscriptionListItem(translator.translate("li.newpage", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_page");
            item.setUserObject(notification.getPageKey());
        } else {
            String bPath = rootBusinessPath;
            if (notification.getPageKey() != null) {
                bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
            }
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            item = new SubscriptionListItem(translator.translate("li.newstruct", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_struct");
            item.setUserObject(notification.getPageKey());
        }
        if (item != null) {
            items.add(item);
        }
    }
    return items;
}
Also used : EPStructureElementNotification(org.olat.portfolio.model.notification.EPStructureElementNotification) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) EPNotification(org.olat.portfolio.model.notification.EPNotification)

Example 2 with EPStructureElementNotification

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

the class EPNotificationManager method getPageNotifications.

private List<EPStructureElementNotification> getPageNotifications(Long mapKey, Date compareDate) {
    StringBuilder sb = new StringBuilder();
    sb.append("select notification from ").append(EPStructureElementNotification.class.getName()).append(" as notification");
    sb.append(" where notification.creationDate>=:currentDate and (notification.key=:mapKey or notification.rootMapKey=:mapKey)");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setDate("currentDate", compareDate);
    query.setLong("mapKey", mapKey);
    @SuppressWarnings("unchecked") List<EPStructureElementNotification> notifications = query.list();
    return notifications;
}
Also used : EPStructureElementNotification(org.olat.portfolio.model.notification.EPStructureElementNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 3 with EPStructureElementNotification

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

the class EPNotificationManager method getPageSubscriptionListItem.

public List<SubscriptionListItem> getPageSubscriptionListItem(Long mapKey, String rootBusinessPath, Date compareDate, Translator translator) {
    List<EPStructureElementNotification> notifications = getPageNotifications(mapKey, compareDate);
    List<SubscriptionListItem> items = new ArrayList<SubscriptionListItem>();
    for (EPNotification notification : notifications) {
        SubscriptionListItem item = null;
        String[] title = new String[] { StringHelper.escapeHtml(notification.getTitle()) };
        if ("page".equals(notification.getType())) {
            String bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            item = new SubscriptionListItem(translator.translate("li.newpage", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_page");
            item.setUserObject(notification.getPageKey());
        } else {
            String bPath = rootBusinessPath;
            if (notification.getPageKey() != null) {
                bPath = rootBusinessPath + "[EPPage:" + notification.getPageKey() + "]";
            }
            String linkUrl = BusinessControlFactory.getInstance().getURLFromBusinessPathString(bPath);
            item = new SubscriptionListItem(translator.translate("li.newstruct", title), linkUrl, bPath, notification.getCreationDate(), "o_ep_icon_struct");
            item.setUserObject(notification.getPageKey());
        }
        if (item != null) {
            items.add(item);
        }
    }
    return items;
}
Also used : EPStructureElementNotification(org.olat.portfolio.model.notification.EPStructureElementNotification) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) EPNotification(org.olat.portfolio.model.notification.EPNotification)

Example 4 with EPStructureElementNotification

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

the class EPNotificationManager method getPageNotifications.

private List<EPStructureElementNotification> getPageNotifications(Long mapKey, Date compareDate) {
    StringBuilder sb = new StringBuilder();
    sb.append("select notification from ").append(EPStructureElementNotification.class.getName()).append(" as notification");
    sb.append(" where notification.creationDate>=:currentDate and (notification.key=:mapKey or notification.rootMapKey=:mapKey)");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setDate("currentDate", compareDate);
    query.setLong("mapKey", mapKey);
    @SuppressWarnings("unchecked") List<EPStructureElementNotification> notifications = query.list();
    return notifications;
}
Also used : EPStructureElementNotification(org.olat.portfolio.model.notification.EPStructureElementNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Aggregations

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