2022-05-17 16:47:28 +02:00
|
|
|
package eu.eudat.migration.entities;
|
|
|
|
|
2022-05-30 10:11:28 +02:00
|
|
|
import eu.eudat.data.entities.UserInfo;
|
|
|
|
import eu.eudat.data.entities.UserToken;
|
|
|
|
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
2022-05-17 16:47:28 +02:00
|
|
|
import org.hibernate.annotations.LazyCollection;
|
|
|
|
import org.hibernate.annotations.LazyCollectionOption;
|
|
|
|
|
|
|
|
import javax.persistence.*;
|
2022-05-30 10:11:28 +02:00
|
|
|
import java.sql.Timestamp;
|
|
|
|
import java.time.LocalDateTime;
|
2022-05-17 16:47:28 +02:00
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
2022-05-30 10:11:28 +02:00
|
|
|
import java.util.UUID;
|
2022-05-17 16:47:28 +02:00
|
|
|
|
|
|
|
@Entity
|
|
|
|
@Table(name = "users")
|
|
|
|
public class User {
|
|
|
|
|
|
|
|
@Id
|
|
|
|
private Long id;
|
|
|
|
private String firstname;
|
|
|
|
private String surname;
|
|
|
|
private String email;
|
|
|
|
@Column(name = "created_at")
|
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
private Date createdAt;
|
|
|
|
@Column(name = "updated_at")
|
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
private Date updatedAt;
|
|
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
|
|
@JoinColumn(name = "org_id")
|
|
|
|
private Organization organization;
|
|
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
|
|
@JoinColumn(name = "language_id")
|
|
|
|
private Language language;
|
|
|
|
@ManyToMany(cascade = CascadeType.ALL)
|
|
|
|
@JoinTable(name = "users_perms",
|
|
|
|
joinColumns = {@JoinColumn(name = "user_id")},
|
|
|
|
inverseJoinColumns = {@JoinColumn(name = "perm_id")}
|
|
|
|
)
|
|
|
|
@LazyCollection(LazyCollectionOption.FALSE)
|
|
|
|
private Set<Perm> perms = new HashSet<>();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "User{" +
|
|
|
|
"id=" + id +
|
|
|
|
", firstname='" + firstname + '\'' +
|
|
|
|
", surname='" + surname + '\'' +
|
|
|
|
", email='" + email + '\'' +
|
|
|
|
", createdAt=" + createdAt +
|
|
|
|
", updatedAt=" + updatedAt +
|
|
|
|
", organization=" + organization +
|
|
|
|
", language=" + language +
|
|
|
|
", perms=" + perms +
|
|
|
|
'}';
|
|
|
|
}
|
|
|
|
|
|
|
|
public Long getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(Long id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getFirstname() {
|
|
|
|
return firstname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFirstname(String firstname) {
|
|
|
|
this.firstname = firstname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSurname() {
|
|
|
|
return surname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSurname(String surname) {
|
|
|
|
this.surname = surname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getEmail() {
|
|
|
|
return email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEmail(String email) {
|
|
|
|
this.email = email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getCreatedAt() {
|
|
|
|
return createdAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreatedAt(Date createdAt) {
|
|
|
|
this.createdAt = createdAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getUpdatedAt() {
|
|
|
|
return updatedAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUpdatedAt(Date updatedAt) {
|
|
|
|
this.updatedAt = updatedAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Organization getOrganization() {
|
|
|
|
return organization;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrganization(Organization organization) {
|
|
|
|
this.organization = organization;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Language getLanguage() {
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLanguage(Language language) {
|
|
|
|
this.language = language;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Perm> getPerms() {
|
|
|
|
return perms;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPerms(Set<Perm> perms) {
|
|
|
|
this.perms = perms;
|
|
|
|
}
|
2022-05-30 10:11:28 +02:00
|
|
|
|
|
|
|
public UserInfo buildUserInfo() {
|
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
|
userInfo.setEmail(getEmail());
|
|
|
|
userInfo.setName(getFirstname() + " " + getSurname());
|
|
|
|
userInfo.setUsertype((short) 0);
|
|
|
|
userInfo.setUserStatus((short) 0);
|
|
|
|
userInfo.setAuthorization_level((short) 1);
|
2022-05-31 19:43:27 +02:00
|
|
|
userInfo.setVerified_email(true);
|
2022-05-30 10:11:28 +02:00
|
|
|
userInfo.setCreated(getCreatedAt());
|
|
|
|
return userInfo;
|
|
|
|
}
|
2022-05-17 16:47:28 +02:00
|
|
|
}
|