Mercurial > hg > LGServices
annotate src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java @ 43:9dbbbfd474f4
new: 1.existing topic in search result. 2.difference-set of book for topic
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Wed, 23 Dec 2015 16:03:32 +0100 |
| parents | 35ed4e650a53 |
| children | 13555aff1f88 |
| rev | line source |
|---|---|
| 39 | 1 package de.mpiwg.web.jsp; |
| 2 | |
| 3 import java.util.ArrayList; | |
| 4 import java.util.Collections; | |
| 5 import java.util.HashMap; | |
| 6 import java.util.List; | |
| 7 import java.util.Map; | |
| 8 | |
| 9 import javax.servlet.http.HttpServletRequest; | |
| 10 import javax.servlet.http.HttpServletResponse; | |
| 11 | |
| 12 import org.apache.commons.lang.StringUtils; | |
| 13 import org.apache.log4j.Logger; | |
| 14 | |
| 15 import de.mpiwg.gazetteer.bo.LGBranch; | |
| 16 import de.mpiwg.gazetteer.bo.LGFile; | |
| 17 import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; | |
| 18 import de.mpiwg.gazetteer.dataverse.bo.VDCUser; | |
| 19 import de.mpiwg.gazetteer.db.DBContents; | |
| 20 import de.mpiwg.gazetteer.db.DBSection; | |
| 21 import de.mpiwg.gazetteer.utils.DBService; | |
| 22 import de.mpiwg.gazetteer.utils.DataProvider; | |
| 23 import de.mpiwg.web.fullTextSearch.SortContentByAdminType; | |
| 24 import de.mpiwg.web.fullTextSearch.SortContentByBookId; | |
| 25 import de.mpiwg.web.fullTextSearch.SortContentByBookName; | |
| 26 import de.mpiwg.web.fullTextSearch.SortContentByDynasty; | |
| 27 import de.mpiwg.web.fullTextSearch.SortContentById; | |
| 28 import de.mpiwg.web.fullTextSearch.SortContentByInx; | |
| 29 import de.mpiwg.web.fullTextSearch.SortContentByLevel1; | |
| 30 import de.mpiwg.web.fullTextSearch.SortContentByLevel2; | |
| 31 import de.mpiwg.web.fullTextSearch.SortContentByPeriod; | |
| 32 import de.mpiwg.web.fullTextSearch.SortContentByStartPage; | |
| 33 import de.mpiwg.web.search.SortSectionByAdminType; | |
| 34 import de.mpiwg.web.search.SortSectionByAuthor; | |
| 35 import de.mpiwg.web.search.SortSectionByBookId; | |
| 36 import de.mpiwg.web.search.SortSectionByBookName; | |
| 37 import de.mpiwg.web.search.SortSectionByDynasty; | |
| 38 import de.mpiwg.web.search.SortSectionByEdition; | |
| 39 import de.mpiwg.web.search.SortSectionById; | |
| 40 import de.mpiwg.web.search.SortSectionByLevel1; | |
| 41 import de.mpiwg.web.search.SortSectionByPeriod; | |
| 42 import de.mpiwg.web.search.SortSectionByStartPage; | |
| 43 import de.mpiwg.web.search.SortSectionByVolume; | |
| 44 | |
| 45 public class FullTextSearchPage extends AbstractJSPPage{ | |
| 46 | |
| 47 private static Logger logger = Logger.getLogger(FullTextSearchPage.class); | |
| 48 | |
| 49 public static String bean = "fullTextSearchBean"; | |
| 50 public static String page = "pages/fullTextSearch.jsp"; | |
| 51 | |
| 52 | |
| 53 private List<DBContents> completeList; | |
| 54 private List<DBContents> filteredList; | |
| 55 private List<DBContents> displayList; | |
| 56 | |
| 57 private String searchTerm = new String(); | |
| 58 | |
| 59 private String dynastyFilter = new String(); | |
| 60 private String adminTypeFilter = new String(); | |
| 61 private String level1Filter = new String(); | |
| 62 | |
| 63 private DataPaginator paginator = new DataPaginator(); | |
| 64 private String searchMessage; | |
| 65 private String filteringMessage; | |
| 66 | |
| 67 private String bookIdFilter = new String(); | |
| 68 private String bookNameFilter = new String(); | |
| 69 private String level2Filter = new String(); | |
| 70 private String periodFilter = new String(); | |
| 71 private String sectionNameFilter = new String(); | |
| 72 | |
| 73 | |
| 74 private List<LGFullTextSearchFile> fileList = null; | |
| 75 private String fileName = new String(); | |
| 76 | |
| 77 private String focusedContentId = new String(); | |
| 78 | |
| 79 @Override | |
| 80 public void init(){ | |
| 81 super.init(); | |
| 82 } | |
| 83 | |
| 84 public void loadParameters(HttpServletRequest request, HttpServletResponse response){ | |
| 85 this.request = request; | |
| 86 this.response = response; | |
| 87 | |
| 88 this.searchTerm = getParameter("searchTerm"); | |
| 89 | |
| 90 this.bookIdFilter = getParameter("bookIdFilter"); | |
| 91 this.bookNameFilter = getParameter("bookNameFilter"); | |
| 92 | |
| 93 this.dynastyFilter = getParameter("dynastyFilter"); | |
| 94 this.adminTypeFilter = getParameter("adminTypeFilter"); | |
| 95 this.level1Filter = getParameter("level1Filter"); | |
| 96 this.level2Filter = getParameter("level2Filter"); | |
| 97 | |
| 98 this.periodFilter = getParameter("periodFilter"); | |
| 99 this.sectionNameFilter = getParameter("sectionNameFilter"); | |
| 100 | |
| 101 this.fileName = getParameter("fileName"); | |
| 102 | |
| 103 this.focusedContentId = getParameter("focusedContentId"); | |
| 104 | |
| 105 } | |
| 106 | |
| 107 | |
| 108 public void search(){ | |
| 109 logger.debug("Searching: " + this.searchTerm); | |
| 110 | |
| 111 this.dynastyFilter = new String(); | |
| 112 this.level1Filter = new String(); | |
| 113 this.adminTypeFilter = new String(); | |
| 114 | |
| 115 if(StringUtils.isNotEmpty(this.searchTerm)){ | |
| 116 try { | |
| 117 List<String> terms = splitTerms(); | |
| 118 System.out.println("Full Text Search: " + terms.toString()); | |
| 119 | |
| 120 this.completeList = DBService.searchFullText(terms); | |
| 121 | |
| 122 if (this.completeList != null ){ | |
| 123 Collections.sort(this.completeList); | |
| 124 filter(); | |
| 125 } | |
| 126 | |
| 127 } catch (Exception e) { | |
| 128 internalError(e); | |
| 129 } | |
| 130 } | |
| 131 } | |
| 132 | |
| 133 | |
| 134 public void forceLoadFileList(){ | |
| 135 logger.debug("forceLoadFileList"); | |
| 136 logger.debug(this.getSearchTerm()); | |
| 137 | |
| 138 if(getSessionBean().getUser() != null){ | |
| 139 //logger.debug("userId="+ getSessionBean().getUser().getId()); | |
| 140 | |
| 141 // set FileList for the user | |
| 142 DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload | |
| 143 this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); | |
| 144 } | |
| 145 | |
| 146 } | |
| 147 | |
| 148 | |
| 149 | |
| 150 public void save() { | |
| 151 logger.debug("saving table..."); | |
| 152 logger.debug(this.getFileName() + ", " + this.getSearchTerm() + ", userId= "+ getSessionBean().getUser().getId()); | |
| 153 | |
| 154 //logger.debug(this.getFilteredList()); | |
| 155 | |
| 156 if (StringUtils.equals(this.getFileName(), "") ) { | |
| 157 addMsg("Save failed. Table name cannot be empty."); | |
| 158 return; | |
| 159 } | |
| 160 | |
| 161 | |
| 162 /* Update db table `LGFullTextSearchFile`: new row with userId, file name, ...*/ | |
| 163 | |
| 164 Long userId = getSessionBean().getUser().getId(); | |
| 165 | |
| 166 LGFullTextSearchFile file; | |
| 167 try { | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
168 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
169 // check if record with (userId, fileName) already existed, update it; otherwise, create one |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
170 LGFullTextSearchFile searchFile = new LGFullTextSearchFile(); |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
171 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
172 for (LGFullTextSearchFile aFile: this.getFileList()) { |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
173 if ( StringUtils.equals(aFile.getFileName(), fileName) && aFile.getUserId().equals(userId)) { |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
174 searchFile = aFile; |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
175 break; |
| 39 | 176 } |
| 177 } | |
| 178 | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
179 if (searchFile.isEmpty() ) { |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
180 searchFile.setFileName(fileName); |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
181 searchFile.setUserId(userId); |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
182 } |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
183 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
184 searchFile.setSearchTerms(this.searchTerm); |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
185 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
186 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
187 file = DataProvider.getInstance().saveLGFullTextSearchFile(this.getFilteredList(), userId, searchFile); |
| 39 | 188 addMsg("The table has been saved!"); |
| 189 | |
| 190 logger.debug(file.getInfo()); | |
| 191 | |
| 192 } catch (Exception e) { | |
| 193 addMsg("Saving fails!"); | |
| 194 e.printStackTrace(); | |
| 195 internalError(e); | |
| 196 } | |
| 197 | |
| 198 // update FileList | |
| 199 DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload | |
| 200 this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); | |
| 201 } | |
| 202 | |
| 203 | |
| 204 | |
| 205 public void filter(){ | |
| 206 this.filteredList = new ArrayList<DBContents>(); | |
| 207 for(DBContents content : this.completeList){ | |
| 208 if(!this.filteredList.contains(content)){ | |
| 209 | |
| 210 if( (StringUtils.isEmpty(dynastyFilter) || StringUtils.startsWith(content.getSection().getBook().getDynasty(), dynastyFilter)) && | |
| 211 (StringUtils.isEmpty(level1Filter) || StringUtils.startsWith(content.getSection().getBook().getLevel1(), level1Filter)) && | |
| 212 (StringUtils.isEmpty(level2Filter) || StringUtils.startsWith(content.getSection().getBook().getLevel2(), level2Filter)) && | |
| 213 (StringUtils.isEmpty(adminTypeFilter) || StringUtils.startsWith(content.getSection().getBook().getAdmin_type(), adminTypeFilter)) && | |
| 214 (StringUtils.isEmpty(bookIdFilter) || StringUtils.startsWith(content.getBookId(), bookIdFilter)) && | |
| 215 (StringUtils.isEmpty(bookNameFilter) || StringUtils.startsWith(content.getSection().getBook().getName(), bookNameFilter)) && | |
| 216 (StringUtils.isEmpty(sectionNameFilter) || StringUtils.startsWith(content.getSection().getName(), sectionNameFilter)) | |
| 217 | |
| 218 ){ | |
| 219 this.filteredList.add(content); | |
| 220 } | |
| 221 } | |
| 222 } | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
223 |
| 39 | 224 if(completeList.size() > 0){ |
| 225 this.searchMessage = completeList.size() + " section(s) found for the term(s): " + this.searchTerm; | |
| 226 this.filteringMessage = this.filteredList.size() + " section(s) listed after the filtering"; | |
| 227 | |
| 228 this.paginator.setCurrentPage(0); | |
| 229 this.paginator.resetNumberOfPages(filteredList.size()); | |
| 230 | |
| 231 }else{ | |
| 232 this.searchMessage = "No sections found for the term(s): " + this.searchTerm; | |
| 233 this.filteredList = null; | |
| 234 this.filteringMessage = ""; | |
| 235 | |
| 236 this.paginator.setCurrentPage(0); | |
| 237 this.paginator.resetNumberOfPages(0); | |
| 238 } | |
| 239 | |
| 240 this.updateCurrentSections(); | |
| 241 | |
| 242 } | |
| 243 | |
| 244 | |
| 245 private void updateCurrentSections() { | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
246 |
| 39 | 247 this.paginator.initCount(); |
| 248 int startRecord = this.paginator.getCurrentPage() | |
| 249 * this.paginator.getItemsPerPage(); | |
| 250 if(this.paginator.getNumberOfPages() == 0){ | |
| 251 this.displayList = new ArrayList<DBContents>(); | |
| 252 }else if((this.paginator.getCurrentPage() + 1) == this.paginator.getNumberOfPages()){ | |
| 253 int mod = this.filteredList.size() % paginator.getItemsPerPage(); | |
| 254 if(mod == 0){ | |
| 255 this.displayList = filteredList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); | |
| 256 }else{ | |
| 257 this.displayList = filteredList.subList(startRecord, startRecord + mod); | |
| 258 } | |
| 259 | |
| 260 }else{ | |
| 261 this.displayList = filteredList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); | |
| 262 } | |
| 263 | |
| 264 } | |
| 265 | |
| 266 | |
| 267 private List<String> splitTerms(){ | |
| 268 List<String> rs = new ArrayList<String>(); | |
| 269 | |
| 270 String[] array = this.searchTerm.split(","); | |
| 271 | |
| 272 for(String tmp : array){ | |
| 273 tmp = tmp.replace(" ", ""); | |
| 274 if(StringUtils.isNotEmpty(tmp)){ | |
| 275 rs.add(tmp); | |
| 276 } | |
| 277 } | |
| 278 return rs; | |
| 279 } | |
| 280 | |
| 281 public List<String> suggestDynasty(String term, int limit){ | |
| 282 List<String> list = new ArrayList<String>(); | |
| 283 for(DBContents content : this.completeList){ | |
| 284 String dynasty = content.getSection().getBook().getDynasty(); | |
| 285 if(!list.contains(dynasty) && dynasty.startsWith(term)){ | |
| 286 list.add(dynasty); | |
| 287 } | |
| 288 if(limit == list.size()){ | |
| 289 break; | |
| 290 } | |
| 291 } | |
| 292 return list; | |
| 293 } | |
| 294 | |
| 295 public List<String> suggestLevel1(String term, int limit){ | |
| 296 List<String> list = new ArrayList<String>(); | |
| 297 for(DBContents content : this.completeList){ | |
| 298 String level1 = content.getSection().getBook().getLevel1(); | |
| 299 if(!list.contains(level1) && level1.startsWith(term)){ | |
| 300 list.add(level1); | |
| 301 } | |
| 302 if(limit == list.size()){ | |
| 303 break; | |
| 304 } | |
| 305 } | |
| 306 return list; | |
| 307 } | |
| 308 | |
| 309 public List<String> suggestAdminType(String term, int limit){ | |
| 310 List<String> list = new ArrayList<String>(); | |
| 311 for(DBContents content : this.completeList){ | |
| 312 String adminType = content.getSection().getBook().getAdmin_type(); | |
| 313 if(!list.contains(adminType) && adminType.startsWith(term)){ | |
| 314 list.add(adminType); | |
| 315 } | |
| 316 if(limit == list.size()){ | |
| 317 break; | |
| 318 } | |
| 319 } | |
| 320 return list; | |
| 321 } | |
| 322 | |
| 323 | |
| 324 | |
| 325 public List<LGFullTextSearchFile> getFileList() { | |
| 326 return fileList; | |
| 327 } | |
| 328 | |
| 329 public void setFileList(List<LGFullTextSearchFile> fileList) { | |
| 330 this.fileList = fileList; | |
| 331 } | |
| 332 | |
| 333 | |
| 334 | |
| 335 public List<DBContents> getCompleteList() { | |
| 336 return completeList; | |
| 337 } | |
| 338 | |
| 339 | |
| 340 | |
| 341 public void setCompleteList(List<DBContents> completeList) { | |
| 342 this.completeList = completeList; | |
| 343 } | |
| 344 | |
| 345 | |
| 346 public String getSearchTerm() { | |
| 347 return searchTerm; | |
| 348 } | |
| 349 | |
| 350 | |
| 351 public void setSearchTerm(String searchTerm) { | |
| 352 this.searchTerm = searchTerm; | |
| 353 } | |
| 354 | |
| 355 public List<DBContents> getFilteredList() { | |
| 356 return filteredList; | |
| 357 } | |
| 358 | |
| 359 public void setFilteredList(List<DBContents> filteredList) { | |
| 360 this.filteredList = filteredList; | |
| 361 } | |
| 362 | |
| 363 | |
| 364 public List<DBContents> getDisplayList() { | |
| 365 return displayList; | |
| 366 } | |
| 367 | |
| 368 public void setDisplayList(List<DBContents> displayList) { | |
| 369 this.displayList = displayList; | |
| 370 } | |
| 371 | |
| 372 | |
| 373 public DataPaginator getPaginator() { | |
| 374 return paginator; | |
| 375 } | |
| 376 | |
| 377 public void setPaginator(DataPaginator paginator) { | |
| 378 this.paginator = paginator; | |
| 379 } | |
| 380 | |
| 381 public void firstPage() { | |
| 382 this.paginator.first(); | |
| 383 this.updateCurrentSections(); | |
| 384 } | |
| 385 | |
| 386 public void lastPage() { | |
| 387 this.paginator.last(); | |
| 388 this.updateCurrentSections(); | |
| 389 } | |
| 390 | |
| 391 public void fastForward() { | |
| 392 this.paginator.fastForward(); | |
| 393 this.updateCurrentSections(); | |
| 394 } | |
| 395 | |
| 396 public void fastRewind() { | |
| 397 this.paginator.fastRewind(); | |
| 398 this.updateCurrentSections(); | |
| 399 } | |
| 400 | |
| 401 public void previousPage() { | |
| 402 this.paginator.previous(); | |
| 403 this.updateCurrentSections(); | |
| 404 } | |
| 405 | |
| 406 public void nextPage() { | |
| 407 this.paginator.next(); | |
| 408 this.updateCurrentSections(); | |
| 409 } | |
| 410 | |
| 411 public String getSearchMessage() { | |
| 412 return searchMessage; | |
| 413 } | |
| 414 | |
| 415 public void setSearchMessage(String searchMessage) { | |
| 416 this.searchMessage = searchMessage; | |
| 417 } | |
| 418 | |
| 419 public String getFilteringMessage() { | |
| 420 return filteringMessage; | |
| 421 } | |
| 422 | |
| 423 public void setFilteringMessage(String filteringMessage) { | |
| 424 this.filteringMessage = filteringMessage; | |
| 425 } | |
| 426 | |
| 427 public String getFileName() { | |
| 428 return fileName; | |
| 429 } | |
| 430 | |
| 431 public void setFileName(String fileName) { | |
| 432 this.fileName = fileName; | |
| 433 } | |
| 434 | |
| 435 public String getDynastyFilter() { | |
| 436 return dynastyFilter; | |
| 437 } | |
| 438 | |
| 439 public void setDynastyFilter(String dynastyFilter) { | |
| 440 this.dynastyFilter = dynastyFilter; | |
| 441 } | |
| 442 | |
| 443 public String getAdminTypeFilter() { | |
| 444 return adminTypeFilter; | |
| 445 } | |
| 446 | |
| 447 public void setAdminTypeFilter(String adminTypeFilter) { | |
| 448 this.adminTypeFilter = adminTypeFilter; | |
| 449 } | |
| 450 | |
| 451 public String getLevel1Filter() { | |
| 452 return level1Filter; | |
| 453 } | |
| 454 | |
| 455 public void setLevel1Filter(String level1Filter) { | |
| 456 this.level1Filter = level1Filter; | |
| 457 } | |
| 458 | |
| 459 | |
| 460 | |
| 461 /////// Sorting | |
| 462 | |
| 463 public String getFocusedContentId() { | |
| 464 return focusedContentId; | |
| 465 } | |
| 466 | |
| 467 public void setFocusedContentId(String focusedContentId) { | |
| 468 this.focusedContentId = focusedContentId; | |
| 469 } | |
| 470 | |
| 471 public String getBookIdFilter() { | |
| 472 return bookIdFilter; | |
| 473 } | |
| 474 | |
| 475 public void setBookIdFilter(String bookIdFilter) { | |
| 476 this.bookIdFilter = bookIdFilter; | |
| 477 } | |
| 478 | |
| 479 public String getBookNameFilter() { | |
| 480 return bookNameFilter; | |
| 481 } | |
| 482 | |
| 483 public void setBookNameFilter(String bookNameFilter) { | |
| 484 this.bookNameFilter = bookNameFilter; | |
| 485 } | |
| 486 | |
| 487 public String getLevel2Filter() { | |
| 488 return level2Filter; | |
| 489 } | |
| 490 | |
| 491 public void setLevel2Filter(String level2Filter) { | |
| 492 this.level2Filter = level2Filter; | |
| 493 } | |
| 494 | |
| 495 public String getPeriodFilter() { | |
| 496 return periodFilter; | |
| 497 } | |
| 498 | |
| 499 public void setPeriodFilter(String periodFilter) { | |
| 500 this.periodFilter = periodFilter; | |
| 501 } | |
| 502 | |
| 503 public String getSectionNameFilter() { | |
| 504 return sectionNameFilter; | |
| 505 } | |
| 506 | |
| 507 public void setSectionNameFilter(String sectionNameFilter) { | |
| 508 this.sectionNameFilter = sectionNameFilter; | |
| 509 } | |
| 510 | |
| 511 public void sortByBookNameUp(){ | |
| 512 Collections.sort(this.completeList, new SortContentByBookName()); | |
| 513 filter(); | |
| 514 } | |
| 515 | |
| 516 public void sortByBookNameDown(){ | |
| 517 Collections.sort(this.completeList, new SortContentByBookName()); | |
| 518 Collections.reverse(this.completeList); | |
| 519 filter(); | |
| 520 } | |
| 521 | |
| 522 public void sortBySectionNameUp(){ | |
| 523 Collections.sort(this.completeList); | |
| 524 filter(); | |
| 525 } | |
| 526 | |
| 527 public void sortBySectionNameDown(){ | |
| 528 Collections.sort(this.completeList); | |
| 529 Collections.reverse(this.completeList); | |
| 530 filter(); | |
| 531 } | |
| 532 | |
| 533 | |
| 534 | |
| 535 public void sortByPeriodUp(){ | |
| 536 Collections.sort(this.completeList, new SortContentByPeriod()); | |
| 537 filter(); | |
| 538 } | |
| 539 | |
| 540 public void sortByPeriodDown(){ | |
| 541 Collections.sort(this.completeList, new SortContentByPeriod()); | |
| 542 Collections.reverse(this.completeList); | |
| 543 filter(); | |
| 544 } | |
| 545 | |
| 546 | |
| 547 | |
| 548 public void sortByIdUp(){ | |
| 549 Collections.sort(this.completeList, new SortContentById()); | |
| 550 this.filter(); | |
| 551 } | |
| 552 | |
| 553 public void sortByIdDown(){ | |
| 554 Collections.sort(this.completeList, new SortContentById()); | |
| 555 Collections.reverse(completeList); | |
| 556 this.filter(); | |
| 557 } | |
| 558 | |
| 559 | |
| 560 public void sortByDynastyUp(){ | |
| 561 Collections.sort(this.completeList, new SortContentByDynasty()); | |
| 562 filter(); | |
| 563 } | |
| 564 | |
| 565 public void sortByDynastyDown(){ | |
| 566 Collections.sort(this.completeList, new SortContentByDynasty()); | |
| 567 Collections.reverse(completeList); | |
| 568 filter(); | |
| 569 } | |
| 570 | |
| 571 public void sortByBookIdUp(){ | |
| 572 Collections.sort(this.completeList, new SortContentByBookId()); | |
| 573 filter(); | |
| 574 } | |
| 575 | |
| 576 public void sortByBookIdDown(){ | |
| 577 Collections.sort(this.completeList, new SortContentByBookId()); | |
| 578 Collections.reverse(completeList); | |
| 579 filter(); | |
| 580 } | |
| 581 | |
| 582 public void sortByLevel1Up(){ | |
| 583 Collections.sort(this.completeList, new SortContentByLevel1()); | |
| 584 filter(); | |
| 585 } | |
| 586 | |
| 587 public void sortByLevel1Down(){ | |
| 588 Collections.sort(this.completeList, new SortContentByLevel1()); | |
| 589 Collections.reverse(completeList); | |
| 590 filter(); | |
| 591 } | |
| 592 public void sortByLevel2Up(){ | |
| 593 Collections.sort(this.completeList, new SortContentByLevel2()); | |
| 594 filter(); | |
| 595 } | |
| 596 | |
| 597 public void sortByLevel2Down(){ | |
| 598 Collections.sort(this.completeList, new SortContentByLevel2()); | |
| 599 Collections.reverse(completeList); | |
| 600 filter(); | |
| 601 } | |
| 602 | |
| 603 public void sortByAdminTypeUp(){ | |
| 604 Collections.sort(this.completeList, new SortContentByAdminType()); | |
| 605 filter(); | |
| 606 } | |
| 607 | |
| 608 public void sortByAdminTypeDown(){ | |
| 609 Collections.sort(this.completeList, new SortContentByAdminType()); | |
| 610 Collections.reverse(completeList); | |
| 611 filter(); | |
| 612 } | |
| 613 | |
| 614 public void sortByStartPageUp(){ | |
| 615 Collections.sort(this.completeList, new SortContentByStartPage()); | |
| 616 filter(); | |
| 617 } | |
| 618 | |
| 619 public void sortByStartPageDown(){ | |
| 620 Collections.sort(this.completeList, new SortContentByStartPage()); | |
| 621 Collections.reverse(completeList); | |
| 622 filter(); | |
| 623 } | |
| 624 public void sortByInxUp(){ | |
| 625 Collections.sort(this.completeList, new SortContentByInx()); | |
| 626 filter(); | |
| 627 } | |
| 628 | |
| 629 public void sortByInxDown(){ | |
| 630 Collections.sort(this.completeList, new SortContentByInx()); | |
| 631 Collections.reverse(completeList); | |
| 632 filter(); | |
| 633 } | |
| 634 | |
| 635 public void removeFocusedContent(boolean status) { | |
| 636 | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
637 // set isRemove for the content with id=this.focusedContentId |
| 39 | 638 // status is true: remove; |
| 639 // status is false: recover (unremove) | |
| 640 | |
| 641 for (DBContents content: this.completeList) { | |
| 642 if (StringUtils.equals(content.getId().toString(), this.focusedContentId)) { | |
| 643 content.setRemoved(status); | |
| 644 logger.debug("set remove content id=" + content.getId().toString()); | |
| 645 break; | |
| 646 } | |
| 647 } | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
648 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
649 int currentPage = this.getPaginator().getCurrentPage(); |
| 39 | 650 |
| 651 Collections.sort(this.completeList); | |
| 652 filter(); | |
|
40
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
653 |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
654 this.getPaginator().setCurrentPage(currentPage); |
|
35ed4e650a53
bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
655 this.updateCurrentSections(); |
| 39 | 656 } |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 } |
