2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.entities;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
2017-10-12 17:41:20 +02:00
|
|
|
import java.util.Date;
|
2017-12-15 17:57:41 +01:00
|
|
|
import java.util.HashSet;
|
2017-10-18 15:12:25 +02:00
|
|
|
import java.util.Set;
|
2017-09-28 12:32:03 +02:00
|
|
|
import java.util.UUID;
|
2017-12-15 17:57:41 +01:00
|
|
|
|
|
|
|
import javax.persistence.*;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
|
import org.hibernate.annotations.Type;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
|
|
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|
|
|
|
|
|
|
|
|
|
|
@Entity
|
|
|
|
@Table(name="\"UserInfo\"")
|
2018-01-25 16:24:21 +01:00
|
|
|
public class UserInfo implements DataEntity<UserInfo>{
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
@Id
|
|
|
|
@GeneratedValue
|
|
|
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
2017-10-18 12:20:04 +02:00
|
|
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
|
|
private UUID id;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "email", nullable = false)
|
|
|
|
private String email = null;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "authorization_level", nullable = false)
|
|
|
|
private Short authorization_level; //0 admin, 1 user
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "usertype", nullable = false)
|
|
|
|
private Short usertype; // 0 internal, 1 external
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "verified_email", nullable = true)
|
|
|
|
private Boolean verified_email = null;
|
|
|
|
|
|
|
|
@Column(name = "name", nullable = true)
|
|
|
|
private String name = null;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "created", nullable = false)
|
|
|
|
private Date created = null;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "lastloggedin", nullable = true)
|
|
|
|
private Date lastloggedin = null;
|
|
|
|
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
@Type(type="eu.eudat.typedefinition.XMLType")
|
2017-10-12 17:41:20 +02:00
|
|
|
@Column(name = "additionalinfo", columnDefinition = "xml", nullable = true)
|
|
|
|
private String additionalinfo;
|
|
|
|
|
2017-10-20 17:11:40 +02:00
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
2017-10-27 12:52:12 +02:00
|
|
|
@JoinTable(name="\"UserDMP\"",
|
2017-10-19 14:31:36 +02:00
|
|
|
joinColumns={@JoinColumn(name="usr", referencedColumnName="id")},
|
2017-10-27 12:52:12 +02:00
|
|
|
inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
2017-10-19 14:31:36 +02:00
|
|
|
)
|
2017-10-27 12:52:12 +02:00
|
|
|
private Set<DMP> dmps;
|
2017-12-15 17:57:41 +01:00
|
|
|
|
|
|
|
@OneToMany(mappedBy="userInfo",fetch = FetchType.LAZY)
|
|
|
|
Set<Credential> credentials = new HashSet<>();
|
2018-01-31 16:39:16 +01:00
|
|
|
|
|
|
|
@OneToMany(mappedBy="userInfo",fetch = FetchType.LAZY)
|
|
|
|
Set<UserRole> userRoles = new HashSet<>();
|
2017-11-07 13:20:13 +01:00
|
|
|
|
2017-10-27 12:52:12 +02:00
|
|
|
public Set<DMP> getDmps() {
|
|
|
|
return dmps;
|
2017-10-19 14:31:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-27 12:52:12 +02:00
|
|
|
public void setDmps(Set<DMP> dmps) {
|
|
|
|
this.dmps = dmps;
|
2017-10-19 14:31:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-18 12:20:04 +02:00
|
|
|
public UUID getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(UUID id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getLastloggedin() {
|
|
|
|
return lastloggedin;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
2017-10-18 12:20:04 +02:00
|
|
|
public void setLastloggedin(Date lastloggedin) {
|
|
|
|
this.lastloggedin = lastloggedin;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
2017-09-28 12:32:03 +02:00
|
|
|
public String getEmail() {
|
|
|
|
return email;
|
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
2017-09-28 12:32:03 +02:00
|
|
|
public void setEmail(String email) {
|
|
|
|
this.email = email;
|
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
|
|
|
public Short getAuthorization_level() {
|
|
|
|
return authorization_level;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
|
|
|
public void setAuthorization_level(Short authorization_level) {
|
|
|
|
this.authorization_level = authorization_level;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
|
|
|
public Short getUsertype() {
|
|
|
|
return usertype;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
|
|
|
public void setUsertype(Short usertype) {
|
|
|
|
this.usertype = usertype;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
2017-10-12 17:41:20 +02:00
|
|
|
|
|
|
|
public Boolean getVerified_email() {
|
|
|
|
return verified_email;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
public void setVerified_email(Boolean verified_email) {
|
|
|
|
this.verified_email = verified_email;
|
|
|
|
}
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
|
|
|
|
2017-10-12 17:41:20 +02:00
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getAdditionalinfo() {
|
|
|
|
return additionalinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAdditionalinfo(String additionalinfo) {
|
|
|
|
this.additionalinfo = additionalinfo;
|
|
|
|
}
|
2017-12-15 17:57:41 +01:00
|
|
|
|
|
|
|
public Set<Credential> getCredentials() {
|
|
|
|
return credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCredentials(Set<Credential> credentials) {
|
|
|
|
this.credentials = credentials;
|
|
|
|
}
|
2017-12-17 22:34:24 +01:00
|
|
|
|
2018-01-31 16:39:16 +01:00
|
|
|
public Set<UserRole> getUserRoles() {
|
|
|
|
return userRoles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUserRoles(Set<UserRole> userRoles) {
|
|
|
|
this.userRoles = userRoles;
|
|
|
|
}
|
|
|
|
|
2017-12-17 22:34:24 +01:00
|
|
|
@Override
|
|
|
|
public void update(UserInfo entity) {
|
2018-01-05 08:47:52 +01:00
|
|
|
this.name = entity.getName();
|
|
|
|
this.email = entity.getEmail();
|
|
|
|
this.additionalinfo = entity.getAdditionalinfo();
|
|
|
|
this.lastloggedin = entity.getLastloggedin();
|
2018-02-01 15:04:36 +01:00
|
|
|
this.userRoles = entity.getUserRoles();
|
2017-12-17 22:34:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object[] getKeys() {
|
2018-01-05 16:40:19 +01:00
|
|
|
return new UUID[]{this.id == null ? null : this.id};
|
2017-12-17 22:34:24 +01:00
|
|
|
}
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|