1 /*
2 * Copyright 2012-2025 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.app.pager;
17
18 import java.io.Serializable;
19 import java.util.List;
20
21 import org.codelibs.fess.util.ComponentUtil;
22
23 /**
24 * Pager class for web authentication configurations.
25 * Provides pagination functionality and search criteria for web authentication listings.
26 */
27 public class WebAuthPager implements Serializable {
28
29 /**
30 * Default constructor.
31 */
32 public WebAuthPager() {
33 // Default constructor
34 }
35
36 private static final long serialVersionUID = 1L;
37
38 /**
39 * Default page size for pagination.
40 */
41 public static final int DEFAULT_PAGE_SIZE = 20;
42
43 /**
44 * Default current page number.
45 */
46 public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
47
48 /**
49 * Total number of records.
50 */
51 private int allRecordCount;
52
53 /**
54 * Total number of pages.
55 */
56 private int allPageCount;
57
58 /**
59 * Flag indicating if a previous page exists.
60 */
61 private boolean existPrePage;
62
63 /**
64 * Flag indicating if a next page exists.
65 */
66 private boolean existNextPage;
67
68 /**
69 * List of page numbers for pagination.
70 */
71 private List<Integer> pageNumberList;
72
73 /**
74 * Number of records per page.
75 */
76 private int pageSize;
77
78 /**
79 * Current page number.
80 */
81 private int currentPageNumber;
82
83 /**
84 * Search criteria: authentication ID.
85 */
86 public String id;
87
88 /**
89 * Search criteria: port number.
90 */
91 public String port;
92
93 /**
94 * Search criteria: username.
95 */
96 public String username;
97
98 /**
99 * Search criteria: web configuration ID.
100 */
101 public String webConfigId;
102
103 /**
104 * Search criteria: creator user.
105 */
106 public String createdBy;
107
108 /**
109 * Search criteria: creation time.
110 */
111 public String createdTime;
112
113 /**
114 * Search criteria: version number.
115 */
116 public String versionNo;
117
118 /**
119 * Clears all pager data and search criteria.
120 */
121 public void clear() {
122 allRecordCount = 0;
123 allPageCount = 0;
124 existPrePage = false;
125 existNextPage = false;
126 pageSize = getDefaultPageSize();
127 currentPageNumber = getDefaultCurrentPageNumber();
128
129 id = null;
130 port = null;
131 username = null;
132 webConfigId = null;
133 createdBy = null;
134 createdTime = null;
135 versionNo = null;
136
137 }
138
139 /**
140 * Gets the default current page number.
141 *
142 * @return The default current page number
143 */
144 protected int getDefaultCurrentPageNumber() {
145 return DEFAULT_CURRENT_PAGE_NUMBER;
146 }
147
148 /**
149 * Gets the total number of records.
150 *
151 * @return The total record count
152 */
153 public int getAllRecordCount() {
154 return allRecordCount;
155 }
156
157 /**
158 * Sets the total number of records.
159 *
160 * @param allRecordCount The total record count
161 */
162 public void setAllRecordCount(final int allRecordCount) {
163 this.allRecordCount = allRecordCount;
164 }
165
166 /**
167 * Gets the total number of pages.
168 *
169 * @return The total page count
170 */
171 public int getAllPageCount() {
172 return allPageCount;
173 }
174
175 /**
176 * Sets the total number of pages.
177 *
178 * @param allPageCount The total page count
179 */
180 public void setAllPageCount(final int allPageCount) {
181 this.allPageCount = allPageCount;
182 }
183
184 /**
185 * Checks if a previous page exists.
186 *
187 * @return True if a previous page exists, false otherwise
188 */
189 public boolean isExistPrePage() {
190 return existPrePage;
191 }
192
193 /**
194 * Sets whether a previous page exists.
195 *
196 * @param existPrePage True if a previous page exists
197 */
198 public void setExistPrePage(final boolean existPrePage) {
199 this.existPrePage = existPrePage;
200 }
201
202 /**
203 * Checks if a next page exists.
204 *
205 * @return True if a next page exists, false otherwise
206 */
207 public boolean isExistNextPage() {
208 return existNextPage;
209 }
210
211 /**
212 * Sets whether a next page exists.
213 *
214 * @param existNextPage True if a next page exists
215 */
216 public void setExistNextPage(final boolean existNextPage) {
217 this.existNextPage = existNextPage;
218 }
219
220 /**
221 * Gets the page size.
222 *
223 * @return The number of records per page
224 */
225 public int getPageSize() {
226 if (pageSize <= 0) {
227 pageSize = getDefaultPageSize();
228 }
229 return pageSize;
230 }
231
232 /**
233 * Sets the page size.
234 *
235 * @param pageSize The number of records per page
236 */
237 public void setPageSize(final int pageSize) {
238 this.pageSize = pageSize;
239 }
240
241 /**
242 * Gets the current page number.
243 *
244 * @return The current page number
245 */
246 public int getCurrentPageNumber() {
247 if (currentPageNumber <= 0) {
248 currentPageNumber = getDefaultCurrentPageNumber();
249 }
250 return currentPageNumber;
251 }
252
253 /**
254 * Sets the current page number.
255 *
256 * @param currentPageNumber The current page number
257 */
258 public void setCurrentPageNumber(final int currentPageNumber) {
259 this.currentPageNumber = currentPageNumber;
260 }
261
262 /**
263 * Gets the list of page numbers for pagination.
264 *
265 * @return The list of page numbers
266 */
267 public List<Integer> getPageNumberList() {
268 return pageNumberList;
269 }
270
271 /**
272 * Sets the list of page numbers for pagination.
273 *
274 * @param pageNumberList The list of page numbers
275 */
276 public void setPageNumberList(final List<Integer> pageNumberList) {
277 this.pageNumberList = pageNumberList;
278 }
279
280 /**
281 * Gets the default page size from configuration.
282 *
283 * @return The default page size
284 */
285 protected int getDefaultPageSize() {
286 return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
287 }
288
289 }