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.Constants;
22  import org.codelibs.fess.util.ComponentUtil;
23  
24  /**
25   * Pager class for boost document management with pagination support.
26   * Provides pagination functionality for boost document rule lists.
27   */
28  public class BoostDocPager implements Serializable {
29      private static final long serialVersionUID = 1L;
30  
31      /** Default current page number. */
32      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
33  
34      /** Total number of records. */
35      private int allRecordCount;
36  
37      /** Total number of pages. */
38      private int allPageCount;
39  
40      /** Indicates if a previous page exists. */
41      private boolean existPrePage;
42  
43      /** Indicates if a next page exists. */
44      private boolean existNextPage;
45  
46      /** List of page numbers for pagination navigation. */
47      private List<Integer> pageNumberList;
48  
49      /** Page size for pagination. */
50      private int pageSize;
51  
52      /** Current page number for pagination. */
53      private int currentPageNumber;
54  
55      /** Boost document ID for search filtering. */
56      public String id;
57  
58      /** URL expression for search filtering. */
59      public String urlExpr;
60  
61      /** Boost expression for search filtering. */
62      public String boostExpr;
63  
64      /** Sort order for search filtering. */
65      public String sortOrder;
66  
67      /** Creator username for search filtering. */
68      public String createdBy;
69  
70      /** Creation time for search filtering. */
71      public String createdTime;
72  
73      /** Version number for search filtering. */
74      public String versionNo;
75  
76      /**
77       * Default constructor for BoostDocPager.
78       */
79      public BoostDocPager() {
80          // Default constructor
81      }
82  
83      /**
84       * Clears all search criteria and resets pagination settings.
85       */
86      public void clear() {
87          allRecordCount = 0;
88          allPageCount = 0;
89          existPrePage = false;
90          existNextPage = false;
91          pageSize = getDefaultPageSize();
92          currentPageNumber = getDefaultCurrentPageNumber();
93  
94          id = null;
95          urlExpr = null;
96          boostExpr = null;
97          sortOrder = null;
98          createdBy = null;
99          createdTime = null;
100         versionNo = null;
101 
102     }
103 
104     /**
105      * Gets the total number of records.
106      * @return The total record count.
107      */
108     public int getAllRecordCount() {
109         return allRecordCount;
110     }
111 
112     /**
113      * Sets the total number of records.
114      * @param allRecordCount The total record count.
115      */
116     public void setAllRecordCount(final int allRecordCount) {
117         this.allRecordCount = allRecordCount;
118     }
119 
120     /**
121      * Gets the total number of pages.
122      * @return The total page count.
123      */
124     public int getAllPageCount() {
125         return allPageCount;
126     }
127 
128     /**
129      * Sets the total number of pages.
130      * @param allPageCount The total page count.
131      */
132     public void setAllPageCount(final int allPageCount) {
133         this.allPageCount = allPageCount;
134     }
135 
136     /**
137      * Checks if there is a previous page.
138      * @return True if a previous page exists, false otherwise.
139      */
140     public boolean isExistPrePage() {
141         return existPrePage;
142     }
143 
144     /**
145      * Sets the existence of a previous page.
146      * @param existPrePage True if a previous page exists.
147      */
148     public void setExistPrePage(final boolean existPrePage) {
149         this.existPrePage = existPrePage;
150     }
151 
152     /**
153      * Checks if there is a next page.
154      * @return True if a next page exists, false otherwise.
155      */
156     public boolean isExistNextPage() {
157         return existNextPage;
158     }
159 
160     /**
161      * Sets the existence of a next page.
162      * @param existNextPage True if a next page exists.
163      */
164     public void setExistNextPage(final boolean existNextPage) {
165         this.existNextPage = existNextPage;
166     }
167 
168     /**
169      * Gets the page size for pagination.
170      * @return The page size.
171      */
172     public int getPageSize() {
173         if (pageSize <= 0) {
174             pageSize = getDefaultPageSize();
175         }
176         return pageSize;
177     }
178 
179     /**
180      * Sets the page size for pagination.
181      * @param pageSize The page size.
182      */
183     public void setPageSize(final int pageSize) {
184         this.pageSize = pageSize;
185     }
186 
187     /**
188      * Gets the current page number.
189      * @return The current page number.
190      */
191     public int getCurrentPageNumber() {
192         if (currentPageNumber <= 0) {
193             currentPageNumber = getDefaultCurrentPageNumber();
194         }
195         return currentPageNumber;
196     }
197 
198     /**
199      * Sets the current page number.
200      * @param currentPageNumber The current page number.
201      */
202     public void setCurrentPageNumber(final int currentPageNumber) {
203         this.currentPageNumber = currentPageNumber;
204     }
205 
206     /**
207      * Gets the list of page numbers for pagination navigation.
208      * @return The list of page numbers.
209      */
210     public List<Integer> getPageNumberList() {
211         return pageNumberList;
212     }
213 
214     /**
215      * Sets the list of page numbers for pagination navigation.
216      * @param pageNumberList The list of page numbers.
217      */
218     public void setPageNumberList(final List<Integer> pageNumberList) {
219         this.pageNumberList = pageNumberList;
220     }
221 
222     /**
223      * Gets the default current page number from constants.
224      * @return The default current page number.
225      */
226     protected int getDefaultCurrentPageNumber() {
227         return Constants.DEFAULT_ADMIN_PAGE_NUMBER;
228     }
229 
230     /**
231      * Gets the default page size from configuration.
232      * @return The default page size.
233      */
234     protected int getDefaultPageSize() {
235         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
236     }
237 
238 }