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 package com.buckosoft.BuckoVidLib.domain;
36
37 import java.util.ArrayList;
38 import java.util.List;
39
40 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42
43 import com.buckosoft.BSAccount.domain.BSAccount;
44 import com.buckosoft.BSAccount.domain.BSAccountUser;
45
46
47
48
49
50
51 public class User extends BSAccountUser {
52 private static final Log log = LogFactory.getLog(User.class);
53 private static final long serialVersionUID = 42;
54
55 private boolean admin = false;
56 private boolean unrestricted = false;
57 private int backgroundFit = 1;
58 private int artShowFit = 1;
59 private int backgroundDelay = 30;
60 private int artShowDelay = 10;
61 private boolean hideRestricted = false;
62 private int findMaxResults = 40;
63
64 private List<UserAttribute> userAttributes;
65
66 public User(BSAccount account) {
67 super(account);
68 }
69
70
71
72
73 public boolean isAdmin() {
74 return admin;
75 }
76
77
78
79
80 public void setAdmin(boolean admin) {
81 this.admin = admin;
82 }
83
84
85
86
87 public boolean isUnrestricted() {
88 return unrestricted;
89 }
90
91
92
93
94 public void setUnrestricted(boolean unrestricted) {
95 this.unrestricted = unrestricted;
96 }
97
98
99
100
101 public boolean isHideRestricted() {
102 return hideRestricted;
103 }
104
105
106
107
108 public void setHideRestricted(boolean hideRestricted) {
109 this.hideRestricted = hideRestricted;
110 }
111
112
113
114
115
116
117
118 public int getBackgroundFit() {
119 return backgroundFit;
120 }
121
122
123
124
125 public void setBackgroundFit(int backgroundFit) {
126 this.backgroundFit = backgroundFit;
127 }
128
129
130
131
132 public int getArtShowFit() {
133 return artShowFit;
134 }
135
136
137
138
139
140 public void setArtShowFit(int artShowFit) {
141 this.artShowFit = artShowFit;
142 }
143
144
145
146
147 public int getBackgroundDelay() {
148 return backgroundDelay;
149 }
150
151
152
153
154 public void setBackgroundDelay(int backgroundDelay) {
155 this.backgroundDelay = backgroundDelay;
156 }
157
158
159
160
161 public int getArtShowDelay() {
162 return artShowDelay;
163 }
164
165
166
167
168 public void setArtShowDelay(int artShowDelay) {
169 this.artShowDelay = artShowDelay;
170 }
171
172
173
174
175 public int getFindMaxResults() {
176 return findMaxResults;
177 }
178
179
180
181
182 public void setFindMaxResults(int findMaxResults) {
183 this.findMaxResults = findMaxResults;
184 }
185
186
187
188
189
190
191 public List<UserAttribute> getUserAttributes() {
192 if (userAttributes == null)
193 userAttributes = new ArrayList<UserAttribute>();
194 setAttribute("admin", "" + admin);
195 setAttribute("unrestricted", "" + unrestricted);
196 setAttribute("hideRestricted", "" + hideRestricted);
197 setAttribute("backgroundFit", "" + backgroundFit);
198 setAttribute("artShowFit", "" + artShowFit);
199 setAttribute("backgroundDelay", "" + backgroundDelay);
200 setAttribute("artShowDelay", "" + artShowDelay);
201 setAttribute("findMaxResults", "" + findMaxResults);
202 return userAttributes;
203 }
204
205
206
207
208 public void setUserAttributes(List<UserAttribute> userAttributes) {
209 this.userAttributes = userAttributes;
210 if (userAttributes == null)
211 return;
212 for (UserAttribute ua : userAttributes) {
213 switch (ua.getKey()) {
214 case "admin":
215 this.admin = Boolean.parseBoolean(ua.getValue());
216 break;
217 case "unrestricted":
218 this.unrestricted = Boolean.parseBoolean(ua.getValue());
219 break;
220 case "hideRestricted":
221 this.hideRestricted = Boolean.parseBoolean(ua.getValue());
222 break;
223 case "backgroundFit":
224 this.backgroundFit = Integer.parseInt(ua.getValue());
225 break;
226 case "artShowFit":
227 this.artShowFit = Integer.parseInt(ua.getValue());
228 break;
229 case "backgroundDelay":
230 this.backgroundDelay = Integer.parseInt(ua.getValue());
231 break;
232 case "artShowDelay":
233 this.artShowDelay = Integer.parseInt(ua.getValue());
234 break;
235 case "findMaxResults":
236 this.findMaxResults = Integer.parseInt(ua.getValue());
237 break;
238 default:
239 log.error("Unknown UserAttribute" + ua.getKey());
240 break;
241 }
242 }
243 }
244
245 private void setAttribute(String key, String value) {
246 for (UserAttribute ua : userAttributes) {
247 if (ua.getKey().equals(key)) {
248 ua.setValue(value);
249 return;
250 }
251 }
252 UserAttribute ua = new UserAttribute();
253 ua.setUserId(this.getUserId());
254 ua.setKey(key);
255 ua.setValue(value);
256 userAttributes.add(ua);
257 }
258 }