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.crm.business.demand;
35
36 import com.fasterxml.jackson.annotation.JsonIgnore;
37 import com.fasterxml.jackson.annotation.JsonProperty;
38 import java.util.Date;
39 import java.util.Locale;
40
41 import javax.servlet.http.HttpServletRequest;
42
43 import org.apache.commons.lang3.StringUtils;
44
45 import fr.paris.lutece.plugins.crm.util.CrmUtils;
46 import fr.paris.lutece.plugins.crm.util.TargetEnum;
47 import fr.paris.lutece.plugins.crm.util.constants.CRMConstants;
48 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
49 import fr.paris.lutece.util.date.DateUtil;
50 import fr.paris.lutece.util.xml.XmlUtil;
51
52
53
54
55
56
57 public class DemandType implements AdminWorkgroupResource
58 {
59 public static final String ROLE_NONE = "none";
60
61 @JsonProperty( "id_demand_type" )
62 private int _nIdDemandType;
63 @JsonProperty( "label" )
64 private String _strLabel;
65 @JsonProperty( "url" )
66 private String _strUrlResource;
67 @JsonIgnore
68 private String _strUrlInfo;
69 @JsonIgnore
70 private String _strUrlContact;
71 @JsonIgnore
72 private int _nOrder;
73 @JsonIgnore
74 private int _nIdCategory;
75 @JsonIgnore
76 private Date _dateBegin;
77 @JsonIgnore
78 private Date _dateEnd;
79 @JsonIgnore
80 private String _strWorkgroupKey;
81 @JsonIgnore
82 private String _strRoleKey;
83 @JsonIgnore
84 private TargetEnum _target;
85 @JsonIgnore
86 private String _strUrlDelete;
87 @JsonIgnore
88 private boolean _bIncludeIdCrmUser;
89 @JsonIgnore
90 private boolean _bNeedAuthentication;
91 @JsonIgnore
92 private boolean _bNeedValidation;
93
94
95
96
97 public DemandType( )
98 {
99 _nIdDemandType = 0;
100 _strLabel = StringUtils.EMPTY;
101 _strUrlResource = StringUtils.EMPTY;
102 _strUrlInfo = StringUtils.EMPTY;
103 _strUrlContact = StringUtils.EMPTY;
104 _nOrder = 1;
105 _nIdCategory = -1;
106 _strWorkgroupKey = StringUtils.EMPTY;
107 _strRoleKey = StringUtils.EMPTY;
108 _target = TargetEnum.SELF;
109 _strUrlDelete = StringUtils.EMPTY;
110 _bIncludeIdCrmUser = false;
111 _bNeedAuthentication = false;
112 _bNeedValidation = false;
113
114 }
115
116
117
118
119
120
121 @JsonProperty( "id_demand_type" )
122 public int getIdDemandType( )
123 {
124 return _nIdDemandType;
125 }
126
127
128
129
130
131
132
133 @JsonProperty( "id_demand_type" )
134 public void setIdDemandType( int nIdDemandType )
135 {
136 _nIdDemandType = nIdDemandType;
137 }
138
139
140
141
142
143
144 @JsonProperty( "label" )
145 public String getLabel( )
146 {
147 return _strLabel;
148 }
149
150
151
152
153
154
155
156 public void setLabel( String strLabel )
157 {
158 _strLabel = strLabel;
159 }
160
161
162
163
164
165
166
167 @JsonProperty( "url" )
168 public String getUrlResource( )
169 {
170 return _strUrlResource;
171 }
172
173
174
175
176
177
178
179 public void setUrlResource( String strUrlResource )
180 {
181 _strUrlResource = strUrlResource;
182 }
183
184
185
186
187
188
189 @JsonIgnore
190 public String getUrlInfo( )
191 {
192 return _strUrlInfo;
193 }
194
195
196
197
198
199
200
201 public void setUrlInfo( String strUrlInfo )
202 {
203 _strUrlInfo = strUrlInfo;
204 }
205
206
207
208
209
210
211 @JsonIgnore
212 public String getUrlContact( )
213 {
214 return _strUrlContact;
215 }
216
217
218
219
220
221
222
223 @JsonIgnore
224 public void setUrlContact( String strUrlContact )
225 {
226 _strUrlContact = strUrlContact;
227 }
228
229
230
231
232
233
234 @JsonIgnore
235 public int getOrder( )
236 {
237 return _nOrder;
238 }
239
240
241
242
243
244
245
246 public void setOrder( int nOrder )
247 {
248 _nOrder = nOrder;
249 }
250
251
252
253
254
255
256 @JsonIgnore
257 public int getIdCategory( )
258 {
259 return _nIdCategory;
260 }
261
262
263
264
265
266
267
268 public void setIdCategory( int nIdCategory )
269 {
270 _nIdCategory = nIdCategory;
271 }
272
273
274
275
276
277
278 @JsonIgnore
279 public Date getDateBegin( )
280 {
281 return _dateBegin;
282 }
283
284
285
286
287
288
289
290 public void setDateBegin( Date dateBegin )
291 {
292 _dateBegin = dateBegin;
293 }
294
295
296
297
298
299
300 @JsonIgnore
301 public Date getDateEnd( )
302 {
303 return _dateEnd;
304 }
305
306
307
308
309
310
311
312 public void setDateEnd( Date dateEnd )
313 {
314 _dateEnd = dateEnd;
315 }
316
317
318
319
320
321
322
323 public void setWorkgroup( String strWorkgroupKey )
324 {
325 _strWorkgroupKey = strWorkgroupKey;
326 }
327
328
329
330
331
332
333 @JsonIgnore
334 public String getWorkgroup( )
335 {
336 return _strWorkgroupKey;
337 }
338
339
340
341
342
343
344
345 public void setRole( String strRoleKey )
346 {
347 _strRoleKey = strRoleKey;
348 }
349
350
351
352
353
354
355 @JsonIgnore
356 public String getRole( )
357 {
358 return _strRoleKey;
359 }
360
361
362
363
364
365
366 @JsonIgnore
367 public boolean isOpen( )
368 {
369 boolean bIsDateBeginCorrect = false;
370 boolean bIsDateEndCorrect = false;
371 Date dateToday = new Date( );
372
373 if ( _dateBegin != null )
374 {
375 if ( _dateBegin.before( dateToday ) )
376 {
377 bIsDateBeginCorrect = true;
378 }
379 }
380 else
381 {
382 bIsDateBeginCorrect = true;
383 }
384
385 if ( _dateEnd != null )
386 {
387 if ( _dateEnd.after( dateToday ) )
388 {
389 bIsDateEndCorrect = true;
390 }
391 }
392 else
393 {
394 bIsDateEndCorrect = true;
395 }
396
397 return bIsDateBeginCorrect && bIsDateEndCorrect;
398 }
399
400
401
402
403
404
405 @JsonIgnore
406 public boolean isClosed( )
407 {
408 return !isOpen( );
409 }
410
411
412
413
414
415
416
417 public void setTarget( TargetEnum target )
418 {
419 _target = target;
420 }
421
422
423
424
425
426
427 @JsonIgnore
428 public TargetEnum getTarget( )
429 {
430 return _target;
431 }
432
433
434
435
436
437
438 @JsonIgnore
439 public String getUrlDelete( )
440 {
441 return _strUrlDelete;
442 }
443
444
445
446
447
448
449
450 public void setUrlDelete( String strUrlDelete )
451 {
452 _strUrlDelete = strUrlDelete;
453 }
454
455
456
457
458
459
460
461
462
463
464 @JsonIgnore
465 public String getXml( HttpServletRequest request, Locale locale )
466 {
467 StringBuffer strXml = new StringBuffer( );
468 XmlUtil.beginElement( strXml, CRMConstants.TAG_DEMAND_TYPE );
469 XmlUtil.addElement( strXml, CRMConstants.TAG_DEMAND_TYPE_ID, _nIdDemandType );
470 XmlUtil.addElement( strXml, CRMConstants.TAG_DEMAND_TYPE_CATEGORY, _nIdCategory );
471 XmlUtil.addElement( strXml, CRMConstants.TAG_DEMAND_TYPE_ORDER, _nOrder );
472 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_LABEL, _strLabel );
473 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_URL_RESOURCE, _strUrlResource );
474 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_URL_INFO, _strUrlInfo );
475 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_URL_CONTACT, _strUrlContact );
476 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_TARGET, _target.toString( ) );
477 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_URL_DELETE, _strUrlDelete );
478 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_DATE_BEGIN, _dateBegin != null ? DateUtil.getDateString( _dateBegin, locale ) : null );
479 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_DATE_END, _dateEnd != null ? DateUtil.getDateString( _dateEnd, locale ) : null );
480 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_NEED_AUTHENTICATION, new Boolean( _bNeedAuthentication ).toString( ) );
481 CrmUtils.addElementHtml( strXml, CRMConstants.TAG_DEMAND_TYPE_NEED_VALIDATION, new Boolean( _bNeedValidation ).toString( ) );
482 XmlUtil.endElement( strXml, CRMConstants.TAG_DEMAND_TYPE );
483 return strXml.toString( );
484 }
485
486
487
488
489
490 @JsonIgnore
491 public boolean isIncludeIdCrmUser( )
492 {
493 return _bIncludeIdCrmUser;
494 }
495
496
497
498
499
500
501 public void setIncludeIdCrmUser( boolean _bUseIdCrmUser )
502 {
503 this._bIncludeIdCrmUser = _bUseIdCrmUser;
504 }
505
506
507
508
509
510 @JsonIgnore
511 public boolean isNeedAuthentication( )
512 {
513 return _bNeedAuthentication;
514 }
515
516
517
518
519
520
521 public void setNeedAuthentication( boolean _bNeedAuthentication )
522 {
523 this._bNeedAuthentication = _bNeedAuthentication;
524 }
525
526
527
528
529
530 @JsonIgnore
531 public boolean isNeedValidation( )
532 {
533 return _bNeedValidation;
534 }
535
536
537
538
539
540
541 public void setNeedValidation( boolean _bNeedValidation )
542 {
543 this._bNeedValidation = _bNeedValidation;
544 }
545
546 }