Search in sources :

Example 1 with DENCourseNode

use of de.bps.course.nodes.DENCourseNode in project openolat by klemens.

the class DENCourseNodeNotificationHandler method getCourseDENNodes.

/**
 * @param course
 * @return
 */
private List<DENCourseNode> getCourseDENNodes(ICourse course) {
    List<DENCourseNode> denNodes = new ArrayList<DENCourseNode>(10);
    Structure courseStruct = course.getRunStructure();
    CourseNode rootNode = courseStruct.getRootNode();
    getCourseDENNodes(rootNode, denNodes);
    return denNodes;
}
Also used : ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode) DENCourseNode(de.bps.course.nodes.DENCourseNode) Structure(org.olat.course.Structure) DENCourseNode(de.bps.course.nodes.DENCourseNode)

Example 2 with DENCourseNode

use of de.bps.course.nodes.DENCourseNode in project OpenOLAT by OpenOLAT.

the class DENCourseNodeNotificationHandler method getCourseDENNodes.

/**
 * @param course
 * @return
 */
private List<DENCourseNode> getCourseDENNodes(ICourse course) {
    List<DENCourseNode> denNodes = new ArrayList<DENCourseNode>(10);
    Structure courseStruct = course.getRunStructure();
    CourseNode rootNode = courseStruct.getRootNode();
    getCourseDENNodes(rootNode, denNodes);
    return denNodes;
}
Also used : ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode) DENCourseNode(de.bps.course.nodes.DENCourseNode) Structure(org.olat.course.Structure) DENCourseNode(de.bps.course.nodes.DENCourseNode)

Example 3 with DENCourseNode

use of de.bps.course.nodes.DENCourseNode in project OpenOLAT by OpenOLAT.

the class DENCourseNodeNotificationHandler method createSubscriptionInfo.

public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
    // 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 (courseStatus(course)) {
                final List<DENCourseNode> denNodes = getCourseDENNodes(course);
                final Translator trans = Util.createPackageTranslator(DENCourseNodeNotificationHandler.class, locale);
                String cssClass = new DENCourseNodeConfiguration().getIconCSSClass();
                si = new SubscriptionInfo(subscriber.getKey(), p.getType(), 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, null, modDate, cssClass);
                    si.addSubscriptionListItem(subListItem);
                }
            }
        } else {
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
    } catch (Exception e) {
        log.error("Error creating enrollment notifications for subscriber: " + subscriber.getKey(), e);
        checkPublisher(p);
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date) DENCourseNode(de.bps.course.nodes.DENCourseNode) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator)

Example 4 with DENCourseNode

use of de.bps.course.nodes.DENCourseNode in project openolat by klemens.

the class DENCourseNodeNotificationHandler method createSubscriptionInfo.

public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
    // 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 (courseStatus(course)) {
                final List<DENCourseNode> denNodes = getCourseDENNodes(course);
                final Translator trans = Util.createPackageTranslator(DENCourseNodeNotificationHandler.class, locale);
                String cssClass = new DENCourseNodeConfiguration().getIconCSSClass();
                si = new SubscriptionInfo(subscriber.getKey(), p.getType(), 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, null, modDate, cssClass);
                    si.addSubscriptionListItem(subListItem);
                }
            }
        } else {
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
    } catch (Exception e) {
        log.error("Error creating enrollment notifications for subscriber: " + subscriber.getKey(), e);
        checkPublisher(p);
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date) DENCourseNode(de.bps.course.nodes.DENCourseNode) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator)

Aggregations

DENCourseNode (de.bps.course.nodes.DENCourseNode)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Publisher (org.olat.core.commons.services.notifications.Publisher)2 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)2 Translator (org.olat.core.gui.translator.Translator)2 ICourse (org.olat.course.ICourse)2 Structure (org.olat.course.Structure)2 CourseNode (org.olat.course.nodes.CourseNode)2