Search in sources :

Example 1 with MessageInfo

use of org.jbei.ice.lib.dto.message.MessageInfo in project ice by JBEI.

the class Messages method get.

public Results<MessageInfo> get(int start, int limit) {
    Account account = accountDAO.getByEmail(this.userId);
    List<Group> groups = DAOFactory.getGroupDAO().retrieveMemberGroups(account);
    List<Message> messages = new ArrayList<>(dao.retrieveMessages(account, groups, start, limit));
    Results<MessageInfo> results = new Results<>();
    for (Message message : messages) {
        Account from = accountDAO.getByEmail(message.getFromEmail());
        if (from == null)
            continue;
        MessageInfo info = new MessageInfo();
        info.setId(message.getId());
        info.setFrom(message.getFromEmail());
        info.setTitle(message.getTitle());
        info.setRead(message.isRead());
        info.setSent(message.getDateSent().getTime());
        results.getData().add(info);
    }
    int totalSize = dao.retrieveMessageCount(account, groups);
    results.setResultCount(totalSize);
    return results;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Message(org.jbei.ice.storage.model.Message) Results(org.jbei.ice.lib.dto.common.Results) ArrayList(java.util.ArrayList) MessageInfo(org.jbei.ice.lib.dto.message.MessageInfo)

Example 2 with MessageInfo

use of org.jbei.ice.lib.dto.message.MessageInfo in project ice by JBEI.

the class Message method toDataTransferObject.

@Override
public MessageInfo toDataTransferObject() {
    MessageInfo info = new MessageInfo();
    info.setId(getId());
    info.setFrom(getFromEmail());
    info.setMessage(getMessage());
    info.setTitle(getTitle());
    info.setRead(isRead());
    info.setSent(this.dateSent.getTime());
    return info;
}
Also used : MessageInfo(org.jbei.ice.lib.dto.message.MessageInfo)

Aggregations

MessageInfo (org.jbei.ice.lib.dto.message.MessageInfo)2 ArrayList (java.util.ArrayList)1 Results (org.jbei.ice.lib.dto.common.Results)1 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)1 Account (org.jbei.ice.storage.model.Account)1 Group (org.jbei.ice.storage.model.Group)1 Message (org.jbei.ice.storage.model.Message)1