2020-04-02 16:32:23 +02:00
|
|
|
package envoy.server.data;
|
|
|
|
|
2020-06-11 13:22:48 +02:00
|
|
|
import java.util.Date;
|
2020-04-02 16:32:23 +02:00
|
|
|
import java.util.Set;
|
|
|
|
|
2020-06-11 13:22:48 +02:00
|
|
|
import javax.persistence.CascadeType;
|
|
|
|
import javax.persistence.Entity;
|
|
|
|
import javax.persistence.FetchType;
|
|
|
|
import javax.persistence.GeneratedValue;
|
|
|
|
import javax.persistence.Id;
|
|
|
|
import javax.persistence.Inheritance;
|
|
|
|
import javax.persistence.InheritanceType;
|
|
|
|
import javax.persistence.ManyToMany;
|
|
|
|
import javax.persistence.Table;
|
|
|
|
import javax.persistence.Temporal;
|
|
|
|
import javax.persistence.TemporalType;
|
2020-04-02 16:32:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-04-02 20:41:05 +02:00
|
|
|
@Entity
|
2020-04-24 21:24:19 +02:00
|
|
|
@Table(name = "contacts")
|
|
|
|
@Inheritance(strategy = InheritanceType.JOINED)
|
2020-04-02 16:32:23 +02:00
|
|
|
public abstract class Contact {
|
|
|
|
|
|
|
|
@Id
|
2020-04-24 21:24:19 +02:00
|
|
|
@GeneratedValue
|
2020-04-02 16:32:23 +02:00
|
|
|
protected long id;
|
|
|
|
protected String name;
|
|
|
|
|
2020-06-11 13:22:48 +02:00
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
private Date creationDate;
|
|
|
|
|
2020-06-14 16:30:46 +02:00
|
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
2020-04-02 16:32:23 +02:00
|
|
|
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();
|
|
|
|
|
2020-04-09 21:01:19 +02:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2020-04-02 16:32:23 +02:00
|
|
|
/**
|
|
|
|
* @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; }
|
2020-04-06 22:55:27 +02:00
|
|
|
|
2020-06-11 13:22:48 +02:00
|
|
|
/**
|
|
|
|
* @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; }
|
|
|
|
|
2020-04-06 22:55:27 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String toString() { return String.format("%s[id=%d,name=%s, contacts=%s]", getClass().getSimpleName(), id, name, contacts); }
|
2020-04-02 16:32:23 +02:00
|
|
|
}
|