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.directory.business;
35
36 import fr.paris.lutece.plugins.directory.business.attribute.DirectoryAttribute;
37 import fr.paris.lutece.plugins.directory.business.rss.DirectoryResourceRssConfigRemovalListener;
38 import fr.paris.lutece.plugins.directory.service.DirectoryXslRemovalListenerService;
39 import fr.paris.lutece.plugins.directory.service.FileImgService;
40 import fr.paris.lutece.plugins.directory.utils.DirectoryUtils;
41 import fr.paris.lutece.portal.service.plugin.Plugin;
42 import fr.paris.lutece.portal.service.rbac.RBACResource;
43 import fr.paris.lutece.portal.service.regularexpression.RegularExpressionRemovalListenerService;
44 import fr.paris.lutece.portal.service.workflow.WorkflowRemovalListenerService;
45 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
46 import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService;
47 import fr.paris.lutece.util.date.DateUtil;
48 import fr.paris.lutece.util.xml.XmlUtil;
49
50 import java.sql.Timestamp;
51
52 import java.util.HashMap;
53 import java.util.List;
54 import java.util.Locale;
55
56
57
58
59
60
61 public class Directory implements AdminWorkgroupResource, RBACResource
62 {
63 public static final String ROLE_NONE = "none";
64 public static final String RESOURCE_TYPE = "DIRECTORY_DIRECTORY_TYPE";
65 public static final int STATE_ENABLE = 1;
66 public static final int STATE_DISABLE = 0;
67 private static final String TAG_LIST_ENTRY = "list-entry";
68 private static final String TAG_DIRECTORY = "directory";
69 private static final String TAG_TITLE = "title";
70 private static final String TAG_LIST_RECORD = "list-record";
71 private static final String TAG_CREATION_DATE = "creation-date";
72 private static final String ATTRIBUTE_ID = "id";
73 private static DirectoryWorkgroupRemovalListener _listenerWorkgroup;
74 private static DirectoryRegularExpressionRemovalListener _listenerRegularExpression;
75 private static DirectoryXslRemovalListener _listenerXslRemovalListener;
76 private static DirectoryWorkflowRemovalListener _listenerWorkflowRemovalListener;
77 private static EntryTypeDirectoryRemovalListener _listenerEntryDirectoryRemovalListener;
78 private static DirectoryResourceRssConfigRemovalListener _listenerDirectoryResourceRssConfigRemovalListener;
79 private int _nIdDirectory;
80 private String _strTitle;
81 private String _strFrontOfficeTitle;
82 private String _strDescription;
83 private String _strUnavailabilityMessage;
84 private String _strWorkgroupKey;
85 private String _strRoleKey;
86 private Timestamp _tDateCreation;
87 private boolean _bIsEnabled;
88 private int _nIdResultListTemplate = DirectoryUtils.CONSTANT_ID_NULL;
89 private int _nIdResultRecordTemplate = DirectoryUtils.CONSTANT_ID_NULL;
90 private int _nIdFormSearchTemplate = DirectoryUtils.CONSTANT_ID_NULL;
91 private int _nNumberRecordPerPage;
92 private List<DirectoryAction> _listActions;
93 private int _nIdWorkflow = DirectoryUtils.CONSTANT_ID_NULL;
94 private int _nIdWorkflowStateToRemove = DirectoryUtils.CONSTANT_ID_NULL;
95 private boolean _bDisplaySearchState;
96 private boolean _bDisplaySearchComplementaryState;
97 private String _strSortEntryId;
98 private boolean _bAscSort;
99 private String _strSortEntryIdFront;
100 private boolean _bAscSortFront;
101 private boolean _bRecordActivated;
102 private boolean _bIsIndexed;
103 @DirectoryAttribute( "searchOperatorOr" )
104 private boolean _bSearchOperatorOr;
105
106
107 @DirectoryAttribute( "dateShownInResultList" )
108 private boolean _bDateShownInResultList;
109 @DirectoryAttribute( "dateShownInResultRecord" )
110 private boolean _bDateShownInResultRecord;
111 @DirectoryAttribute( "dateShownInHistory" )
112 private boolean _bDateShownInHistory;
113 @DirectoryAttribute( "dateShownInSearch" )
114 private boolean _bDateShownInSearch;
115 @DirectoryAttribute( "dateShownInAdvancedSearch" )
116 private boolean _bDateShownInAdvancedSearch;
117 @DirectoryAttribute( "dateShownInMultiSearch" )
118 private boolean _bDateShownInMultiSearch;
119 @DirectoryAttribute( "dateShownInExport" )
120 private boolean _bDateShownInExport;
121
122
123 @DirectoryAttribute( "dateModificationShownInResultList" )
124 private boolean _bDateModificationShownInResultList;
125 @DirectoryAttribute( "dateModificationShownInResultRecord" )
126 private boolean _bDateModificationShownInResultRecord;
127 @DirectoryAttribute( "dateModificationShownInHistory" )
128 private boolean _bDateModificationShownInHistory;
129 @DirectoryAttribute( "dateModificationShownInSearch" )
130 private boolean _bDateModificationShownInSearch;
131 @DirectoryAttribute( "dateModificationShownInAdvancedSearch" )
132 private boolean _bDateModificationShownInAdvancedSearch;
133 @DirectoryAttribute( "dateModificationShownInMultiSearch" )
134 private boolean _bDateModificationShownInMultiSearch;
135 @DirectoryAttribute( "dateModificationShownInExport" )
136 private boolean _bDateModificationShownInExport;
137
138
139
140
141 public static void init( )
142 {
143
144 if ( _listenerWorkgroup == null )
145 {
146 _listenerWorkgroup = new DirectoryWorkgroupRemovalListener( );
147 WorkgroupRemovalListenerService.getService( ).registerListener( _listenerWorkgroup );
148 }
149
150 if ( _listenerRegularExpression == null )
151 {
152 _listenerRegularExpression = new DirectoryRegularExpressionRemovalListener( );
153 RegularExpressionRemovalListenerService.getService( ).registerListener( _listenerRegularExpression );
154 }
155
156 if ( _listenerXslRemovalListener == null )
157 {
158 _listenerXslRemovalListener = new DirectoryXslRemovalListener( );
159 DirectoryXslRemovalListenerService.getService( ).registerListener( _listenerXslRemovalListener );
160 }
161
162 if ( _listenerWorkflowRemovalListener == null )
163 {
164 _listenerWorkflowRemovalListener = new DirectoryWorkflowRemovalListener( );
165 WorkflowRemovalListenerService.getService( ).registerListener( _listenerWorkflowRemovalListener );
166 }
167
168 if ( _listenerEntryDirectoryRemovalListener == null )
169 {
170 _listenerEntryDirectoryRemovalListener = new EntryTypeDirectoryRemovalListener( );
171 EntryRemovalListenerService.getService( ).registerListener( _listenerEntryDirectoryRemovalListener );
172 }
173
174 if ( _listenerDirectoryResourceRssConfigRemovalListener == null )
175 {
176 _listenerDirectoryResourceRssConfigRemovalListener = new DirectoryResourceRssConfigRemovalListener( );
177 EntryRemovalListenerService.getService( ).registerListener( _listenerDirectoryResourceRssConfigRemovalListener );
178 }
179
180
181 FileImgService.getInstance( ).register( );
182 }
183
184
185
186
187
188 public String getTitle( )
189 {
190 return _strTitle;
191 }
192
193
194
195
196
197
198
199 public void setTitle( String strTitle )
200 {
201 _strTitle = strTitle;
202 }
203
204
205
206
207
208 public String getFrontOfficeTitle( )
209 {
210 return _strFrontOfficeTitle;
211 }
212
213
214
215
216
217
218
219 public void setFrontOfficeTitle( String strFrontOfficeTitle )
220 {
221 _strFrontOfficeTitle = strFrontOfficeTitle;
222 }
223
224
225
226
227
228 public String getDescription( )
229 {
230 return _strDescription;
231 }
232
233
234
235
236 public boolean isDisplaySearchState( )
237 {
238 return _bDisplaySearchState;
239 }
240
241
242
243
244
245 public void setDisplaySearchState( boolean displayState )
246 {
247 _bDisplaySearchState = displayState;
248 }
249
250
251
252
253 public boolean isDisplayComplementarySearchState( )
254 {
255 return _bDisplaySearchComplementaryState;
256 }
257
258
259
260
261
262 public void setDisplayComplementarySearchState( boolean displayState )
263 {
264 _bDisplaySearchComplementaryState = displayState;
265 }
266
267
268
269
270
271
272
273 public void setDescription( String description )
274 {
275 this._strDescription = description;
276 }
277
278
279
280
281
282 public String getUnavailabilityMessage( )
283 {
284 return _strUnavailabilityMessage;
285 }
286
287
288
289
290
291
292
293 public void setUnavailabilityMessage( String unavailabilityMessage )
294 {
295 _strUnavailabilityMessage = unavailabilityMessage;
296 }
297
298
299
300
301
302
303 @Override
304 public String getWorkgroup( )
305 {
306 return _strWorkgroupKey;
307 }
308
309
310
311
312
313
314
315 public void setWorkgroup( String workGroup )
316 {
317 _strWorkgroupKey = workGroup;
318 }
319
320
321
322
323
324 public int getIdDirectory( )
325 {
326 return _nIdDirectory;
327 }
328
329
330
331
332
333
334
335 public void setIdDirectory( int idDirectory )
336 {
337 _nIdDirectory = idDirectory;
338 }
339
340
341
342
343
344 public boolean isEnabled( )
345 {
346 return _bIsEnabled;
347 }
348
349
350
351
352
353
354
355 public void setEnabled( boolean enable )
356 {
357 _bIsEnabled = enable;
358 }
359
360
361
362
363
364 public Timestamp getDateCreation( )
365 {
366 return _tDateCreation;
367 }
368
369
370
371
372
373
374
375 public void setDateCreation( Timestamp dateCreation )
376 {
377 _tDateCreation = dateCreation;
378 }
379
380
381
382
383
384
385 @Override
386 public String getResourceTypeCode( )
387 {
388 return RESOURCE_TYPE;
389 }
390
391
392
393
394
395
396 @Override
397 public String getResourceId( )
398 {
399 return "" + _nIdDirectory;
400 }
401
402
403
404
405
406 public List<DirectoryAction> getActions( )
407 {
408 return _listActions;
409 }
410
411
412
413
414
415
416
417 public void setActions( List<DirectoryAction> directoryActions )
418 {
419 _listActions = directoryActions;
420 }
421
422
423
424
425
426
427
428 public String getRoleKey( )
429 {
430 return _strRoleKey;
431 }
432
433
434
435
436
437
438
439
440 public void setRoleKey( String strRole )
441 {
442 _strRoleKey = strRole;
443 }
444
445
446
447
448
449
450 public int getIdResultListTemplate( )
451 {
452 return _nIdResultListTemplate;
453 }
454
455
456
457
458
459
460
461 public void setIdResultListTemplate( int idResultListTemplate )
462 {
463 _nIdResultListTemplate = idResultListTemplate;
464 }
465
466
467
468
469
470
471 public int getIdResultRecordTemplate( )
472 {
473 return _nIdResultRecordTemplate;
474 }
475
476
477
478
479
480
481
482 public void setIdResultRecordTemplate( int idResultRecordTemplate )
483 {
484 _nIdResultRecordTemplate = idResultRecordTemplate;
485 }
486
487
488
489
490
491
492 public int getIdFormSearchTemplate( )
493 {
494 return _nIdFormSearchTemplate;
495 }
496
497
498
499
500
501 public int getNumberRecordPerPage( )
502 {
503 return _nNumberRecordPerPage;
504 }
505
506
507
508
509
510
511
512 public void setNumberRecordPerPage( int numberRecordPerPage )
513 {
514 _nNumberRecordPerPage = numberRecordPerPage;
515 }
516
517
518
519
520
521
522
523 public void setIdFormSearchTemplate( int idFormSearchTemplate )
524 {
525 _nIdFormSearchTemplate = idFormSearchTemplate;
526 }
527
528
529
530
531
532 public int getIdWorkflow( )
533 {
534 return _nIdWorkflow;
535 }
536
537
538
539
540
541
542
543 public void setIdWorkflow( int nIdWorkflow )
544 {
545 _nIdWorkflow = nIdWorkflow;
546 }
547
548
549
550
551
552
553 public int getIdWorkflowStateToRemove( )
554 {
555 return _nIdWorkflowStateToRemove;
556 }
557
558
559
560
561
562
563
564 public void setIdWorkflowStateToRemove( int nIdWorkflowStateToRemove )
565 {
566 this._nIdWorkflowStateToRemove = nIdWorkflowStateToRemove;
567 }
568
569
570
571
572
573
574 public boolean isDateShownInResultList( )
575 {
576 return _bDateShownInResultList;
577 }
578
579
580
581
582
583
584
585 public void setDateShownInResultList( boolean bDateShownInResultList )
586 {
587 _bDateShownInResultList = bDateShownInResultList;
588 }
589
590
591
592
593
594
595 public boolean isDateShownInResultRecord( )
596 {
597 return _bDateShownInResultRecord;
598 }
599
600
601
602
603
604
605
606 public void setDateShownInResultRecord( boolean bDateShownInResultRecord )
607 {
608 _bDateShownInResultRecord = bDateShownInResultRecord;
609 }
610
611
612
613
614
615
616 public boolean isDateShownInHistory( )
617 {
618 return _bDateShownInHistory;
619 }
620
621
622
623
624
625
626
627 public void setDateShownInHistory( boolean bDateShownInHistory )
628 {
629 _bDateShownInHistory = bDateShownInHistory;
630 }
631
632
633
634
635
636
637 public boolean isDateShownInSearch( )
638 {
639 return _bDateShownInSearch;
640 }
641
642
643
644
645
646
647
648 public void setDateShownInSearch( boolean bDateShownInSearch )
649 {
650 _bDateShownInSearch = bDateShownInSearch;
651 }
652
653
654
655
656
657
658 public boolean isDateShownInAdvancedSearch( )
659 {
660 return _bDateShownInAdvancedSearch;
661 }
662
663
664
665
666
667
668
669 public void setDateShownInAdvancedSearch( boolean bDateShownInAdvancedSearch )
670 {
671 _bDateShownInAdvancedSearch = bDateShownInAdvancedSearch;
672 }
673
674
675
676
677
678
679 public boolean isDateShownInMultiSearch( )
680 {
681 return _bDateShownInMultiSearch;
682 }
683
684
685
686
687
688
689
690 public void setDateShownInMultiSearch( boolean bDateShownInMultiSearch )
691 {
692 _bDateShownInMultiSearch = bDateShownInMultiSearch;
693 }
694
695
696
697
698
699
700 public boolean isDateShownInExport( )
701 {
702 return _bDateShownInExport;
703 }
704
705
706
707
708
709
710
711 public void setDateShownInExport( boolean bDateShownInExport )
712 {
713 _bDateShownInExport = bDateShownInExport;
714 }
715
716
717
718
719
720
721 public boolean isDateModificationShownInResultList( )
722 {
723 return _bDateModificationShownInResultList;
724 }
725
726
727
728
729
730
731
732 public void setDateModificationShownInResultList( boolean bDateModificationShownInResultList )
733 {
734 _bDateModificationShownInResultList = bDateModificationShownInResultList;
735 }
736
737
738
739
740
741
742 public boolean isDateModificationShownInResultRecord( )
743 {
744 return _bDateModificationShownInResultRecord;
745 }
746
747
748
749
750
751
752
753 public void setDateModificationShownInResultRecord( boolean bDateModificationShownInResultRecord )
754 {
755 _bDateModificationShownInResultRecord = bDateModificationShownInResultRecord;
756 }
757
758
759
760
761
762
763 public boolean isDateModificationShownInHistory( )
764 {
765 return _bDateModificationShownInHistory;
766 }
767
768
769
770
771
772
773
774 public void setDateModificationShownInHistory( boolean bDateModificationShownInHistory )
775 {
776 _bDateModificationShownInHistory = bDateModificationShownInHistory;
777 }
778
779
780
781
782
783
784 public boolean isDateModificationShownInSearch( )
785 {
786 return _bDateModificationShownInSearch;
787 }
788
789
790
791
792
793
794
795 public void setDateModificationShownInSearch( boolean bDateModificationShownInSearch )
796 {
797 _bDateModificationShownInSearch = bDateModificationShownInSearch;
798 }
799
800
801
802
803
804
805 public boolean isDateModificationShownInAdvancedSearch( )
806 {
807 return _bDateModificationShownInAdvancedSearch;
808 }
809
810
811
812
813
814
815
816 public void setDateModificationShownInAdvancedSearch( boolean bDateModificationShownInAdvancedSearch )
817 {
818 _bDateModificationShownInAdvancedSearch = bDateModificationShownInAdvancedSearch;
819 }
820
821
822
823
824
825
826 public boolean isDateModificationShownInMultiSearch( )
827 {
828 return _bDateModificationShownInMultiSearch;
829 }
830
831
832
833
834
835
836
837 public void setDateModificationShownInMultiSearch( boolean bDateModificationShownInMultiSearch )
838 {
839 _bDateModificationShownInMultiSearch = bDateModificationShownInMultiSearch;
840 }
841
842
843
844
845
846
847 public boolean isDateModificationShownInExport( )
848 {
849 return _bDateModificationShownInExport;
850 }
851
852
853
854
855
856
857
858 public void setDateModificationShownInExport( boolean bDateModificationShownInExport )
859 {
860 _bDateModificationShownInExport = bDateModificationShownInExport;
861 }
862
863
864
865
866
867
868 public boolean isAscendingSort( )
869 {
870 return _bAscSort;
871 }
872
873
874
875
876
877
878
879 public void setAscendingSort( boolean bAscendingSort )
880 {
881 _bAscSort = bAscendingSort;
882 }
883
884
885
886
887
888
889 public String getIdSortEntry( )
890 {
891 return _strSortEntryId;
892 }
893
894
895
896
897
898
899
900 public void setIdSortEntry( String strIdSortEntry )
901 {
902 _strSortEntryId = strIdSortEntry;
903 }
904
905
906
907
908
909
910 public boolean isAscendingSortFront( )
911 {
912 return _bAscSortFront;
913 }
914
915
916
917
918
919
920
921 public void setAscendingSortFront( boolean bAscendingSort )
922 {
923 _bAscSortFront = bAscendingSort;
924 }
925
926
927
928
929
930
931 public String getIdSortEntryFront( )
932 {
933 return _strSortEntryIdFront;
934 }
935
936
937
938
939
940
941
942 public void setIdSortEntryFront( String strIdSortEntry )
943 {
944 _strSortEntryIdFront = strIdSortEntry;
945 }
946
947
948
949
950
951
952 public boolean isRecordActivated( )
953 {
954 return _bRecordActivated;
955 }
956
957
958
959
960
961
962
963 public void setRecordActivated( boolean bRecordActivated )
964 {
965 _bRecordActivated = bRecordActivated;
966 }
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981 public StringBuffer getXml( Plugin plugin, Locale locale, StringBuffer strListRecord, StringBuffer strListEntry )
982 {
983 StringBuffer strXml = new StringBuffer( );
984 HashMap<String, Object> model = new HashMap<String, Object>( );
985 model.put( ATTRIBUTE_ID, String.valueOf( getIdDirectory( ) ) );
986 XmlUtil.beginElement( strXml, TAG_DIRECTORY, model );
987 XmlUtil.addElementHtml( strXml, TAG_TITLE, DirectoryUtils.substituteSpecialCaractersForExport( getTitle( ) ) );
988 XmlUtil.addElement( strXml, TAG_CREATION_DATE, DateUtil.getDateString( getDateCreation( ), locale ) );
989 XmlUtil.beginElement( strXml, TAG_LIST_ENTRY );
990 strXml.append( strListEntry );
991 XmlUtil.endElement( strXml, TAG_LIST_ENTRY );
992 XmlUtil.beginElement( strXml, TAG_LIST_RECORD );
993 strXml.append( strListRecord );
994 XmlUtil.endElement( strXml, TAG_LIST_RECORD );
995 XmlUtil.endElement( strXml, TAG_DIRECTORY );
996
997 return strXml;
998 }
999
1000
1001
1002
1003
1004
1005
1006 public void setIndexed( boolean bIsIndexed )
1007 {
1008 _bIsIndexed = bIsIndexed;
1009 }
1010
1011
1012
1013
1014
1015
1016 public boolean isIndexed( )
1017 {
1018 return _bIsIndexed;
1019 }
1020
1021
1022
1023
1024
1025 public boolean isSearchOperatorOr( )
1026 {
1027 return _bSearchOperatorOr;
1028 }
1029
1030
1031
1032
1033
1034
1035 public void setSearchOperatorOr( boolean bSearchOperatorOr )
1036 {
1037 _bSearchOperatorOr = bSearchOperatorOr;
1038 }
1039 }