Search in sources :

Example 1 with MessageLightImpl

use of org.olat.modules.fo.model.MessageLightImpl 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 2 with MessageLightImpl

use of org.olat.modules.fo.model.MessageLightImpl 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

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