View Javadoc
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 for scheduler management.
25   */
26  public class SchedulerPager implements Serializable {
27  
28      /**
29       * Constructor.
30       */
31      public SchedulerPager() {
32          super();
33      }
34  
35      private static final long serialVersionUID = 1L;
36  
37      /**
38       * Default page size for pagination.
39       */
40      public static final int DEFAULT_PAGE_SIZE = 20;
41  
42      /**
43       * Default current page number for pagination.
44       */
45      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
46  
47      /**
48       * Total number of records.
49       */
50      private int allRecordCount;
51  
52      /**
53       * Total number of pages.
54       */
55      private int allPageCount;
56  
57      /**
58       * Flag indicating whether a previous page exists.
59       */
60      private boolean existPrePage;
61  
62      /**
63       * Flag indicating whether a next page exists.
64       */
65      private boolean existNextPage;
66  
67      /**
68       * List of page numbers for pagination navigation.
69       */
70      private List<Integer> pageNumberList;
71  
72      /**
73       * Number of records per page.
74       */
75      private int pageSize;
76  
77      /**
78       * Current page number in pagination.
79       */
80      private int currentPageNumber;
81  
82      /**
83       * ID of the scheduled job.
84       */
85      public String id;
86  
87      /**
88       * Name of the scheduled job.
89       */
90      public String name;
91  
92      /**
93       * Target of the scheduled job.
94       */
95      public String target;
96  
97      /**
98       * Cron expression for the scheduled job.
99       */
100     public String cronExpression;
101 
102     /**
103      * Script type of the scheduled job.
104      */
105     public String scriptType;
106 
107     /**
108      * Whether the scheduled job is a crawler job.
109      */
110     public String crawler;
111 
112     /**
113      * Whether logging is enabled for the scheduled job.
114      */
115     public String jobLogging;
116 
117     /**
118      * Whether the scheduled job is available.
119      */
120     public String available;
121 
122     /**
123      * Sort order of the scheduled job.
124      */
125     public String sortOrder;
126 
127     /**
128      * The user who created the scheduled job.
129      */
130     public String createdBy;
131 
132     /**
133      * The time when the scheduled job was created.
134      */
135     public String createdTime;
136 
137     /**
138      * Version number of the scheduled job.
139      */
140     public String versionNo;
141 
142     /**
143      * Clears the pager's state.
144      */
145     public void clear() {
146         allRecordCount = 0;
147         allPageCount = 0;
148         existPrePage = false;
149         existNextPage = false;
150         pageSize = getDefaultPageSize();
151         currentPageNumber = getDefaultCurrentPageNumber();
152 
153         id = null;
154         name = null;
155         target = null;
156         cronExpression = null;
157         scriptType = null;
158         crawler = null;
159         jobLogging = null;
160         available = null;
161         sortOrder = null;
162         createdBy = null;
163         createdTime = null;
164         versionNo = null;
165 
166     }
167 
168     /**
169      * Gets the default current page number.
170      * @return The default current page number.
171      */
172     protected int getDefaultCurrentPageNumber() {
173         return DEFAULT_CURRENT_PAGE_NUMBER;
174     }
175 
176     /**
177      * Gets the total number of records.
178      * @return The total number of records.
179      */
180     public int getAllRecordCount() {
181         return allRecordCount;
182     }
183 
184     /**
185      * Sets the total number of records.
186      * @param allRecordCount The total number of records.
187      */
188     public void setAllRecordCount(final int allRecordCount) {
189         this.allRecordCount = allRecordCount;
190     }
191 
192     /**
193      * Gets the total number of pages.
194      * @return The total number of pages.
195      */
196     public int getAllPageCount() {
197         return allPageCount;
198     }
199 
200     /**
201      * Sets the total number of pages.
202      * @param allPageCount The total number of pages.
203      */
204     public void setAllPageCount(final int allPageCount) {
205         this.allPageCount = allPageCount;
206     }
207 
208     /**
209      * Checks if a previous page exists.
210      * @return true if a previous page exists, false otherwise.
211      */
212     public boolean isExistPrePage() {
213         return existPrePage;
214     }
215 
216     /**
217      * Sets whether a previous page exists.
218      * @param existPrePage true if a previous page exists, false otherwise.
219      */
220     public void setExistPrePage(final boolean existPrePage) {
221         this.existPrePage = existPrePage;
222     }
223 
224     /**
225      * Checks if a next page exists.
226      * @return true if a next page exists, false otherwise.
227      */
228     public boolean isExistNextPage() {
229         return existNextPage;
230     }
231 
232     /**
233      * Sets whether a next page exists.
234      * @param existNextPage true if a next page exists, false otherwise.
235      */
236     public void setExistNextPage(final boolean existNextPage) {
237         this.existNextPage = existNextPage;
238     }
239 
240     /**
241      * Gets the page size.
242      * @return The page size.
243      */
244     public int getPageSize() {
245         if (pageSize <= 0) {
246             pageSize = getDefaultPageSize();
247         }
248         return pageSize;
249     }
250 
251     /**
252      * Sets the page size.
253      * @param pageSize The page size.
254      */
255     public void setPageSize(final int pageSize) {
256         this.pageSize = pageSize;
257     }
258 
259     /**
260      * Gets the current page number.
261      * @return The current page number.
262      */
263     public int getCurrentPageNumber() {
264         if (currentPageNumber <= 0) {
265             currentPageNumber = getDefaultCurrentPageNumber();
266         }
267         return currentPageNumber;
268     }
269 
270     /**
271      * Sets the current page number.
272      * @param currentPageNumber The current page number.
273      */
274     public void setCurrentPageNumber(final int currentPageNumber) {
275         this.currentPageNumber = currentPageNumber;
276     }
277 
278     /**
279      * Gets the list of page numbers.
280      * @return The list of page numbers.
281      */
282     public List<Integer> getPageNumberList() {
283         return pageNumberList;
284     }
285 
286     /**
287      * Sets the list of page numbers.
288      * @param pageNumberList The list of page numbers.
289      */
290     public void setPageNumberList(final List<Integer> pageNumberList) {
291         this.pageNumberList = pageNumberList;
292     }
293 
294     /**
295      * Gets the default page size from the Fess configuration.
296      * @return The default page size.
297      */
298     protected int getDefaultPageSize() {
299         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
300     }
301 
302 }