View Javadoc
1   /*
2    * Copyright 2012-2021 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  public class SearchLogPager implements Serializable {
24  
25      private static final long serialVersionUID = 1L;
26  
27      public static final String LOG_TYPE_SEARCH = "search";
28  
29      public static final String LOG_TYPE_SEARCH_COUNT_HOUR = "search_count_hour_agg";
30  
31      public static final String LOG_TYPE_SEARCH_COUNT_DAY = "search_count_day_agg";
32  
33      public static final String LOG_TYPE_SEARCH_USER_HOUR = "search_user_hour_agg";
34  
35      public static final String LOG_TYPE_SEARCH_USER_DAY = "search_user_day_agg";
36  
37      public static final String LOG_TYPE_SEARCH_REQTIMEAVG_HOUR = "search_reqtimeavg_hour_agg";
38  
39      public static final String LOG_TYPE_SEARCH_REQTIMEAVG_DAY = "search_reqtimeavg_day_agg";
40  
41      public static final String LOG_TYPE_SEARCH_KEYWORD = "search_keyword_agg";
42  
43      public static final String LOG_TYPE_SEARCH_ZEROHIT = "search_zerohit_agg";
44  
45      public static final String LOG_TYPE_SEARCH_ZEROCLICK = "search_zeroclick_agg";
46  
47      public static final String LOG_TYPE_CLICK = "click";
48  
49      public static final String LOG_TYPE_CLICK_COUNT = "click_count_agg";
50  
51      public static final String LOG_TYPE_FAVORITE = "favorite";
52  
53      public static final String LOG_TYPE_FAVORITE_COUNT = "favorite_count_agg";
54  
55      public static final String LOG_TYPE_USERINFO = "user_info";
56  
57      public static final int DEFAULT_PAGE_SIZE = 20;
58  
59      public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;
60  
61      private int allRecordCount;
62  
63      private int allPageCount;
64  
65      private boolean existPrePage;
66  
67      private boolean existNextPage;
68  
69      private List<Integer> pageNumberList;
70  
71      private int pageSize;
72  
73      private int currentPageNumber;
74  
75      public String logType = LOG_TYPE_SEARCH;
76  
77      public String queryId;
78  
79      public String userSessionId;
80  
81      public String requestedTimeRange;
82  
83      public String accessType;
84  
85      public void clear() {
86          allRecordCount = 0;
87          allPageCount = 0;
88          existPrePage = false;
89          existNextPage = false;
90          pageSize = getDefaultPageSize();
91          currentPageNumber = getDefaultCurrentPageNumber();
92  
93          queryId = null;
94          userSessionId = null;
95          requestedTimeRange = null;
96          accessType = null;
97          logType = LOG_TYPE_SEARCH;
98  
99      }
100 
101     protected int getDefaultCurrentPageNumber() {
102         return DEFAULT_CURRENT_PAGE_NUMBER;
103     }
104 
105     public int getAllRecordCount() {
106         return allRecordCount;
107     }
108 
109     public void setAllRecordCount(final int allRecordCount) {
110         this.allRecordCount = allRecordCount;
111     }
112 
113     public int getAllPageCount() {
114         return allPageCount;
115     }
116 
117     public void setAllPageCount(final int allPageCount) {
118         this.allPageCount = allPageCount;
119     }
120 
121     public boolean isExistPrePage() {
122         return existPrePage;
123     }
124 
125     public void setExistPrePage(final boolean existPrePage) {
126         this.existPrePage = existPrePage;
127     }
128 
129     public boolean isExistNextPage() {
130         return existNextPage;
131     }
132 
133     public void setExistNextPage(final boolean existNextPage) {
134         this.existNextPage = existNextPage;
135     }
136 
137     public int getPageSize() {
138         if (pageSize <= 0) {
139             pageSize = getDefaultPageSize();
140         }
141         return pageSize;
142     }
143 
144     public void setPageSize(final int pageSize) {
145         this.pageSize = pageSize;
146     }
147 
148     public int getCurrentPageNumber() {
149         if (currentPageNumber <= 0) {
150             currentPageNumber = getDefaultCurrentPageNumber();
151         }
152         return currentPageNumber;
153     }
154 
155     public void setCurrentPageNumber(final int currentPageNumber) {
156         this.currentPageNumber = currentPageNumber;
157     }
158 
159     public List<Integer> getPageNumberList() {
160         return pageNumberList;
161     }
162 
163     public void setPageNumberList(final List<Integer> pageNumberList) {
164         this.pageNumberList = pageNumberList;
165     }
166 
167     protected int getDefaultPageSize() {
168         return ComponentUtil.getFessConfig().getPagingPageSizeAsInteger();
169     }
170 
171 }