Common * Replace LocalDateTime with Instant everywhere Client * Display message creation date with system time zone in MessageControl * LocalDB#users now strictly contains Users * lastSync time stamp in LocalDB (saved per user) * isOnline parameter in save function (lastSync updated if true) * lastSync time stamp in LoginCredentials * No ClientConfig#getLoginCredentials because of missing information, moved to LoginScene * Pass LocalDB#lastSync to LoginCredentials in LoginScene Server * Explicit lastSync parameter for PersistenceManager#getPending(Group)Messages This sends the correct time stamp to the server, however the JPQL queries have yet to be adjusted.
108 lines
2.7 KiB
Java
108 lines
2.7 KiB
Java
package envoy.server.data;
|
|
|
|
import java.time.Instant;
|
|
import java.util.Set;
|
|
|
|
import javax.persistence.*;
|
|
|
|
/**
|
|
* This class acts as a superclass for all contacts, being {@link User}s and
|
|
* {@link Group}s. <br>
|
|
* <br>
|
|
* Project: <strong>envoy-server-standalone</strong><br>
|
|
* File: <strong>Contact.java</strong><br>
|
|
* Created: <strong>24.03.2020</strong><br>
|
|
*
|
|
* @author Maximilian Käfer
|
|
* @since Envoy Server Standalone v0.1-alpha
|
|
*/
|
|
|
|
@Entity
|
|
@Table(name = "contacts")
|
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
|
public abstract class Contact {
|
|
|
|
@Id
|
|
@GeneratedValue
|
|
protected long id;
|
|
protected String name;
|
|
|
|
@Column(name = "creation_date")
|
|
private Instant creationDate;
|
|
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
|
protected Set<Contact> contacts;
|
|
|
|
/**
|
|
* @return a {@link envoy.data.Contact} object of this envoy.server.data.Contact
|
|
* object.
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public abstract envoy.data.Contact toCommon();
|
|
|
|
/**
|
|
* Transforms this contact into a {@link envoy.data.Contact} where the contacts
|
|
* set of contacts is empty.
|
|
*
|
|
* @return a {@link envoy.data.Contact} object of this contact
|
|
* object.
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
protected abstract envoy.data.Contact toFlatCommon();
|
|
|
|
/**
|
|
* @return the ID of this contact.
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public long getID() { return id; }
|
|
|
|
/**
|
|
* Sets the ID of this contact.
|
|
*
|
|
* @param id to set for this contact
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public void setID(long id) { this.id = id; }
|
|
|
|
/**
|
|
* @return the name of this contact.
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public String getName() { return name; }
|
|
|
|
/**
|
|
* Sets the name of this contact.
|
|
*
|
|
* @param name to set for this contact
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public void setName(String name) { this.name = name; }
|
|
|
|
/**
|
|
* @return the contacts
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public Set<Contact> getContacts() { return contacts; }
|
|
|
|
/**
|
|
* @param contacts the contacts to set
|
|
* @since Envoy Server Standalone v0.1-beta
|
|
*/
|
|
public void setContacts(Set<Contact> contacts) { this.contacts = contacts; }
|
|
|
|
/**
|
|
* @return the creationDate
|
|
* @since Envoy Server Standalone v0.2-beta
|
|
*/
|
|
public Instant getCreationDate() { return creationDate; }
|
|
|
|
/**
|
|
* @param creationDate the creationDate to set
|
|
* @since Envoy Server Standalone v0.2-beta
|
|
*/
|
|
public void setCreationDate(Instant creationDate) { this.creationDate = creationDate; }
|
|
|
|
@Override
|
|
public String toString() { return String.format("%s[id=%d,name=%s, %d contact(s)]", getClass().getSimpleName(), id, name, contacts.size()); }
|
|
}
|