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 package fr.paris.lutece.plugins.participatorybudget.business;
35
36 import java.io.Serializable;
37 import java.text.ParseException;
38 import java.util.Set;
39
40 import javax.validation.ConstraintViolation;
41 import javax.validation.Validator;
42 import javax.validation.constraints.Pattern;
43
44 import org.hibernate.validator.constraints.NotEmpty;
45
46 import fr.paris.lutece.plugins.participatorybudget.service.MyInfosService;
47 import fr.paris.lutece.portal.service.util.AppLogService;
48 import fr.paris.lutece.util.beanvalidation.BeanValidationUtil;
49
50
51
52
53 public class MyInfosForm implements Serializable, Cloneable
54 {
55 private static final long serialVersionUID = 3729142258589861636L;
56 private String _strNickname;
57
58 @NotEmpty( message = "participatorybudget.validation.civility.notEmpty" )
59 private String _strCivility;
60
61 private String _strFirstname;
62
63 private String _strLastname;
64 private String _strPostalCode;
65
66 private String _strAddress;
67 private Double _dLongitude;
68 private Double _dLatitude;
69 @NotEmpty( message = "participatorybudget.validation.birthdate.notEmpty" )
70 @Pattern( regexp = "(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)", message = "participatorybudget.validation.birthdate.pattern" )
71 private String _strBirthdate;
72
73
74 private String _strArrondissement;
75 @NotEmpty( message = "participatorybudget.validation.iliveinparis.notEmpty" )
76 private String _strIliveinparis;
77 private boolean _bIsValid;
78
79 private int _nAge;
80 private String _strSendaccountvalidation;
81 private boolean _bAccountVerified;
82
83 private String _strGeojson;
84
85
86
87
88
89
90 public String getFirstname( )
91 {
92 return _strFirstname;
93 }
94
95
96
97
98
99
100
101 public void setFirstname( String strFirstname )
102 {
103 _strFirstname = strFirstname;
104 }
105
106
107
108
109
110
111 public String getLastname( )
112 {
113 return _strLastname;
114 }
115
116
117
118
119
120
121
122 public void setLastname( String strLastname )
123 {
124 _strLastname = strLastname;
125 }
126
127
128
129
130
131
132 public String getAddress( )
133 {
134 return _strAddress;
135 }
136
137
138
139
140
141
142
143 public void setAddress( String strAddress )
144 {
145 _strAddress = strAddress;
146 }
147
148
149
150
151
152
153 public String getBirthdate( )
154 {
155 return _strBirthdate;
156 }
157
158
159
160
161
162
163
164 public void setBirthdate( String strBirthdate )
165 {
166 _strBirthdate = strBirthdate;
167
168
169 Validator validator = BeanValidationUtil.getValidator( );
170 Set<ConstraintViolation<MyInfosForm>> constraintViolations = validator.validateProperty( this, "_strBirthdate" );
171 if ( constraintViolations.isEmpty( ) )
172 {
173 try
174 {
175 _nAge = MyInfosService.getAge( strBirthdate );
176 }
177 catch( ParseException ex )
178 {
179 _nAge = 0;
180 AppLogService.error( "Error setting age from birthdate" + ex.getMessage( ), ex );
181 }
182 }
183 else
184 {
185 _nAge = 18;
186 }
187 }
188
189
190
191
192
193
194 public int getAge( )
195 {
196 return _nAge;
197 }
198
199
200
201
202
203
204 public String getArrondissement( )
205 {
206 return _strArrondissement;
207 }
208
209
210
211
212
213
214
215 public void setArrondissement( String strArrondissement )
216 {
217 _strArrondissement = strArrondissement;
218 }
219
220
221
222
223
224
225 public String getIliveinparis( )
226 {
227 return _strIliveinparis;
228 }
229
230
231
232
233
234
235
236 public void setIliveinparis( String strIliveinparis )
237 {
238 _strIliveinparis = strIliveinparis;
239 }
240
241
242
243
244
245
246 public boolean getIsValid( )
247 {
248 return _bIsValid;
249 }
250
251
252
253
254
255
256
257 public void setIsValid( boolean bIsValid )
258 {
259 _bIsValid = bIsValid;
260 }
261
262
263
264
265 @Override
266 public MyInfosForm clone( )
267 {
268 try
269 {
270 return (MyInfosForm) super.clone( );
271 }
272 catch( CloneNotSupportedException e )
273 {
274 return null;
275 }
276 }
277
278
279
280
281
282
283
284 public void setSendaccountvalidation( String strSendAccountValidation )
285 {
286
287 _strSendaccountvalidation = strSendAccountValidation;
288
289 }
290
291
292
293
294
295
296 public String getSendaccountvalidation( )
297 {
298 return _strSendaccountvalidation;
299 }
300
301
302
303
304
305 public boolean isAccountVerified( )
306 {
307 return _bAccountVerified;
308 }
309
310
311
312
313
314
315 public void setAccountVerified( boolean _bAccountVerified )
316 {
317 this._bAccountVerified = _bAccountVerified;
318 }
319
320 public String getNickname( )
321 {
322 return _strNickname;
323 }
324
325 public void setNickname( String _strNickname )
326 {
327 this._strNickname = _strNickname;
328 }
329
330
331
332
333
334 public String getCivility( )
335 {
336 return _strCivility;
337 }
338
339 public void setCivility( String strCivility )
340 {
341 this._strCivility = strCivility;
342 }
343
344
345
346
347
348 public String getPostalCode( )
349 {
350 return _strPostalCode;
351 }
352
353
354
355
356
357
358 public void setPostalCode( String _strPostalCode )
359 {
360 this._strPostalCode = _strPostalCode;
361 }
362
363
364
365
366
367 public Double getLongitude( )
368 {
369 return _dLongitude;
370 }
371
372
373
374
375
376
377 public void setLongitude( Double _dLongitude )
378 {
379 this._dLongitude = _dLongitude;
380 }
381
382
383
384
385
386 public Double getLatitude( )
387 {
388 return _dLatitude;
389 }
390
391
392
393
394
395
396 public void setLatitude( Double _dLatitude )
397 {
398 this._dLatitude = _dLatitude;
399 }
400
401 public String getGeojson( )
402 {
403 return _strGeojson;
404 }
405
406 public void setGeojson( String _strGeojson )
407 {
408 this._strGeojson = _strGeojson;
409 }
410
411 }