Reverted some changes related to ORM
This commit is contained in:
parent
9f2a245ce8
commit
891d6e3c43
@ -13,11 +13,23 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Contacts implements Serializable {
|
public class Contacts implements Serializable {
|
||||||
|
|
||||||
private long userId;
|
private final long userId;
|
||||||
private List<User> contacts;
|
private final List<User> contacts;
|
||||||
|
|
||||||
private static final long serialVersionUID = 136970804968152871L;
|
private static final long serialVersionUID = 136970804968152871L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of {@link Contacts}.
|
||||||
|
*
|
||||||
|
* @param userId the ID of the user this contacts belong to
|
||||||
|
* @param contacts the contact list
|
||||||
|
* @since Envoy Common v0.2-alpha
|
||||||
|
*/
|
||||||
|
public Contacts(long userId, List<User> contacts) {
|
||||||
|
this.userId = userId;
|
||||||
|
this.contacts = contacts;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return String.format("Contacts[%s]", contacts); }
|
public String toString() { return String.format("Contacts[%s]", contacts); }
|
||||||
|
|
||||||
@ -27,21 +39,9 @@ public class Contacts implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public long getUserId() { return userId; }
|
public long getUserId() { return userId; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @param userId the ID of the user this contacts belong to
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setUserId(long userId) { this.userId = userId; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of users messages can be sent to
|
* @return a list of users messages can be sent to
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public List<User> getContacts() { return contacts; }
|
public List<User> getContacts() { return contacts; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @param contacts the contact list to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setContacts(List<User> contacts) { this.contacts = contacts; }
|
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ public class Message implements Serializable {
|
|||||||
READ
|
READ
|
||||||
}
|
}
|
||||||
|
|
||||||
private long id, senderId, recipientId;
|
private final long id, senderId, recipientId;
|
||||||
private transient User sender, recipient;
|
private final Date creationDate;
|
||||||
private Date date;
|
private final String text;
|
||||||
private String text;
|
private final MessageAttachment<?> attachment;
|
||||||
private MessageAttachment<?> attachment;
|
|
||||||
|
|
||||||
|
private Date receivedDate, readDate;
|
||||||
private MessageStatus status;
|
private MessageStatus status;
|
||||||
|
|
||||||
private static final long serialVersionUID = -4393477412979594435L;
|
private static final long serialVersionUID = -4393477412979594435L;
|
||||||
@ -65,25 +65,23 @@ public class Message implements Serializable {
|
|||||||
* properties.
|
* properties.
|
||||||
*
|
*
|
||||||
* @param id unique ID
|
* @param id unique ID
|
||||||
* @param sender the user who sends the message
|
* @param senderId the ID of the user who sends the message
|
||||||
* @param recipient the user who receives the message
|
* @param recipientId the ID of the user who receives the message
|
||||||
* @param date the creation date of the message
|
* @param date the creation date of the message
|
||||||
* @param text the text content of the message
|
* @param text the text content of the message
|
||||||
* @param attachment the attachment of the message, if present
|
* @param attachment the attachment of the message, if present
|
||||||
* @param status the current {@link MessageStatus} of the message
|
* @param status the current {@link MessageStatus} of the message
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
Message(long id, User sender, User recipient, Date date, String text, MessageAttachment<?> attachment, MessageStatus status) {
|
Message(long id, long senderId, long recipientId, Date date, String text, MessageAttachment<?> attachment, MessageStatus status) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.sender = sender;
|
this.senderId = senderId;
|
||||||
this.recipient = recipient;
|
this.recipientId = recipientId;
|
||||||
this.date = date;
|
this.creationDate = date;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
|
||||||
senderId = sender.getId();
|
|
||||||
recipientId = recipient.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,13 +104,14 @@ public class Message implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("TextMessage[id=%d,sender=%s,recipient=%s,date=%s,status=%s,text=%s]",
|
return String.format("TextMessage[id=%d,sender=%s,recipient=%s,date=%s,status=%s,text=%s,hasAttachment=%b]",
|
||||||
id,
|
id,
|
||||||
sender,
|
senderId,
|
||||||
recipient,
|
recipientId,
|
||||||
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date),
|
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(creationDate),
|
||||||
status,
|
status,
|
||||||
text);
|
text,
|
||||||
|
attachment != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,24 +120,12 @@ public class Message implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public long getId() { return id; }
|
public long getId() { return id; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the sender of this message
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public User getSender() { return sender; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the sender ID of this message
|
* @return the sender ID of this message
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public long getSenderId() { return senderId; }
|
public long getSenderId() { return senderId; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the recipient of this message
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public User getRecipient() { return recipient; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the recipient ID of this message
|
* @return the recipient ID of this message
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
@ -149,7 +136,33 @@ public class Message implements Serializable {
|
|||||||
* @return the date at which this message was created
|
* @return the date at which this message was created
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public Date getDate() { return date; }
|
public Date getDate() { return creationDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which the message has been received by the sender
|
||||||
|
* @since Envoy Common v0.2-alpha
|
||||||
|
*/
|
||||||
|
public Date getReceivedDate() { return receivedDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param receivedDate the date at which the message has been received by the
|
||||||
|
* sender
|
||||||
|
* @since Envoy Common v0.2-alpha
|
||||||
|
*/
|
||||||
|
public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which the message has been read by the sender
|
||||||
|
* @since Envoy Common v0.2-alpha
|
||||||
|
*/
|
||||||
|
public Date getReadDate() { return readDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param readDate at which the message has been read by the sender
|
||||||
|
* @since Envoy Common v0.2-alpha
|
||||||
|
*/
|
||||||
|
public void setReadDate(Date readDate) { this.readDate = readDate; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the text content of this message
|
* @return the text content of this message
|
||||||
@ -168,74 +181,4 @@ public class Message implements Serializable {
|
|||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public MessageStatus getStatus() { return status; }
|
public MessageStatus getStatus() { return status; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param id the id to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setId(long id) { this.id = id; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param senderId the senderId to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setSenderId(long senderId) { this.senderId = senderId; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param recipientId the recipientId to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setRecipientId(long recipientId) { this.recipientId = recipientId; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param sender the sender to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setSender(User sender) { this.sender = sender; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param recipient the recipient to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setRecipient(User recipient) { this.recipient = recipient; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param date the date to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setDate(Date date) { this.date = date; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param text the text to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setText(String text) { this.text = text; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used for Hibernate. Please do not use.
|
|
||||||
*
|
|
||||||
* @param attachment the attachment to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setAttachment(MessageAttachment<?> attachment) { this.attachment = attachment; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status the status to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setStatus(MessageStatus status) { this.status = status; }
|
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ import envoy.data.Message.MessageStatus;
|
|||||||
public class MessageBuilder {
|
public class MessageBuilder {
|
||||||
|
|
||||||
// Mandatory properties without default values
|
// Mandatory properties without default values
|
||||||
private final User sender, recipient;
|
private final long senderId, recipientId;
|
||||||
|
|
||||||
// Properties with default values
|
// Properties with default values
|
||||||
private long id;
|
private long id;
|
||||||
@ -30,15 +30,13 @@ public class MessageBuilder {
|
|||||||
* Creates an instance of {@link MessageBuilder} with all mandatory values
|
* Creates an instance of {@link MessageBuilder} with all mandatory values
|
||||||
* without defaults for the {@link Message} class.
|
* without defaults for the {@link Message} class.
|
||||||
*
|
*
|
||||||
* @param sender the user who sends the {@link Message}
|
* @param senderId the ID of the user who sends the {@link Message}
|
||||||
* @param recipient the user who received the {@link Message}
|
* @param recipientId the ID of the user who received the {@link Message}
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public MessageBuilder(User sender, User recipient) {
|
public MessageBuilder(long senderId, long recipientId) {
|
||||||
if (sender == null) throw new NullPointerException("Message sender is null");
|
this.senderId = senderId;
|
||||||
if (recipient == null) throw new NullPointerException("Message recipient is null");
|
this.recipientId = recipientId;
|
||||||
this.sender = sender;
|
|
||||||
this.recipient = recipient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +67,7 @@ public class MessageBuilder {
|
|||||||
if (text == null) text = "";
|
if (text == null) text = "";
|
||||||
if (status == null) status = MessageStatus.WAITING;
|
if (status == null) status = MessageStatus.WAITING;
|
||||||
|
|
||||||
return new Message(id, sender, recipient, date, text, attachment, status);
|
return new Message(id, senderId, recipientId, date, text, attachment, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package envoy.data;
|
package envoy.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a unique user with a unique, numeric ID, a name and a current
|
* Represents a unique user with a unique, numeric ID, a name and a current
|
||||||
@ -45,10 +44,10 @@ public class User implements Serializable {
|
|||||||
OFFLINE;
|
OFFLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long id;
|
private final long id;
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
private UserStatus status;
|
private UserStatus status;
|
||||||
private Date lastOnline;
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3530947374856708236L;
|
private static final long serialVersionUID = 3530947374856708236L;
|
||||||
|
|
||||||
@ -64,16 +63,8 @@ public class User implements Serializable {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
status = UserStatus.ONLINE;
|
status = UserStatus.ONLINE;
|
||||||
setLastOnline(new Date());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to let Hibernate modify the values of an {@link User}
|
|
||||||
*
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public User() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); }
|
public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); }
|
||||||
|
|
||||||
@ -96,32 +87,8 @@ public class User implements Serializable {
|
|||||||
public UserStatus getStatus() { return status; }
|
public UserStatus getStatus() { return status; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param status the status to set
|
* @param status the next status of this user
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public void setStatus(UserStatus status) { this.status = status; }
|
public void setStatus(UserStatus status) { this.status = status; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id the id to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setId(long id) { this.id = id; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name the name to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setName(String name) { this.name = name; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the lastOnline
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public Date getLastOnline() { return lastOnline; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastOnline the lastOnline to set
|
|
||||||
* @since Envoy Common v0.2-alpha
|
|
||||||
*/
|
|
||||||
public void setLastOnline(Date lastOnline) { this.lastOnline = lastOnline; }
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user