2018-03-21 11:57:56 +01:00
|
|
|
package eu.eudat.data.entities;
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2018-10-02 16:33:58 +02:00
|
|
|
import eu.eudat.data.converters.DateToUTCConverter;
|
2019-05-21 17:17:41 +02:00
|
|
|
import eu.eudat.data.entities.helpers.EntityBinder;
|
2018-03-21 11:16:32 +01:00
|
|
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
2018-02-16 11:34:02 +01:00
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
|
import org.hibernate.annotations.Type;
|
|
|
|
|
|
|
|
import javax.persistence.*;
|
2018-10-02 16:33:58 +02:00
|
|
|
import java.util.*;
|
2017-12-15 17:57:41 +01:00
|
|
|
|
2017-09-28 12:32:03 +02:00
|
|
|
|
|
|
|
@Entity
|
2018-02-16 11:34:02 +01:00
|
|
|
@Table(name = "\"UserInfo\"")
|
2018-02-09 16:54:41 +01:00
|
|
|
@NamedEntityGraphs({
|
2019-05-21 17:17:41 +02:00
|
|
|
@NamedEntityGraph(
|
|
|
|
name = "userInfo",
|
2020-12-02 13:19:43 +01:00
|
|
|
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials"), @NamedAttributeNode("additionalinfo")}),
|
2018-02-09 16:54:41 +01:00
|
|
|
})
|
2018-02-20 08:50:17 +01:00
|
|
|
public class UserInfo implements DataEntity<UserInfo, UUID> {
|
2017-09-28 12:32:03 +02:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Id
|
|
|
|
@GeneratedValue
|
|
|
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
|
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
|
|
private UUID id;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "email", nullable = false)
|
|
|
|
private String email = null;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "authorization_level", nullable = false)
|
|
|
|
private Short authorization_level; //0 admin, 1 user
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "usertype", nullable = false)
|
|
|
|
private Short usertype; // 0 internal, 1 external
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2020-10-27 17:06:58 +01:00
|
|
|
@Column(name = "userstatus", nullable = false)
|
|
|
|
private Short userStatus; // 0 active, 1 inactive
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "verified_email", nullable = true)
|
|
|
|
private Boolean verified_email = null;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "name", nullable = true)
|
|
|
|
private String name = null;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "created", nullable = false)
|
|
|
|
@Convert(converter = DateToUTCConverter.class)
|
|
|
|
private Date created = null;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Column(name = "lastloggedin", nullable = true)
|
|
|
|
@Convert(converter = DateToUTCConverter.class)
|
|
|
|
private Date lastloggedin = null;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
|
|
|
@Column(name = "additionalinfo", nullable = true)
|
|
|
|
private String additionalinfo;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
|
|
@JoinTable(name = "\"UserDMP\"",
|
|
|
|
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
|
|
|
|
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
|
|
|
|
)
|
|
|
|
private Set<DMP> dmps;
|
2017-12-15 17:57:41 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
|
|
|
|
private Set<Credential> credentials = new HashSet<>();
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
|
|
|
|
private Set<UserRole> userRoles = new HashSet<>();
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2020-02-11 17:27:54 +01:00
|
|
|
@OneToMany(mappedBy = "lockedBy", fetch = FetchType.LAZY)
|
|
|
|
private Set<Lock> locks = new HashSet<>();
|
|
|
|
|
2020-02-14 17:40:34 +01:00
|
|
|
@OneToMany(mappedBy = "userId", fetch = FetchType.LAZY)
|
|
|
|
private Set<Notification> notifications = new HashSet<>();
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Set<DMP> getDmps() {
|
|
|
|
return dmps;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setDmps(Set<DMP> dmps) {
|
|
|
|
this.dmps = dmps;
|
|
|
|
}
|
2018-01-31 16:39:16 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public UUID getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setId(UUID id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Date getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Date getLastloggedin() {
|
|
|
|
return lastloggedin;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setLastloggedin(Date lastloggedin) {
|
|
|
|
this.lastloggedin = lastloggedin;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public String getEmail() {
|
|
|
|
return email;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setEmail(String email) {
|
|
|
|
this.email = email;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Short getAuthorization_level() {
|
|
|
|
return authorization_level;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setAuthorization_level(Short authorization_level) {
|
|
|
|
this.authorization_level = authorization_level;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Short getUsertype() {
|
|
|
|
return usertype;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setUsertype(Short usertype) {
|
|
|
|
this.usertype = usertype;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public Boolean getVerified_email() {
|
|
|
|
return verified_email;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setVerified_email(Boolean verified_email) {
|
|
|
|
this.verified_email = verified_email;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
public String getAdditionalinfo() {
|
|
|
|
return additionalinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAdditionalinfo(String additionalinfo) {
|
|
|
|
this.additionalinfo = additionalinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Credential> getCredentials() {
|
|
|
|
return credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCredentials(Set<Credential> credentials) {
|
|
|
|
this.credentials = credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<UserRole> getUserRoles() {
|
|
|
|
return userRoles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUserRoles(Set<UserRole> userRoles) {
|
|
|
|
this.userRoles = userRoles;
|
|
|
|
}
|
|
|
|
|
2020-02-11 17:27:54 +01:00
|
|
|
public Set<Lock> getLocks() {
|
|
|
|
return locks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLocks(Set<Lock> locks) {
|
|
|
|
this.locks = locks;
|
|
|
|
}
|
|
|
|
|
2020-02-14 17:40:34 +01:00
|
|
|
public Set<Notification> getNotifications() {
|
|
|
|
return notifications;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNotifications(Set<Notification> notifications) {
|
|
|
|
this.notifications = notifications;
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:06:58 +01:00
|
|
|
public Short getUserStatus() {
|
|
|
|
return userStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUserStatus(Short userStatus) {
|
|
|
|
this.userStatus = userStatus;
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:17:41 +02:00
|
|
|
@Override
|
|
|
|
public void update(UserInfo entity) {
|
|
|
|
this.name = entity.getName();
|
|
|
|
this.email = entity.getEmail();
|
|
|
|
this.additionalinfo = entity.getAdditionalinfo();
|
|
|
|
this.lastloggedin = entity.getLastloggedin();
|
|
|
|
this.userRoles = entity.getUserRoles();
|
2020-10-27 17:06:58 +01:00
|
|
|
this.userStatus = entity.getUserStatus();
|
2019-05-21 17:17:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public UUID getKeys() {
|
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public UserInfo buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
|
|
String currentBase = base.isEmpty() ? "" : base + ".";
|
|
|
|
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
|
|
|
return this;
|
|
|
|
}
|
2017-09-28 12:32:03 +02:00
|
|
|
}
|