Files
Athou_commafeed/src/main/java/com/commafeed/backend/model/User.java

162 lines
3.4 KiB
Java
Raw Normal View History

2013-03-23 16:17:19 +01:00
package com.commafeed.backend.model;
2013-03-20 20:33:42 +01:00
2013-04-18 16:58:56 +02:00
import java.util.Date;
2013-03-28 17:07:37 +01:00
import java.util.Set;
import javax.persistence.Cacheable;
2013-03-28 17:07:37 +01:00
import javax.persistence.CascadeType;
2013-03-20 20:33:42 +01:00
import javax.persistence.Column;
import javax.persistence.Entity;
2013-06-16 18:03:52 +02:00
import javax.persistence.FetchType;
2013-03-28 17:07:37 +01:00
import javax.persistence.OneToMany;
2013-03-20 20:33:42 +01:00
import javax.persistence.Table;
2013-04-18 16:58:56 +02:00
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
2013-03-20 20:33:42 +01:00
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
2013-03-28 17:07:37 +01:00
import com.google.common.collect.Sets;
2013-03-20 20:33:42 +01:00
@Entity
@Table(name = "USERS")
2013-03-21 08:55:53 +01:00
@SuppressWarnings("serial")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
2013-03-23 01:49:39 +01:00
public class User extends AbstractModel {
2013-03-20 20:33:42 +01:00
2013-03-29 11:51:27 +01:00
@Column(length = 32, nullable = false, unique = true)
2013-03-20 20:33:42 +01:00
private String name;
2013-04-06 08:17:25 +02:00
@Column(length = 255, unique = true)
2013-04-05 16:31:42 +02:00
private String email;
2013-03-29 11:51:27 +01:00
@Column(length = 256, nullable = false)
2013-03-20 20:33:42 +01:00
private byte[] password;
@Column(length = 40, unique = true)
private String apiKey;
2013-03-29 11:51:27 +01:00
@Column(length = 8, nullable = false)
2013-03-20 20:33:42 +01:00
private byte[] salt;
2013-03-29 12:59:21 +01:00
@Column(nullable = false)
private boolean disabled;
2013-04-18 16:58:56 +02:00
@Temporal(TemporalType.TIMESTAMP)
private Date lastLogin;
2013-06-16 18:31:21 +02:00
@Temporal(TemporalType.TIMESTAMP)
private Date created;
2013-05-20 21:53:13 +02:00
@Column(length = 40)
private String recoverPasswordToken;
@Temporal(TemporalType.TIMESTAMP)
private Date recoverPasswordTokenDate;
2013-06-16 18:03:52 +02:00
@OneToMany(mappedBy = "user", cascade = { CascadeType.PERSIST,
CascadeType.REMOVE })
2013-03-28 17:07:37 +01:00
private Set<UserRole> roles = Sets.newHashSet();
2013-06-16 18:31:21 +02:00
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
2013-06-16 18:03:52 +02:00
private Set<FeedSubscription> subscriptions;
2013-03-20 20:33:42 +01:00
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte[] getPassword() {
return password;
}
public void setPassword(byte[] password) {
this.password = password;
}
public byte[] getSalt() {
return salt;
}
public void setSalt(byte[] salt) {
this.salt = salt;
}
2013-03-28 17:07:37 +01:00
public Set<UserRole> getRoles() {
return roles;
}
public void setRoles(Set<UserRole> roles) {
this.roles = roles;
}
2013-03-29 12:59:21 +01:00
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
2013-04-06 21:38:18 +02:00
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
2013-04-18 16:58:56 +02:00
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
2013-05-20 21:53:13 +02:00
public String getRecoverPasswordToken() {
return recoverPasswordToken;
}
public void setRecoverPasswordToken(String recoverPasswordToken) {
this.recoverPasswordToken = recoverPasswordToken;
}
public Date getRecoverPasswordTokenDate() {
return recoverPasswordTokenDate;
}
public void setRecoverPasswordTokenDate(Date recoverPasswordTokenDate) {
this.recoverPasswordTokenDate = recoverPasswordTokenDate;
}
2013-06-16 18:03:52 +02:00
public Set<FeedSubscription> getSubscriptions() {
return subscriptions;
}
public void setSubscriptions(Set<FeedSubscription> subscriptions) {
this.subscriptions = subscriptions;
}
2013-06-16 18:31:21 +02:00
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
2013-03-20 20:33:42 +01:00
}