package envoy.server.data; import java.util.Date; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Temporal; import javax.persistence.TemporalType; import envoy.data.MessageBuilder; /** * Project: envoy-server-standalone
* File: Message.java
* Created: 02.01.2020
* * @author Kai S. K. Engelbart * @since Envoy Server Standalone v0.1-alpha */ @Entity public class Message { @Id private long id; private User sender, recipient; @Temporal(TemporalType.TIMESTAMP) private Date creationDate; @Temporal(TemporalType.TIMESTAMP) private Date receivedDate; @Temporal(TemporalType.TIMESTAMP) private Date readDate; private envoy.data.Message.MessageStatus status; private String text; private byte[] attachment; public Message() {} // TODO: everything except ID public Message(envoy.data.Message message) { id = message.getId(); } public envoy.data.Message toCommonMessage() { // TODO: Attachment, dates return new MessageBuilder(sender.getId(), recipient.getId()).setText(text).setDate(creationDate).setStatus(status).build(); } public long getId() { return id; } public void setId(long id) { this.id = id; } public User getSender() { return sender; } public void setSender(User sender) { this.sender = sender; } public User getRecipient() { return recipient; } public void setRecipient(User recipient) { this.recipient = recipient; } public Date getCreationDate() { return creationDate; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } public Date getReceivedDate() { return receivedDate; } public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; } public Date getReadDate() { return readDate; } public void setReadDate(Date readDate) { this.readDate = readDate; } public envoy.data.Message.MessageStatus getStatus() { return status; } public void setStatus(envoy.data.Message.MessageStatus status) { this.status = status; } public String getText() { return text; } public void setText(String text) { this.text = text; } public byte[] getAttachment() { return attachment; } public void setAttachment(byte[] attachment) { this.attachment = attachment; } }