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.unittree.web.action;
35
36 import fr.paris.lutece.portal.service.util.AppPropertiesService;
37 import fr.paris.lutece.portal.web.constants.Parameters;
38
39 import org.apache.commons.lang3.StringUtils;
40
41 import java.io.Serializable;
42
43 import javax.servlet.http.HttpServletRequest;
44
45
46
47
48
49
50 public abstract class DefaultUnitSearchFields implements IUnitSearchFields, Serializable
51 {
52 private static final long serialVersionUID = 7400229591290783994L;
53
54
55 private static final String PROPERTY_ITEM_PER_PAGE = "unittree.itemsPerPage";
56
57
58 private static final String PARAMETER_SESSION = "session";
59 private static final String PARAMETER_IS_IN_DEPTH_SEARCH = "isInDepthSearch";
60
61
62 private int _nItemsPerPage;
63 private int _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_ITEM_PER_PAGE, 50 );
64 private String _strCurrentPageIndex;
65 private boolean _bIsInDepthSearch;
66 private String _strSortedAttributeName;
67 private boolean _bIsAscSort;
68
69
70
71
72 @Override
73 public String getCurrentPageIndex( )
74 {
75 return _strCurrentPageIndex;
76 }
77
78
79
80
81 @Override
82 public int getDefaultItemsPerPage( )
83 {
84 return _nDefaultItemsPerPage;
85 }
86
87
88
89
90 @Override
91 public void setCurrentPageIndex( String strCurrentPageIndex )
92 {
93 _strCurrentPageIndex = strCurrentPageIndex;
94 }
95
96
97
98
99 @Override
100 public void setDefaultItemsPerPage( int nDefaultItemsPerPage )
101 {
102 _nDefaultItemsPerPage = nDefaultItemsPerPage;
103 }
104
105
106
107
108 @Override
109 public int getItemsPerPage( )
110 {
111 return _nItemsPerPage;
112 }
113
114
115
116
117 @Override
118 public void setItemsPerPage( int nItemsPerPage )
119 {
120 _nItemsPerPage = nItemsPerPage;
121 }
122
123
124
125
126 @Override
127 public void setInDepthSearch( HttpServletRequest request )
128 {
129 if ( StringUtils.isBlank( request.getParameter( PARAMETER_SESSION ) ) )
130 {
131 _bIsInDepthSearch = StringUtils.isNotBlank( request.getParameter( PARAMETER_IS_IN_DEPTH_SEARCH ) );
132 }
133 }
134
135
136
137
138 @Override
139 public boolean isInDepthSearch( )
140 {
141 return _bIsInDepthSearch;
142 }
143
144
145
146
147 @Override
148 public String getSortedAttributeName( )
149 {
150 return _strSortedAttributeName;
151 }
152
153
154
155
156 @Override
157 public void setSortedAttributeName( HttpServletRequest request )
158 {
159 if ( StringUtils.isNotBlank( request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME ) ) )
160 {
161 _strSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME );
162 }
163 }
164
165
166
167
168 @Override
169 public boolean isAscSort( )
170 {
171 return _bIsAscSort;
172 }
173
174
175
176
177 @Override
178 public void setAscSort( HttpServletRequest request )
179 {
180 if ( StringUtils.isNotBlank( request.getParameter( Parameters.SORTED_ASC ) ) )
181 {
182 _bIsAscSort = Boolean.parseBoolean( request.getParameter( Parameters.SORTED_ASC ) );
183 }
184 }
185 }