Implemented the GroupMessage class
This commit is contained in:
parent
f30732c71e
commit
61d2a8d307
221
src/main/java/envoy/server/data/GroupMessage.java
Normal file
221
src/main/java/envoy/server/data/GroupMessage.java
Normal file
@ -0,0 +1,221 @@
|
||||
package envoy.server.data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-server-standalone</strong><br>
|
||||
* File: <strong>GroupMessage.java</strong><br>
|
||||
* Created: <strong>18.04.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "groupMessages")
|
||||
// @NamedQuery()
|
||||
// TODO Add Queries
|
||||
public class GroupMessage {
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
private User sender;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
private Group group;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date creationDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date receivedDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date readDate;
|
||||
|
||||
@ElementCollection
|
||||
private Map<Long, envoy.data.Message.MessageStatus> memberMessageStatus;
|
||||
|
||||
private String text;
|
||||
private envoy.data.Message.MessageStatus status;
|
||||
private byte[] attachment;
|
||||
private boolean forwarded;
|
||||
|
||||
/**
|
||||
* The constructor for a database object.
|
||||
*
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public GroupMessage() {}
|
||||
|
||||
/**
|
||||
* Constructs a database groupMessage from a common groupMessage.
|
||||
*
|
||||
* @param groupMessage the {@link envoy.data.GroupMessage} to convert into a
|
||||
* database {@link GroupMessage}
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public GroupMessage(envoy.data.GroupMessage groupMessage) {
|
||||
PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
id = groupMessage.getID();
|
||||
status = groupMessage.getStatus();
|
||||
text = groupMessage.getText();
|
||||
creationDate = groupMessage.getCreationDate();
|
||||
receivedDate = groupMessage.getReceivedDate();
|
||||
readDate = groupMessage.getReadDate();
|
||||
sender = persistenceManager.getUserByID(groupMessage.getSenderID());
|
||||
group = persistenceManager.getGroupByID(groupMessage.getRecipientID());
|
||||
forwarded = groupMessage.isForwarded();
|
||||
memberMessageStatus = groupMessage.getMemberStatuses();
|
||||
// TODO: attachment = groupMessage.getAttachment().toByteArray();DOES NOT WORK
|
||||
// YET
|
||||
}
|
||||
|
||||
// TODO Implement GroupMessageBuilder and add toCommonGroupMessage method here
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public long getId() { return id; }
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setId(long id) { this.id = id; }
|
||||
|
||||
/**
|
||||
* @return the sender
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public User getSender() { return sender; }
|
||||
|
||||
/**
|
||||
* @param sender the sender to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setSender(User sender) { this.sender = sender; }
|
||||
|
||||
/**
|
||||
* @return the group
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public Group getGroup() { return group; }
|
||||
|
||||
/**
|
||||
* @param group the group to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setGroup(Group group) { this.group = group; }
|
||||
|
||||
/**
|
||||
* @return the creationDate
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public Date getCreationDate() { return creationDate; }
|
||||
|
||||
/**
|
||||
* @param creationDate the creationDate to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setCreationDate(Date creationDate) { this.creationDate = creationDate; }
|
||||
|
||||
/**
|
||||
* @return the receivedDate
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public Date getReceivedDate() { return receivedDate; }
|
||||
|
||||
/**
|
||||
* @param receivedDate the receivedDate to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; }
|
||||
|
||||
/**
|
||||
* @return the readDate
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public Date getReadDate() { return readDate; }
|
||||
|
||||
/**
|
||||
* @param readDate the readDate to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setReadDate(Date readDate) { this.readDate = readDate; }
|
||||
|
||||
/**
|
||||
* @return the memberMessageStatus
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public Map<Long, envoy.data.Message.MessageStatus> getMemberMessageStatus() { return memberMessageStatus; }
|
||||
|
||||
/**
|
||||
* @param memberMessageStatus the memberMessageStatus to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setMemberMessageStatus(Map<Long, envoy.data.Message.MessageStatus> memberMessageStatus) {
|
||||
this.memberMessageStatus = memberMessageStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public String getText() { return text; }
|
||||
|
||||
/**
|
||||
* @param text the text to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setText(String text) { this.text = text; }
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public envoy.data.Message.MessageStatus getStatus() { return status; }
|
||||
|
||||
/**
|
||||
* @param status the status to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setStatus(envoy.data.Message.MessageStatus status) { this.status = status; }
|
||||
|
||||
/**
|
||||
* @return the attachment
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public byte[] getAttachment() { return attachment; }
|
||||
|
||||
/**
|
||||
* @param attachment the attachment to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setAttachment(byte[] attachment) { this.attachment = attachment; }
|
||||
|
||||
/**
|
||||
* @return the forwarded
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public boolean isForwarded() { return forwarded; }
|
||||
|
||||
/**
|
||||
* @param forwarded the forwarded to set
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public void setForwarded(boolean forwarded) { this.forwarded = forwarded; }
|
||||
}
|
Reference in New Issue
Block a user