| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.directdemocracyportal.democracy.model.application; |
| 6 | |
|
| 7 | |
import java.util.Date; |
| 8 | |
|
| 9 | |
import javax.persistence.CascadeType; |
| 10 | |
import javax.persistence.Entity; |
| 11 | |
import javax.persistence.GeneratedValue; |
| 12 | |
import javax.persistence.GenerationType; |
| 13 | |
import javax.persistence.Id; |
| 14 | |
import javax.persistence.JoinColumn; |
| 15 | |
import javax.persistence.OneToOne; |
| 16 | |
import javax.persistence.Temporal; |
| 17 | |
import javax.persistence.TemporalType; |
| 18 | |
|
| 19 | |
import org.directdemocracyportal.democracy.model.core.BaseEntity; |
| 20 | |
import org.hibernate.annotations.Cache; |
| 21 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
@Entity |
| 27 | |
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) |
| 28 | |
public class UserSession extends BaseEntity |
| 29 | |
{ |
| 30 | |
|
| 31 | |
|
| 32 | |
private static final long serialVersionUID = -2831588433419103923L; |
| 33 | |
|
| 34 | |
|
| 35 | |
private Long id; |
| 36 | |
|
| 37 | |
|
| 38 | |
private User user; |
| 39 | |
|
| 40 | |
|
| 41 | |
private String sessionId; |
| 42 | |
|
| 43 | |
|
| 44 | |
private Date createdAt; |
| 45 | |
|
| 46 | |
|
| 47 | |
private Date endedAt; |
| 48 | |
|
| 49 | |
|
| 50 | |
private boolean active; |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | 1 | public UserSession() { |
| 56 | 1 | } |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | 1 | public UserSession(User user, String sessionId, Date createdAt) { |
| 66 | 1 | this.user = user; |
| 67 | 1 | this.sessionId = sessionId; |
| 68 | 1 | this.createdAt = createdAt; |
| 69 | 1 | this.active = true; |
| 70 | 1 | this.endedAt = null; |
| 71 | 1 | } |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
@Override |
| 79 | |
@Id |
| 80 | |
@GeneratedValue(strategy = GenerationType.AUTO) |
| 81 | |
public Long getId() { |
| 82 | 1 | return this.id; |
| 83 | |
} |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public void setId(Long id) { |
| 91 | 0 | this.id = id; |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
public boolean isActive() { |
| 100 | 0 | return active; |
| 101 | |
} |
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
public void setActive(boolean active) { |
| 109 | 1 | this.active = active; |
| 110 | 1 | } |
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
@Temporal(TemporalType.DATE) |
| 118 | |
public Date getCreatedAt() { |
| 119 | 0 | return createdAt; |
| 120 | |
} |
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
public void setCreatedAt(Date createdAt) { |
| 128 | 0 | this.createdAt = createdAt; |
| 129 | 0 | } |
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
@Temporal(TemporalType.DATE) |
| 137 | |
public Date getEndedAt() { |
| 138 | 0 | return endedAt; |
| 139 | |
} |
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
public void setEndedAt(Date endedAt) { |
| 147 | 1 | this.endedAt = endedAt; |
| 148 | 1 | } |
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
public String getSessionId() { |
| 156 | 0 | return sessionId; |
| 157 | |
} |
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
public void setSessionId(String sessionId) { |
| 165 | 0 | this.sessionId = sessionId; |
| 166 | 0 | } |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
@OneToOne(cascade = CascadeType.ALL) |
| 174 | |
@JoinColumn |
| 175 | |
public User getUser() { |
| 176 | 4 | return user; |
| 177 | |
} |
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
public void setUser(User user) { |
| 185 | 0 | this.user = user; |
| 186 | 0 | } |
| 187 | |
} |