User.java
11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "users")
@NamedQueries( {
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
@NamedQuery(name = "User.findByCreated", query = "SELECT u FROM User u WHERE u.created = :created"),
@NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"),
@NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
@NamedQuery(name = "User.findByLastname", query = "SELECT u FROM User u WHERE u.lastname = :lastname"),
@NamedQuery(name = "User.findByFirstnames", query = "SELECT u FROM User u WHERE u.firstnames = :firstnames"),
@NamedQuery(name = "User.findByBirthday", query = "SELECT u FROM User u WHERE u.birthday = :birthday"),
@NamedQuery(name = "User.findByNick", query = "SELECT u FROM User u WHERE u.nick = :nick"),
@NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"),
@NamedQuery(name = "User.findByAddress", query = "SELECT u FROM User u WHERE u.address = :address"),
@NamedQuery(name = "User.findByZip", query = "SELECT u FROM User u WHERE u.zip = :zip"),
@NamedQuery(name = "User.findByPostalCode", query = "SELECT u FROM User u WHERE u.postalCode = :postalCode"),
@NamedQuery(name = "User.findByTown", query = "SELECT u FROM User u WHERE u.town = :town"),
@NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"),
@NamedQuery(name = "User.findByFemale", query = "SELECT u FROM User u WHERE u.female = :female"),
@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User implements ModelInterface {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "users_id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "created", nullable = false, columnDefinition = "timestamptz default now()")
@Temporal(TemporalType.TIMESTAMP)
private Calendar created;
@Column(name = "active", nullable = false, columnDefinition = "boolean default true")
private boolean active;
@Column(name = "password")
private String password;
@Column(name = "lastname")
private String lastname;
@Column(name = "firstnames")
private String firstnames;
@Column(name = "birthday")
@Temporal(TemporalType.TIMESTAMP)
private Calendar birthday;
@Column(name = "nick")
private String nick;
@Column(name = "email")
private String email;
@Column(name = "address")
private String address;
@Column(name = "zip")
private String zip;
@Column(name = "postal_code")
private String postalCode;
@Column(name = "town")
private String town;
@Column(name = "phone")
private String phone;
@Column(name = "female")
private Boolean female;
@Column(name = "login")
private String login;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "voter")
private List<Vote> votes;
@ManyToMany(cascade = CascadeType.ALL, mappedBy = "users")
private List<Role> roles;
@OneToMany(mappedBy = "user")
private List<LogEntry> logEntryList;
@OneToMany(mappedBy = "user")
private List<UserImage> userImageList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "users")
private List<CompoEntryParticipant> compoEntryParticipantList;
@OneToMany(mappedBy = "creator")
private List<CompoEntry> compoEntryList;
@OneToMany(mappedBy = "creator")
private List<PlaceGroup> placeGroupList;
@OneToMany(mappedBy = "user")
private List<GroupMembership> groupMemberships;
/**
* The places this user has registered into.
*/
@OneToMany(mappedBy = "currentUser")
private List<Place> currentPlaces;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<PrintedCard> printedCards;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<AccountEvent> accountEvents;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<DiscountInstance> discountInstances;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<Bill> bills;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "seller")
private List<AccountEvent> soldItems;
@Version
@Column(nullable = false)
private int jpaVersionField;
public User() {
}
public User(Integer usersId) {
this.id = usersId;
}
public List<Vote> getVotes() {
return votes;
}
public void setVotes(List<Vote> votes) {
this.votes = votes;
}
public User(Integer usersId, Calendar created, boolean active, String lastname,
String firstnames) {
this.id = usersId;
this.created = created;
this.active = active;
this.lastname = lastname;
this.firstnames = firstnames;
}
public Calendar getCreated() {
return created;
}
public void setCreated(Calendar created) {
this.created = created;
}
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getFirstnames() {
return firstnames;
}
public void setFirstnames(String firstnames) {
this.firstnames = firstnames;
}
public Calendar getBirthday() {
return birthday;
}
public void setBirthday(Calendar birthday) {
this.birthday = birthday;
}
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getTown() {
return town;
}
public void setTown(String town) {
this.town = town;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Boolean getFemale() {
return female;
}
public void setFemale(Boolean female) {
this.female = female;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public List<Vote> getVoteList() {
return votes;
}
public void setVoteList(List<Vote> voteList) {
this.votes = voteList;
}
public List<LogEntry> getLogEntryList() {
return logEntryList;
}
public void setLogEntryList(List<LogEntry> logEntryList) {
this.logEntryList = logEntryList;
}
public List<UserImage> getUserImageList() {
return userImageList;
}
public void setUserImageList(List<UserImage> userImageList) {
this.userImageList = userImageList;
}
public List<CompoEntryParticipant> getCompoEntryParticipantList() {
return compoEntryParticipantList;
}
public void setCompoEntryParticipantList(
List<CompoEntryParticipant> compoEntryParticipantList) {
this.compoEntryParticipantList = compoEntryParticipantList;
}
public List<CompoEntry> getCompoEntryList() {
return compoEntryList;
}
public void setCompoEntryList(List<CompoEntry> compoEntryList) {
this.compoEntryList = compoEntryList;
}
public List<PlaceGroup> getPlaceGroupList() {
return placeGroupList;
}
public void setPlaceGroupList(List<PlaceGroup> placeGroupList) {
this.placeGroupList = placeGroupList;
}
public List<GroupMembership> getGroupMemberships() {
return groupMemberships;
}
public void setGroupMemberships(List<GroupMembership> groupMembershipList) {
this.groupMemberships = groupMembershipList;
}
public List<Place> getCurrentPlaces() {
return currentPlaces;
}
public void setCurrentPlaces(List<Place> placeList) {
this.currentPlaces = placeList;
}
public List<PrintedCard> getPrintedCards() {
return printedCards;
}
public void setPrintedCards(List<PrintedCard> printedCardList) {
this.printedCards = printedCardList;
}
public List<AccountEvent> getAccountEvents() {
return accountEvents;
}
public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEvents = accountEventList;
}
public List<DiscountInstance> getDiscountInstances() {
return discountInstances;
}
public void setDiscountInstances(List<DiscountInstance> discountInstanceList) {
this.discountInstances = discountInstanceList;
}
public List<Bill> getBills() {
return bills;
}
public void setBills(List<Bill> billList) {
this.bills = billList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof User)) {
return false;
}
User other = (User) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.User[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
public List<Role> getRoles() {
return roles;
}
public void setSoldItems(List<AccountEvent> accountEvents) {
this.soldItems = accountEvents;
}
public List<AccountEvent> getSoldItems() {
return soldItems;
}
}