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.genericattributes.business;
35
36 import fr.paris.lutece.plugins.genericattributes.service.entrytype.IEntryTypeService;
37 import fr.paris.lutece.portal.service.util.AppLogService;
38
39 import java.io.Serializable;
40
41 import java.util.List;
42
43
44
45
46
47
48 public class Entry implements Serializable, Cloneable
49 {
50 private static final long serialVersionUID = 7623715927165156626L;
51
52
53 private int _nIdEntry;
54 private String _strTitle;
55 private String _strCode;
56 private String _strHelpMessage;
57 private String _strComment;
58 private boolean _bMandatory;
59 private boolean _bFieldInLine;
60 private int _nPosition;
61 private int _nIdResource;
62 private String _strResourceType;
63 private EntryType _entryType;
64 private Entry _entryParent;
65 private List<Entry> _listEntryChildren;
66 private List<Field> _listFields;
67 private Field _fieldDepend;
68 private int _nNumberConditionalQuestion;
69 private boolean _bUnique;
70 private GenericAttributeError _error;
71 private String _strCSSClass;
72 private String _strErrorMessage;
73 private boolean _bOnlyDisplayInBack;
74 private boolean _bIndexed;
75
76
77
78
79
80
81 public List<Entry> getChildren( )
82 {
83 return _listEntryChildren;
84 }
85
86
87
88
89
90
91 public String getComment( )
92 {
93 return _strComment;
94 }
95
96
97
98
99
100
101 public EntryType getEntryType( )
102 {
103 return _entryType;
104 }
105
106
107
108
109
110
111 public List<Field> getFields( )
112 {
113 return _listFields;
114 }
115
116
117
118
119
120
121 public String getHelpMessage( )
122 {
123 return _strHelpMessage;
124 }
125
126
127
128
129
130
131 public int getIdEntry( )
132 {
133 return _nIdEntry;
134 }
135
136
137
138
139 public Entry getParent( )
140 {
141 return _entryParent;
142 }
143
144
145
146
147
148
149 public int getPosition( )
150 {
151 return _nPosition;
152 }
153
154
155
156
157
158
159 public String getTitle( )
160 {
161 return _strTitle;
162 }
163
164
165
166
167
168
169 public boolean isFieldInLine( )
170 {
171 return _bFieldInLine;
172 }
173
174
175
176
177
178
179 public boolean isMandatory( )
180 {
181 return _bMandatory;
182 }
183
184
185
186
187
188
189
190 public void setChildren( List<Entry> children )
191 {
192 _listEntryChildren = children;
193 }
194
195
196
197
198
199
200
201 public void setComment( String strComment )
202 {
203 _strComment = strComment;
204 }
205
206
207
208
209
210
211
212 public void setEntryType( EntryType entryType )
213 {
214 _entryType = entryType;
215 }
216
217
218
219
220
221
222
223 public void setFieldInLine( boolean bFieldInLine )
224 {
225 _bFieldInLine = bFieldInLine;
226 }
227
228
229
230
231
232
233
234 public void setFields( List<Field> fields )
235 {
236 _listFields = fields;
237 }
238
239
240
241
242
243
244
245 public void setHelpMessage( String strHelpMessage )
246 {
247 _strHelpMessage = strHelpMessage;
248 }
249
250
251
252
253
254
255
256 public void setIdEntry( int nIdEntry )
257 {
258 _nIdEntry = nIdEntry;
259 }
260
261
262
263
264
265
266
267 public void setMandatory( boolean bMandatory )
268 {
269 _bMandatory = bMandatory;
270 }
271
272
273
274
275
276
277
278 public void setParent( Entry parent )
279 {
280 _entryParent = parent;
281 }
282
283
284
285
286
287
288
289 public void setPosition( int position )
290 {
291 _nPosition = position;
292 }
293
294
295
296
297
298
299
300 public void setTitle( String strTitle )
301 {
302 _strTitle = strTitle;
303 }
304
305
306
307
308
309
310 public int getIdResource( )
311 {
312 return _nIdResource;
313 }
314
315
316
317
318
319
320
321 public void setIdResource( int nIdResource )
322 {
323 this._nIdResource = nIdResource;
324 }
325
326
327
328
329
330
331 public String getResourceType( )
332 {
333 return _strResourceType;
334 }
335
336
337
338
339
340
341
342 public void setResourceType( String strResourceType )
343 {
344 this._strResourceType = strResourceType;
345 }
346
347
348
349
350
351
352 public Field getFieldDepend( )
353 {
354 return _fieldDepend;
355 }
356
357
358
359
360
361
362
363 public void setFieldDepend( Field depend )
364 {
365 _fieldDepend = depend;
366 }
367
368
369
370
371
372
373 public int getNumberConditionalQuestion( )
374 {
375 return _nNumberConditionalQuestion;
376 }
377
378
379
380
381
382
383
384
385 public void setNumberConditionalQuestion( int numberConditionalQuestion )
386 {
387 _nNumberConditionalQuestion = numberConditionalQuestion;
388 }
389
390
391
392
393
394
395
396 public void setUnique( boolean bUnique )
397 {
398 this._bUnique = bUnique;
399 }
400
401
402
403
404
405
406 public boolean isUnique( )
407 {
408 return _bUnique;
409 }
410
411
412
413
414
415
416 public GenericAttributeError getError( )
417 {
418 return _error;
419 }
420
421
422
423
424
425
426
427 public void setError( GenericAttributeError error )
428 {
429 _error = error;
430 }
431
432
433
434
435
436
437
438 public void setCSSClass( String strCSSClass )
439 {
440 this._strCSSClass = strCSSClass;
441 }
442
443
444
445
446
447
448 public String getCSSClass( )
449 {
450 return _strCSSClass;
451 }
452
453
454
455
456
457
458
459 public String getErrorMessage( )
460 {
461 return _strErrorMessage;
462 }
463
464
465
466
467
468
469
470
471 public void setErrorMessage( String strErrorMessage )
472 {
473 this._strErrorMessage = strErrorMessage;
474 }
475
476
477
478
479 public String getCode( )
480 {
481 return _strCode;
482 }
483
484
485
486
487
488 public void setCode( String strCode )
489 {
490 this._strCode = strCode;
491 }
492
493
494
495
496
497
498
499 @Override
500 public Object clone( )
501 {
502 try
503 {
504 return super.clone( );
505 }
506 catch( CloneNotSupportedException e )
507 {
508 AppLogService.error( e.getMessage( ), e );
509
510 return new Entry( );
511 }
512 }
513
514 public boolean isOnlyDisplayInBack( )
515 {
516 return _bOnlyDisplayInBack;
517 }
518
519 public void setOnlyDisplayInBack( boolean onlyDisplayInBack )
520 {
521 this._bOnlyDisplayInBack = onlyDisplayInBack;
522 }
523
524 public boolean isIndexed( )
525 {
526 return _bIndexed;
527 }
528
529 public void setIndexed( boolean bIndexed )
530 {
531 _bIndexed = bIndexed;
532 }
533
534
535
536
537 public boolean isExportable( )
538 {
539 Field fieldExportable = getFieldByCode( IEntryTypeService.FIELD_EXPORTABLE );
540 return fieldExportable != null && Boolean.valueOf( fieldExportable.getValue( ) );
541 }
542
543
544
545
546 public boolean isExportablePdf( )
547 {
548 Field fieldExportablePdf = getFieldByCode( IEntryTypeService.FIELD_EXPORTABLE_PDF );
549 return fieldExportablePdf != null && Boolean.valueOf( fieldExportablePdf.getValue( ) );
550 }
551
552
553
554
555 public boolean isPublished( )
556 {
557 Field fieldPublished = getFieldByCode( IEntryTypeService.FIELD_PUBLISHED );
558 return fieldPublished != null && Boolean.valueOf( fieldPublished.getValue( ) );
559 }
560
561
562
563
564 public boolean isDisabled( )
565 {
566 Field fieldDisabled = getFieldByCode( IEntryTypeService.FIELD_DISABLED );
567 return fieldDisabled != null && Boolean.valueOf( fieldDisabled.getValue( ) );
568 }
569
570
571
572
573
574
575
576 public IMapProvider getMapProvider( )
577 {
578 Field fieldProvider = getFieldByCode( IEntryTypeService.FIELD_PROVIDER );
579 if ( fieldProvider == null )
580 {
581 return null;
582 }
583 return MapProviderManager.getMapProvider( fieldProvider.getValue( ) );
584 }
585
586
587
588
589
590
591
592 public Field getFieldByCode( String strCode )
593 {
594 if ( _listFields == null || _listFields.isEmpty( ) )
595 {
596 return null;
597 }
598
599 return _listFields.stream( ).filter( field -> field.getCode( ).equals( strCode ) ).findFirst( ).orElse( null );
600 }
601 }