1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.mobility.user.entity; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.ArrayList; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import javax.persistence.CascadeType; |
23 | |
import javax.persistence.Column; |
24 | |
import javax.persistence.Entity; |
25 | |
import javax.persistence.FetchType; |
26 | |
import javax.persistence.GeneratedValue; |
27 | |
import javax.persistence.GenerationType; |
28 | |
import javax.persistence.Id; |
29 | |
import javax.persistence.OneToMany; |
30 | |
import javax.persistence.Table; |
31 | |
import javax.persistence.Version; |
32 | |
|
33 | |
@Entity |
34 | |
@Table(name="KME_USR_PRF_T") |
35 | |
public class UserPreference implements Serializable { |
36 | |
|
37 | |
private static final long serialVersionUID = -9145594618847463951L; |
38 | |
|
39 | |
@Id |
40 | |
@GeneratedValue(strategy = GenerationType.TABLE) |
41 | |
@Column(name="ID") |
42 | |
private Long preferenceId; |
43 | |
|
44 | |
@Column(name="PRNCPL_ID") |
45 | |
private Long principalId; |
46 | |
|
47 | |
@Column(name="PRF_NM") |
48 | |
private String preferenceName; |
49 | |
|
50 | |
@Version |
51 | |
@Column(name="VER_NBR") |
52 | |
protected Long versionNumber; |
53 | |
|
54 | |
@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL}, mappedBy="preferenceId") |
55 | |
private List<UserPreferenceValue> preferenceValues; |
56 | |
|
57 | 0 | public UserPreference() { |
58 | 0 | this.preferenceValues = new ArrayList<UserPreferenceValue>(); |
59 | 0 | } |
60 | |
|
61 | |
public UserPreferenceValue getPreferenceValueById(Long preferenceValueId) { |
62 | 0 | UserPreferenceValue value = null; |
63 | 0 | for (UserPreferenceValue val : this.getPreferenceValues()) { |
64 | 0 | if (val.getPreferenceValueId().equals(preferenceValueId)) { |
65 | 0 | value = val; |
66 | 0 | break; |
67 | |
} |
68 | |
} |
69 | 0 | return value; |
70 | |
} |
71 | |
|
72 | |
public void addPreferenceValue(UserPreferenceValue value) { |
73 | 0 | value.setPreference(this); |
74 | 0 | this.getPreferenceValues().add(value); |
75 | 0 | } |
76 | |
|
77 | |
public void removePreferenceValue(Long preferenceValueId) { |
78 | 0 | this.getPreferenceValues().remove(getPreferenceValueById(preferenceValueId)); |
79 | 0 | } |
80 | |
|
81 | |
public Long getPrincipalId() { |
82 | 0 | return principalId; |
83 | |
} |
84 | |
|
85 | |
public void setPrincipalId(Long principalId) { |
86 | 0 | this.principalId = principalId; |
87 | 0 | } |
88 | |
|
89 | |
public Long getPreferenceId() { |
90 | 0 | return preferenceId; |
91 | |
} |
92 | |
|
93 | |
public void setPreferenceId(Long preferenceId) { |
94 | 0 | this.preferenceId = preferenceId; |
95 | 0 | } |
96 | |
|
97 | |
public String getPreferenceName() { |
98 | 0 | return preferenceName; |
99 | |
} |
100 | |
|
101 | |
public void setPreferenceName(String preferenceName) { |
102 | 0 | this.preferenceName = preferenceName; |
103 | 0 | } |
104 | |
|
105 | |
public List<UserPreferenceValue> getPreferenceValues() { |
106 | 0 | return preferenceValues; |
107 | |
} |
108 | |
|
109 | |
public void setPreferenceValues(List<UserPreferenceValue> preferenceValues) { |
110 | 0 | this.preferenceValues = preferenceValues; |
111 | 0 | } |
112 | |
|
113 | |
public Long getVersionNumber() { |
114 | 0 | return versionNumber; |
115 | |
} |
116 | |
|
117 | |
public void setVersionNumber(Long versionNumber) { |
118 | 0 | this.versionNumber = versionNumber; |
119 | 0 | } |
120 | |
|
121 | |
} |