/** * */ 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 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 settings; @Transient private Map 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 getRoles() { return roles; } /** * @param roles the roles to set */ public void setRoles(List 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 getSettings() { return settings; } /** * @param settings the settings to set */ public void setSettings(Map settings) { this.settings = settings; } /** * @return the metadata */ public Map getMetadata() { if (metadata == null) { metadata = Maps.newHashMap(); } return metadata; } /** * @param metadata the metadata to set */ public void setMetadata(Map metadata) { this.metadata = metadata; } }