|
1 | 1 | package com.backend.entities;
|
2 | 2 |
|
3 | 3 | import com.backend.entities.IDs.AccountID;
|
| 4 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 5 | +import org.springframework.data.annotation.Id; |
| 6 | +import org.springframework.data.annotation.PersistenceCreator; |
| 7 | +import org.springframework.data.annotation.Transient; |
| 8 | +import org.springframework.data.mongodb.core.mapping.Document; |
4 | 9 |
|
5 |
| -import java.sql.Timestamp; |
| 10 | +import java.util.Date; |
6 | 11 |
|
| 12 | +/** |
| 13 | + * Represents an Invitation entity |
| 14 | + */ |
| 15 | +@Document(collection = "InvitationsCollection") |
7 | 16 | public class Invitation {
|
8 | 17 | // The value is generated by Account.java
|
9 |
| - private final AccountID senderID; |
| 18 | + @Transient |
| 19 | + @JsonIgnore |
| 20 | + private final AccountID senderIDObject; |
10 | 21 |
|
11 |
| - // The value is generated by Account.java |
12 |
| - private final AccountID receiverID; |
| 22 | + @Transient |
| 23 | + @JsonIgnore |
| 24 | + private final AccountID receiverIDObject; |
| 25 | + |
| 26 | + @Id |
| 27 | + private final String ID; |
13 | 28 |
|
14 |
| - private final Timestamp timestamp; |
| 29 | + private final String senderID; |
| 30 | + private final String receiverID; |
| 31 | + private final Date timestamp; |
15 | 32 |
|
16 | 33 | // fields, getters
|
17 |
| - public Invitation(AccountID senderID, AccountID receiverID, Timestamp timestamp) { |
| 34 | + public Invitation(AccountID senderIDObject, AccountID receiverIDObject, Date timestamp) { |
| 35 | + this.ID = senderIDObject.getID() + receiverIDObject.getID(); |
| 36 | + |
| 37 | + this.senderIDObject = senderIDObject; |
| 38 | + this.senderID = senderIDObject.getID(); |
| 39 | + |
| 40 | + this.receiverIDObject = receiverIDObject; |
| 41 | + this.receiverID = receiverIDObject.getID(); |
| 42 | + |
| 43 | + this.timestamp = timestamp; |
| 44 | + } |
| 45 | + @PersistenceCreator |
| 46 | + public Invitation(String ID, String senderID, String receiverID, Date timestamp) { |
| 47 | + this.ID = ID; |
| 48 | + this.senderIDObject = new AccountID(senderID); |
| 49 | + this.receiverIDObject = new AccountID(receiverID); |
18 | 50 | this.senderID = senderID;
|
19 | 51 | this.receiverID = receiverID;
|
20 | 52 | this.timestamp = timestamp;
|
21 | 53 | }
|
22 | 54 |
|
23 |
| - public AccountID getSenderID() { |
| 55 | + // Getters |
| 56 | + |
| 57 | + /** |
| 58 | + * Retrieve the AccountID String as the sender |
| 59 | + * @return the AccountID String as the sender |
| 60 | + */ |
| 61 | + public String getSenderID() { |
24 | 62 | return this.senderID;
|
25 | 63 | }
|
26 | 64 |
|
27 |
| - public AccountID getReceiverID() { |
| 65 | + /** |
| 66 | + * Retrieve the AccountID String as the receiver |
| 67 | + * @return the AccountID String as the receiver |
| 68 | + */ |
| 69 | + public String getReceiverID() { |
28 | 70 | return this.receiverID;
|
29 | 71 | }
|
30 | 72 |
|
31 |
| - public Timestamp getTimestamp() { |
| 73 | + /** |
| 74 | + * Retrieve the AccountID Object as the sender |
| 75 | + * @return the AccountID Object as the sender |
| 76 | + */ |
| 77 | + public AccountID getSenderIDObject() { |
| 78 | + return this.senderIDObject; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Retrieve the Account Object as the retriever |
| 83 | + * @return the Account Object as the retriever |
| 84 | + */ |
| 85 | + public AccountID getReceiverIDObject() { |
| 86 | + return this.receiverIDObject; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Retrieve the TimeStamp as java.util.Date |
| 91 | + * @return the TimeStamp as java.util.Date |
| 92 | + */ |
| 93 | + public Date getTimestamp() { |
32 | 94 | return this.timestamp;
|
33 | 95 | }
|
34 | 96 | }
|
0 commit comments