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 file crawler configuration management.
25 * This class provides pagination functionality for file configuration listings
26 * and contains form fields for file crawler configuration parameters.
27 */
28 public class FileConfigPager implements Serializable {
29
30 /** Serial version UID for serialization */
31 private static final long serialVersionUID = 1L;
32
33 /**
34 * Default constructor for file configuration pager.
35 * Creates a new instance with default values.
36 */
37 public FileConfigPager() {
38 // Default constructor
39 }
40
41 /** Default page size for pagination */
42 public static final int DEFAULT_PAGE_SIZE = 20;
43
44 /** Default current page number for pagination */
45 public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
46
47 /** Total number of records across all pages */
48 private int allRecordCount;
49
50 /** Total number of pages */
51 private int allPageCount;
52
53 /** Flag indicating if a previous page exists */
54 private boolean existPrePage;
55
56 /** Flag indicating if a next page exists */
57 private boolean existNextPage;
58
59 /** List of page numbers for pagination display */
60 private List<Integer> pageNumberList;
61
62 /** Number of records per page */
63 private int pageSize;
64
65 /** Current page number */
66 private int currentPageNumber;
67
68 /** Configuration ID */
69 public String id;
70
71 /** Configuration name */
72 public String name;
73
74 /** File system paths to crawl */
75 public String paths;
76
77 /** Number of threads for crawling */
78 public String numOfThread;
79
80 /** Interval time between crawling operations */
81 public String intervalTime;
82
83 /** Boost value for search ranking */
84 public String boost;
85
86 /** Availability status of the configuration */
87 public String available;
88
89 /** Sort order for the configuration */
90 public String sortOrder;
91
92 /** User who created the configuration */
93 public String createdBy;
94
95 /** Creation timestamp of the configuration */
96 public String createdTime;
97
98 /** Version number of the configuration */
99 public String versionNo;
100
101 /** Description of the configuration */
102 public String description;
103
104 /**
105 * Clears all pagination and configuration data, resetting to default values.
106 */
107 public void clear() {
108 allRecordCount = 0;
109 allPageCount = 0;
110 existPrePage = false;
111 existNextPage = false;
112 pageSize = getDefaultPageSize();
113 currentPageNumber = getDefaultCurrentPageNumber();
114
115 id = null;
116 name = null;
117 paths = null;
118 numOfThread = null;
119 intervalTime = null;
120 boost = null;
121 available = null;
122 sortOrder = null;
123 createdBy = null;
124 createdTime = null;
125 versionNo = null;
126 description = null;
127
128 }
129
130 /**
131 * Gets the default current page number.
132 *
133 * @return the default current page number
134 */
135 protected int getDefaultCurrentPageNumber() {
136 return DEFAULT_CURRENT_PAGE_NUMBER;
137 }
138
139 /**
140 * Gets the total number of records across all pages.
141 *
142 * @return the total record count
143 */
144 public int getAllRecordCount() {
145 return allRecordCount;
146 }
147
148 /**
149 * Sets the total number of records across all pages.
150 *
151 * @param allRecordCount the total record count
152 */
153 public void setAllRecordCount(final int allRecordCount) {
154 this.allRecordCount = allRecordCount;
155 }
156
157 /**
158 * Gets the total number of pages.
159 *
160 * @return the total page count
161 */
162 public int getAllPageCount() {
163 return allPageCount;
164 }
165
166 /**
167 * Sets the total number of pages.
168 *
169 * @param allPageCount the total page count
170 */
171 public void setAllPageCount(final int allPageCount) {
172 this.allPageCount = allPageCount;
173 }
174
175 /**
176 * Checks if a previous page exists.
177 *
178 * @return true if a previous page exists, false otherwise
179 */
180 public boolean isExistPrePage() {
181 return existPrePage;
182 }
183
184 /**
185 * Sets the flag indicating if a previous page exists.
186 *
187 * @param existPrePage true if a previous page exists, false otherwise
188 */
189 public void setExistPrePage(final boolean existPrePage) {
190 this.existPrePage = existPrePage;
191 }
192
193 /**
194 * Checks if a next page exists.
195 *
196 * @return true if a next page exists, false otherwise
197 */
198 public boolean isExistNextPage() {
199 return existNextPage;
200 }
201
202 /**
203 * Sets the flag indicating if a next page exists.
204 *
205 * @param existNextPage true if a next page exists, false otherwise
206 */
207 public void setExistNextPage(final boolean existNextPage) {
208 this.existNextPage = existNextPage;
209 }
210
211 /**
212 * Gets the number of records per page.
213 * If page size is not set or is invalid, returns the default page size.
214 *
215 * @return the page size
216 */
217 public int getPageSize() {
218 if (pageSize <= 0) {
219 pageSize = getDefaultPageSize();
220 }
221 return pageSize;
222 }
223
224 /**
225 * Sets the number of records per page.
226 *
227 * @param pageSize the page size
228 */
229 public void setPageSize(final int pageSize) {
230 this.pageSize = pageSize;
231 }
232
233 /**
234 * Gets the current page number.
235 * If current page number is not set or is invalid, returns the default current page number.
236 *
237 * @return the current page number
238 */
239 public int getCurrentPageNumber() {
240 if (currentPageNumber <= 0) {
241 currentPageNumber = getDefaultCurrentPageNumber();
242 }
243 return currentPageNumber;
244 }
245
246 /**
247 * Sets the current page number.
248 *
249 * @param currentPageNumber the current page number
250 */
251 public void setCurrentPageNumber(final int currentPageNumber) {
252 this.currentPageNumber = currentPageNumber;
253 }
254
255 /**
256 * Gets the list of page numbers for pagination display.
257 *
258 * @return the list of page numbers
259 */
260 public List<Integer> getPageNumberList() {
261 return pageNumberList;
262 }
263
264 /**
265 * Sets the list of page numbers for pagination display.
266 *
267 * @param pageNumberList the list of page numbers
268 */
269 public void setPageNumberList(final List<Integer> pageNumberList) {
270 this.pageNumberList = pageNumberList;
271 }
272
273 /**
274 * Gets the default page size from the Fess configuration.
275 *
276 * @return the default page size
277 */
278 protected int getDefaultPageSize() {
279 return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
280 }
281
282 }