Search in sources :

Example 1 with ReadMessageImpl

use of org.olat.modules.fo.model.ReadMessageImpl in project OpenOLAT by OpenOLAT.

the class ForumManager method markNewMessageAsRead.

/**
 * Optimized method to mark newly created messages as read.
 *
 * @param identity
 * @param forum
 * @param msg
 */
public void markNewMessageAsRead(Identity identity, Forum forum, Message msg) {
    // Check if the message was not already deleted
    ReadMessageImpl readMessage = new ReadMessageImpl();
    readMessage.setIdentity(identity);
    readMessage.setMessage(msg);
    readMessage.setForum(forum);
    dbInstance.getCurrentEntityManager().persist(readMessage);
}
Also used : ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 2 with ReadMessageImpl

use of org.olat.modules.fo.model.ReadMessageImpl in project OpenOLAT by OpenOLAT.

the class ForumManager method markAsRead.

/**
 * Implementation with one entry per forum message.
 * Adds a new entry into the ReadMessage for the input message and identity.
 * @param msg
 * @param identity
 */
public void markAsRead(Identity identity, Forum forum, MessageLight msg) {
    // Check if the message was not already deleted
    Message retrievedMessage = loadMessage(msg.getKey());
    if (retrievedMessage != null) {
        ReadMessageImpl readMessage = new ReadMessageImpl();
        readMessage.setIdentity(identity);
        if (msg instanceof MessageLightImpl) {
            readMessage.setMessage(msg);
        } else {
            msg = dbInstance.getCurrentEntityManager().getReference(MessageLightImpl.class, msg.getKey());
            readMessage.setMessage(msg);
        }
        readMessage.setForum(forum);
        dbInstance.getCurrentEntityManager().persist(readMessage);
    }
}
Also used : Message(org.olat.modules.fo.Message) MessageLightImpl(org.olat.modules.fo.model.MessageLightImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 3 with ReadMessageImpl

use of org.olat.modules.fo.model.ReadMessageImpl in project openolat by klemens.

the class ForumManager method markNewMessageAsRead.

/**
 * Optimized method to mark newly created messages as read.
 *
 * @param identity
 * @param forum
 * @param msg
 */
public void markNewMessageAsRead(Identity identity, Forum forum, Message msg) {
    // Check if the message was not already deleted
    ReadMessageImpl readMessage = new ReadMessageImpl();
    readMessage.setIdentity(identity);
    readMessage.setMessage(msg);
    readMessage.setForum(forum);
    dbInstance.getCurrentEntityManager().persist(readMessage);
}
Also used : ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 4 with ReadMessageImpl

use of org.olat.modules.fo.model.ReadMessageImpl in project openolat by klemens.

the class ForumManager method markAsRead.

/**
 * Implementation with one entry per forum message.
 * Adds a new entry into the ReadMessage for the input message and identity.
 * @param msg
 * @param identity
 */
public void markAsRead(Identity identity, Forum forum, MessageLight msg) {
    // Check if the message was not already deleted
    Message retrievedMessage = loadMessage(msg.getKey());
    if (retrievedMessage != null) {
        ReadMessageImpl readMessage = new ReadMessageImpl();
        readMessage.setIdentity(identity);
        if (msg instanceof MessageLightImpl) {
            readMessage.setMessage(msg);
        } else {
            msg = dbInstance.getCurrentEntityManager().getReference(MessageLightImpl.class, msg.getKey());
            readMessage.setMessage(msg);
        }
        readMessage.setForum(forum);
        dbInstance.getCurrentEntityManager().persist(readMessage);
    }
}
Also used : Message(org.olat.modules.fo.Message) MessageLightImpl(org.olat.modules.fo.model.MessageLightImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Aggregations

ReadMessageImpl (org.olat.modules.fo.model.ReadMessageImpl)4 Message (org.olat.modules.fo.Message)2 MessageLightImpl (org.olat.modules.fo.model.MessageLightImpl)2