bstlboard-back/src/main/java/de/bstly/board/model/LocalUser.java

207 lines
3.9 KiB
Java
Raw Normal View History

2021-10-03 17:17:00 +02:00
/**
*
*/
package de.bstly.board.model;
import java.util.List;
import java.util.Map;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.google.common.collect.Maps;
/**
* @author monitoring@bstly.de
*
*/
@Entity
@Table(name = "users")
@JsonInclude(Include.NON_EMPTY)
public class LocalUser {
@Id
@Column(name = "username", nullable = false)
private String username;
@Column(name = "external_id", nullable = true)
private String externalId;
@JsonIgnore
@Column(name = "password_hash", nullable = true)
private String passwordHash;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "users_roles")
private List<String> roles;
@Lob
@Column(name = "about", nullable = true)
private String about;
@Column(name = "email", nullable = true)
private String email;
@Column(name = "locale", nullable = false, columnDefinition = "varchar(255) default 'en'")
private String locale;
@Column(name = "dark_theme", columnDefinition = "boolean default false")
private boolean darkTheme;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "users_settings")
private Map<String, String> settings;
@Transient
private Map<String, Object> metadata;
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the externalId
*/
public String getExternalId() {
return externalId;
}
/**
* @param externalId the externalId to set
*/
public void setExternalId(String externalId) {
this.externalId = externalId;
}
/**
* @return the passwordHash
*/
public String getPasswordHash() {
return passwordHash;
}
/**
* @param passwordHash the passwordHash to set
*/
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
/**
* @return the roles
*/
public List<String> getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(List<String> roles) {
this.roles = roles;
}
/**
* @return the about
*/
public String getAbout() {
return about;
}
/**
* @param about the about to set
*/
public void setAbout(String about) {
this.about = about;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the locale
*/
public String getLocale() {
return locale;
}
/**
* @param locale the locale to set
*/
public void setLocale(String locale) {
this.locale = locale;
}
/**
* @return the darkTheme
*/
public boolean isDarkTheme() {
return darkTheme;
}
/**
* @param darkTheme the darkTheme to set
*/
public void setDarkTheme(boolean darkTheme) {
this.darkTheme = darkTheme;
}
/**
* @return the settings
*/
public Map<String, String> getSettings() {
return settings;
}
/**
* @param settings the settings to set
*/
public void setSettings(Map<String, String> settings) {
this.settings = settings;
}
/**
* @return the metadata
*/
public Map<String, Object> getMetadata() {
if (metadata == null) {
metadata = Maps.newHashMap();
}
return metadata;
}
/**
* @param metadata the metadata to set
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}
}