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.modules.multiview.web.record.filter.display.impl;
35
36 import java.util.LinkedHashMap;
37 import java.util.Locale;
38 import java.util.Map;
39
40 import javax.servlet.http.HttpServletRequest;
41
42 import fr.paris.lutece.plugins.directory.modules.multiview.util.DirectoryMultiviewConstants;
43 import fr.paris.lutece.plugins.directory.modules.multiview.util.RecordRecordDateCreationNameConstants;
44 import fr.paris.lutece.portal.service.i18n.I18nService;
45 import fr.paris.lutece.util.ReferenceList;
46
47
48
49
50 public class RecordFilterDisplayRecordDateCreation extends AbstractRecordFilterDisplay
51 {
52
53 private static final int LAST_DAY_VALUE = 1;
54 private static final int LAST_WEEK_VALUE = 7;
55 private static final int LAST_MONTH_VALUE = 31;
56 private static final String PARAMETER_SEARCH_OPEN_SINCE = "multiview_search_open_since";
57
58
59 private static final String LAST_DAY_MESSAGE_KEY = "module.directory.multiview.records_list.search_since_last_day";
60 private static final String LAST_WEEK_MESSAGE_KEY = "module.directory.multiview.records_list.search_since_last_week";
61 private static final String LAST_MONTH_MESSAGE_KEY = "module.directory.multiview.records_list.search_since_last_month";
62
63
64
65
66 @Override
67 public String getParameterName( )
68 {
69 return PARAMETER_SEARCH_OPEN_SINCE;
70 }
71
72
73
74
75 @Override
76 public Map<String, Object> getFilterDisplayMapValues( HttpServletRequest request )
77 {
78 String strPeriodCreationDate = request.getParameter( PARAMETER_SEARCH_OPEN_SINCE );
79 setValue( strPeriodCreationDate );
80
81 Map<String, Object> mapFilterNameValues = new LinkedHashMap<>( );
82 mapFilterNameValues.put( RecordRecordDateCreationNameConstants.FILTER_RECORD_DATE_CREATION, strPeriodCreationDate );
83
84 return mapFilterNameValues;
85 }
86
87
88
89
90 @Override
91 public void buildTemplate( HttpServletRequest request )
92 {
93 manageFilterTemplate( request, createReferenceList( request.getLocale( ) ), PARAMETER_SEARCH_OPEN_SINCE );
94 }
95
96
97
98
99
100
101
102
103 private ReferenceList createReferenceList( Locale locale )
104 {
105 ReferenceList referenceList = new ReferenceList( );
106
107
108 String strDefaultDayItemName = getRecordFilterDisplayLabel( );
109 referenceList.addItem( DirectoryMultiviewConstants.DEFAULT_FILTER_VALUE, strDefaultDayItemName );
110
111
112 String strLastDayItemName = I18nService.getLocalizedString( LAST_DAY_MESSAGE_KEY, locale );
113 referenceList.addItem( LAST_DAY_VALUE, strLastDayItemName );
114
115
116 String strLastWeekItemName = I18nService.getLocalizedString( LAST_WEEK_MESSAGE_KEY, locale );
117 referenceList.addItem( LAST_WEEK_VALUE, strLastWeekItemName );
118
119
120 String strLastMonthItemName = I18nService.getLocalizedString( LAST_MONTH_MESSAGE_KEY, locale );
121 referenceList.addItem( LAST_MONTH_VALUE, strLastMonthItemName );
122
123 return referenceList;
124 }
125 }