Search in sources :

Example 1 with MessageImpl

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

the class ForumManager method createMessage.

/**
 * creates (in RAM only) a new Message<br>
 * fill the values and use saveMessage to make it persistent
 *
 * @return the message
 * @see ForumManager#saveMessage(Message)
 */
public Message createMessage(Forum forum, Identity creator, boolean guest) {
    MessageImpl message = new MessageImpl();
    message.setForum(forum);
    if (guest) {
        message.setGuest(guest);
    } else {
        message.setCreator(creator);
    }
    return message;
}
Also used : MessageImpl(org.olat.modules.fo.model.MessageImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 2 with MessageImpl

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

the class ForumManager method persistMessageInAnotherLocation.

/**
 * Persist message in another location.
 */
private Message persistMessageInAnotherLocation(Message oldMessage, Forum forum, Message top, Message parent) {
    // 1) take the new top messages forum to create a new child
    Message message = createMessage(forum, oldMessage.getCreator(), oldMessage.isGuest());
    ((MessageImpl) message).setCreationDate(oldMessage.getCreationDate());
    message.setLastModified(oldMessage.getLastModified());
    message.setModifier(oldMessage.getModifier());
    message.setTitle(oldMessage.getTitle());
    message.setBody(oldMessage.getBody());
    message.setPseudonym(oldMessage.getPseudonym());
    // 2) set the thread top to the new top message
    message.setThreadtop(top);
    // 3) maintain the hierarchy, parent and top message can be equal
    message.setParent(parent);
    Status status = Status.getStatus(oldMessage.getStatusCode());
    if (status != null) {
        status.setMoved(true);
        message.setStatusCode(Status.getStatusCode(status));
    }
    // 4) save the new massage in the new destination
    message = saveMessage(message);
    return message;
}
Also used : Status(org.olat.modules.fo.Status) Message(org.olat.modules.fo.Message) MessageImpl(org.olat.modules.fo.model.MessageImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 3 with MessageImpl

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

the class ForumManager method createMessage.

/**
 * creates (in RAM only) a new Message<br>
 * fill the values and use saveMessage to make it persistent
 *
 * @return the message
 * @see ForumManager#saveMessage(Message)
 */
public Message createMessage(Forum forum, Identity creator, boolean guest) {
    MessageImpl message = new MessageImpl();
    message.setForum(forum);
    if (guest) {
        message.setGuest(guest);
    } else {
        message.setCreator(creator);
    }
    return message;
}
Also used : MessageImpl(org.olat.modules.fo.model.MessageImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Example 4 with MessageImpl

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

the class ForumManager method persistMessageInAnotherLocation.

/**
 * Persist message in another location.
 */
private Message persistMessageInAnotherLocation(Message oldMessage, Forum forum, Message top, Message parent) {
    // 1) take the new top messages forum to create a new child
    Message message = createMessage(forum, oldMessage.getCreator(), oldMessage.isGuest());
    ((MessageImpl) message).setCreationDate(oldMessage.getCreationDate());
    message.setLastModified(oldMessage.getLastModified());
    message.setModifier(oldMessage.getModifier());
    message.setTitle(oldMessage.getTitle());
    message.setBody(oldMessage.getBody());
    message.setPseudonym(oldMessage.getPseudonym());
    // 2) set the thread top to the new top message
    message.setThreadtop(top);
    // 3) maintain the hierarchy, parent and top message can be equal
    message.setParent(parent);
    Status status = Status.getStatus(oldMessage.getStatusCode());
    if (status != null) {
        status.setMoved(true);
        message.setStatusCode(Status.getStatusCode(status));
    }
    // 4) save the new massage in the new destination
    message = saveMessage(message);
    return message;
}
Also used : Status(org.olat.modules.fo.Status) Message(org.olat.modules.fo.Message) MessageImpl(org.olat.modules.fo.model.MessageImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Aggregations

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