# HG changeset patch # User Calvin Yeh # Date 1495217554 -7200 # Node ID 910cfd8521ddff1ee07ce3b849b1493012cb0092 # Parent 53ca65aad5f7e8d079076ac5f72c71e8ca5aac76 1. Add ?Source? column in Section Page 2. Add pagination in Section Page diff -r 53ca65aad5f7 -r 910cfd8521dd src/main/java/de/mpiwg/web/jsp/JSPProxy.java --- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Fri May 19 20:09:47 2017 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Fri May 19 20:12:34 2017 +0200 @@ -243,6 +243,10 @@ getSessionBean().getSearchPage().sortByStartPageUp(); } else if(StringUtils.equals(action, "sortByStartPageDown")){ getSessionBean().getSearchPage().sortByStartPageDown(); + } else if(StringUtils.equals(action, "sortBySourceUp")){ + getSessionBean().getSearchPage().sortBySourceUp(); + } else if(StringUtils.equals(action, "sortBySourceDown")){ + getSessionBean().getSearchPage().sortBySourceDown(); } return SearchPage.page; diff -r 53ca65aad5f7 -r 910cfd8521dd src/main/java/de/mpiwg/web/jsp/SearchPage.java --- a/src/main/java/de/mpiwg/web/jsp/SearchPage.java Fri May 19 20:09:47 2017 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/SearchPage.java Fri May 19 20:12:34 2017 +0200 @@ -29,55 +29,57 @@ import de.mpiwg.web.search.SortSectionByPeriod; import de.mpiwg.web.search.SortSectionByStartPage; import de.mpiwg.web.search.SortSectionByVolume; +import de.mpiwg.web.search.SortSectionBySource; public class SearchPage extends AbstractJSPPage{ - + private static Logger logger = Logger.getLogger(SearchPage.class); - + public static String bean = "searchBean"; public static String page = "pages/search.jsp"; - - + + private static Integer SEARCH_IN_SECTION_NAME = 0; private static Integer SEARCH_IN_BOOK_NAME = 1; //private static Integer SEARCH_FULL_TEXT = 2; - - + + private Map> branchesMap; private List completeSectionList; private List filteredSectionList; private List displaySectionList; - + private String searchTerm = new String(); private Integer searchIn = SEARCH_IN_SECTION_NAME; - + private String dynastyFilter = new String(); private String adminTypeFilter = new String(); private String level1Filter = new String(); private String level2Filter = new String(); - + private String bookNameFilter = new String(); private String periodFilter = new String(); private String sectionNameFilter = new String(); - + private String sourceFilter = new String(); + private DataPaginator paginator = new DataPaginator(); private String searchMessage; private String filteringMessage; - + private Map> topicSectionRelationMap; - - + + @Override public void init(){ super.init(); } - + public void loadParameters(HttpServletRequest request, HttpServletResponse response){ - + this.request = request; this.response = response; - + this.searchTerm = getParameter("searchTerm"); this.dynastyFilter = getParameter("dynastyFilter"); this.adminTypeFilter = getParameter("adminTypeFilter"); @@ -86,102 +88,103 @@ this.bookNameFilter = getParameter("bookNameFilter"); this.periodFilter = getParameter("periodFilter"); this.sectionNameFilter = getParameter("sectionNameFilter"); - + this.sourceFilter = getParameter("sourceFilter"); + this.searchIn = getIntParameter("searchIn"); - + } - + public void updateTopicSectionRelation() { - logger.debug("updateTopicSectionRelation"); + logger.debug("updateTopicSectionRelation"); this.loadTopicSectionRelation(); this.filter(); - + } - - public void search(){ + + public void search(){ logger.debug("Searching: " + this.searchTerm); - + this.dynastyFilter = new String(); this.level1Filter = new String(); this.adminTypeFilter = new String(); - + if(StringUtils.isNotEmpty(this.searchTerm)){ this.loadBranches(); - + this.loadTopicSectionRelation(); - + // TODO load all books for the difference set?? - - + + try { List terms = splitTerms(); - + if(SEARCH_IN_SECTION_NAME.equals(this.searchIn)){ System.out.println("Section Search in Section Name"); this.completeSectionList = DBService.searchSection(terms); - + }else if(SEARCH_IN_BOOK_NAME.equals(this.searchIn)){ System.out.println("Section Search in Book Name"); this.completeSectionList = DBService.searchBook(terms, "name"); } /*else if (SEARCH_FULL_TEXT.equals(this.searchIn)) { System.out.println("Full Text Search"); - DBService.searchFullText(terms); + DBService.searchFullText(terms); } */ - + Collections.sort(this.completeSectionList); filter(); - + } catch (Exception e) { internalError(e); - } + } } } - - public void filter(){ + + public void filter(){ this.filteredSectionList = new ArrayList(); if (this.completeSectionList != null) { - + for(DBSection section : this.completeSectionList){ if(!this.filteredSectionList.contains(section)){ - + if( (StringUtils.isEmpty(dynastyFilter) || StringUtils.startsWith(section.getBook().getDynasty(), dynastyFilter)) && (StringUtils.isEmpty(level1Filter) || StringUtils.startsWith(section.getBook().getLevel1(), level1Filter)) && (StringUtils.isEmpty(level2Filter) || StringUtils.startsWith(section.getBook().getLevel2(), level2Filter)) && (StringUtils.isEmpty(bookNameFilter) || StringUtils.startsWith(section.getBook().getName(), bookNameFilter)) && (StringUtils.isEmpty(periodFilter) || StringUtils.startsWith(section.getBook().getPeriod(), periodFilter)) && (StringUtils.isEmpty(sectionNameFilter) || StringUtils.startsWith(section.getName(), sectionNameFilter)) && - + (StringUtils.isEmpty(sourceFilter) || StringUtils.contains(section.getBook().getSource(), sourceFilter)) && (StringUtils.isEmpty(adminTypeFilter) || StringUtils.startsWith(section.getBook().getAdmin_type(), adminTypeFilter)) ){ this.filteredSectionList.add(section); - } + } } } - - - + + + if(completeSectionList.size() > 0){ this.searchMessage = completeSectionList.size() + " section(s) found for the term(s): " + this.searchTerm; this.filteringMessage = this.filteredSectionList.size() + " section(s) listed after the filtering"; - + this.paginator.setCurrentPage(0); this.paginator.resetNumberOfPages(filteredSectionList.size()); - + }else{ this.searchMessage = "No sections found for the term(s): " + this.searchTerm; this.filteredSectionList = null; this.filteringMessage = ""; - + this.paginator.setCurrentPage(0); this.paginator.resetNumberOfPages(0); } - + this.updateCurrentSections(); } } - + private void updateCurrentSections() { this.paginator.initCount(); int startRecord = this.paginator.getCurrentPage() @@ -193,24 +196,24 @@ if(mod == 0){ this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); }else{ - this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + mod); + this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + mod); } - + }else{ - this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); + this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); } - + for(DBSection section : this.displaySectionList){ section.setBranches(this.branchesMap.get(section.getId())); section.setTopicSectionRelation(this.topicSectionRelationMap.get(section.getId())); } } - + private void loadBranches(){ this.branchesMap = new HashMap>(); // List list = DataProvider.getInstance().getBranches(getSessionBean().getUser().getId()); List list = DataProvider.getInstance().getAllExistingBranches(); - + for(LGBranch branch : list){ branch.loadTransientData(); if(this.branchesMap.get(branch.getSectionId()) == null){ @@ -219,11 +222,11 @@ this.branchesMap.get(branch.getSectionId()).add(branch); } } - + private void loadTopicSectionRelation(){ this.topicSectionRelationMap = new HashMap>(); List list = DataProvider.getInstance().getAllExistingTopicSectionRelation(); - + for(LGTopicSectionRelation relation : list){ relation.loadTransientData(); if(this.topicSectionRelationMap.get(relation.getSectionId()) == null){ @@ -232,16 +235,16 @@ this.topicSectionRelationMap.get(relation.getSectionId()).add(relation); } } - - + + private List splitTerms(){ List rs = new ArrayList(); String[] array = this.searchTerm.split(","); - + for(String tmp : array){ tmp = tmp.replace(" ", ""); if(StringUtils.isNotEmpty(tmp)){ - rs.add(tmp); + rs.add(tmp); } } return rs; @@ -256,11 +259,11 @@ } if(limit == list.size()){ break; - } + } } return list; } - + public List suggestLevel1(String term, int limit){ List list = new ArrayList(); for(DBSection section : this.completeSectionList){ @@ -270,11 +273,11 @@ } if(limit == list.size()){ break; - } + } } return list; } - + public List suggestLevel2(String term, int limit){ List list = new ArrayList(); for(DBSection section : this.completeSectionList){ @@ -284,12 +287,12 @@ } if(limit == list.size()){ break; - } + } } return list; } - - + + public List suggestBookName(String term, int limit){ List list = new ArrayList(); for(DBSection section : this.completeSectionList){ @@ -299,11 +302,11 @@ } if(limit == list.size()){ break; - } + } } return list; } - + public List suggestPeriod(String term, int limit){ List list = new ArrayList(); for(DBSection section : this.completeSectionList){ @@ -313,11 +316,11 @@ } if(limit == list.size()){ break; - } + } } return list; } - + public List suggestAdminType(String term, int limit){ List list = new ArrayList(); for(DBSection section : this.completeSectionList){ @@ -327,7 +330,7 @@ } if(limit == list.size()){ break; - } + } } return list; } @@ -340,11 +343,11 @@ } if(limit == list.size()){ break; - } + } } return list; } - + public static Integer getSEARCH_IN_SECTION_NAME() { return SEARCH_IN_SECTION_NAME; @@ -427,7 +430,7 @@ public void setPaginator(DataPaginator paginator) { this.paginator = paginator; } - + public void firstPage() { this.paginator.first(); this.updateCurrentSections(); @@ -489,7 +492,7 @@ public void setLevel1Filter(String level1Filter) { this.level1Filter = level1Filter; } - + public String getDynastyFilter() { return dynastyFilter; } @@ -530,153 +533,172 @@ this.periodFilter = periodFilter; } - - + public String getSourceFilter() { + return sourceFilter; + } + + + public void setSourceFilter(String sourceFilter) { + this.sourceFilter = sourceFilter; + } + + /////// Sorting - + public void sortByBookNameUp(){ Collections.sort(this.completeSectionList, new SortSectionByBookName()); filter(); } - + public void sortByBookNameDown(){ Collections.sort(this.completeSectionList, new SortSectionByBookName()); Collections.reverse(this.completeSectionList); filter(); } - + public void sortBySectionNameUp(){ Collections.sort(this.completeSectionList); filter(); } - + public void sortBySectionNameDown(){ Collections.sort(this.completeSectionList); Collections.reverse(this.completeSectionList); filter(); } - + public void sortByAuthorUp(){ Collections.sort(this.completeSectionList, new SortSectionByAuthor()); filter(); } - + public void sortByAuthorDown(){ Collections.sort(this.completeSectionList, new SortSectionByAuthor()); Collections.reverse(this.completeSectionList); filter(); } - + public void sortByPeriodUp(){ Collections.sort(this.completeSectionList, new SortSectionByPeriod()); filter(); } - + public void sortByPeriodDown(){ Collections.sort(this.completeSectionList, new SortSectionByPeriod()); Collections.reverse(this.completeSectionList); filter(); } - + public void sortByVolumeUp(){ Collections.sort(this.completeSectionList, new SortSectionByVolume()); filter(); } - + public void sortByVolumeDown(){ Collections.sort(this.completeSectionList, new SortSectionByVolume()); Collections.reverse(this.completeSectionList); filter(); } - - + + public void sortBySectionIdUp(){ Collections.sort(this.completeSectionList, new SortSectionById()); this.filter(); } - + public void sortBySectionIdDown(){ Collections.sort(this.completeSectionList, new SortSectionById()); Collections.reverse(completeSectionList); this.filter(); } - + public void sortByEditionUp(){ Collections.sort(this.completeSectionList, new SortSectionByEdition()); filter(); } - + public void sortByEditionDown(){ Collections.sort(this.completeSectionList, new SortSectionByEdition()); Collections.reverse(completeSectionList); filter(); } - + public void sortByDynastyUp(){ Collections.sort(this.completeSectionList, new SortSectionByDynasty()); filter(); } - + public void sortByDynastyDown(){ Collections.sort(this.completeSectionList, new SortSectionByDynasty()); Collections.reverse(completeSectionList); filter(); } - + public void sortByBookIdUp(){ Collections.sort(this.completeSectionList, new SortSectionByBookId()); filter(); } - + public void sortByBookIdDown(){ Collections.sort(this.completeSectionList, new SortSectionByBookId()); Collections.reverse(completeSectionList); filter(); } - + public void sortByLevel1Up(){ Collections.sort(this.completeSectionList, new SortSectionByLevel1()); filter(); } - + public void sortByLevel1Down(){ Collections.sort(this.completeSectionList, new SortSectionByLevel1()); Collections.reverse(completeSectionList); filter(); } - + public void sortByLevel2Up(){ Collections.sort(this.completeSectionList, new SortSectionByLevel2()); filter(); } - + public void sortByLevel2Down(){ Collections.sort(this.completeSectionList, new SortSectionByLevel2()); Collections.reverse(completeSectionList); filter(); } - + public void sortByAdminTypeUp(){ Collections.sort(this.completeSectionList, new SortSectionByAdminType()); filter(); } - + public void sortByAdminTypeDown(){ Collections.sort(this.completeSectionList, new SortSectionByAdminType()); Collections.reverse(completeSectionList); filter(); } - + public void sortByStartPageUp(){ Collections.sort(this.completeSectionList, new SortSectionByStartPage()); filter(); } - + public void sortByStartPageDown(){ Collections.sort(this.completeSectionList, new SortSectionByStartPage()); Collections.reverse(completeSectionList); filter(); } - + public void sortBySourceUp(){ + Collections.sort(this.completeSectionList, new SortSectionBySource()); + filter(); + } + + public void sortBySourceDown(){ + Collections.sort(this.completeSectionList, new SortSectionBySource()); + Collections.reverse(completeSectionList); + filter(); + } + + } diff -r 53ca65aad5f7 -r 910cfd8521dd src/main/webapp/componentes/paginator.jsp --- a/src/main/webapp/componentes/paginator.jsp Fri May 19 20:09:47 2017 +0200 +++ b/src/main/webapp/componentes/paginator.jsp Fri May 19 20:12:34 2017 +0200 @@ -1,25 +1,25 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - + <% String formName = request.getParameter("formName"); %> - + -
- - - @@ -27,13 +27,14 @@ <% if (formName.equals("booksForm")) { %> <%=sessionBean.getBooksPage().getPaginator().getRecordStatus() %> - + <% } else if (formName.equals("searchForm")) { %> <%=sessionBean.getSearchPage().getPaginator().getRecordStatus() %> - + <% } else if (formName.equals("fullTextSearchForm")) { %> <%=sessionBean.getFullTextSearchPage().getPaginator().getRecordStatus() %> - + <% } else if (formName.equals("homeForm")) { %> + <%=sessionBean.getHomePage().getPaginator().getRecordStatus() %> <% } %> @@ -43,16 +44,16 @@ onclick="setAction('nextPage', '<%=formName%>');"/> - -
\ No newline at end of file + diff -r 53ca65aad5f7 -r 910cfd8521dd src/main/webapp/pages/search.jsp --- a/src/main/webapp/pages/search.jsp Fri May 19 20:09:47 2017 +0200 +++ b/src/main/webapp/pages/search.jsp Fri May 19 20:12:34 2017 +0200 @@ -5,27 +5,26 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - + + @@ -339,29 +338,29 @@
- +
- + <% if (sessionBean.getUser() == null) { %> <%} else if (sessionBean.getSearchPage().getSearchIn() == null) { %> - + <% } else { %> - + - +
- - - + + + @@ -384,21 +383,20 @@ />/> - +
@@ -370,11 +369,11 @@ name="searchTerm" type="text" class="searchInput" - value="<%=sessionBean.getSearchPage().getSearchTerm()%>" /> + value="<%=sessionBean.getSearchPage().getSearchTerm()%>" />
- - + + <% if (sessionBean.getSearchPage().getCompleteSectionList() != null) { %> - - + - - + +
@@ -410,14 +408,14 @@ @@ -433,12 +431,12 @@
- + src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -446,14 +444,14 @@ - + - + - + @@ -469,7 +467,7 @@
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -477,17 +475,17 @@ - + - - - + + + - + @@ -501,7 +499,7 @@
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -509,15 +507,15 @@ - + - - + + - + @@ -533,7 +531,7 @@
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -541,14 +539,14 @@ - + - + - + @@ -559,12 +557,12 @@
+ src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -572,14 +570,14 @@ - + - + - + @@ -595,7 +593,7 @@
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -603,14 +601,45 @@ - + - - - + + + + + + + + + + + + + + +
+ + + +
+ +
+ +
+
+ + + +
@@ -621,12 +650,12 @@
+ src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
@@ -634,14 +663,14 @@ - + - - - + + + @@ -652,40 +681,43 @@
+ src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+ src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
- - + + - + - + - - + + - - - <% + + <% + long userId = sessionBean.getUser().getId(); + long userDefaultTopicId = sessionBean.getTopicListPage().getDefaultTopicId(userId); + String extractionInterfaceUrl = sessionBean.getApplicationBean().getExtractionInterfaceUrl(); + for (DBSection section : sessionBean.getSearchPage().getDisplaySectionList()) { %> <%=section.getBook().getId()%> - + <%=section.getBook().getName()%> @@ -694,27 +726,28 @@ <%=section.getBook().getDynasty()%> <%=section.getBook().getPeriod()%> <%=section.getBook().getAdmin_type() %> + <%=section.getBook().getSource() %> <%=section.getName()%> <%=section.getPages()%> - - + + - + onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBook().getId() %>', '<%=section.getBook().getName() %>', '<%=userDefaultTopicId %>', '<%=userId %>','<%=extractionInterfaceUrl%>');"> + - + - + <% if(section.getTopicSectionRelation() != null && !section.getTopicSectionRelation().isEmpty()) { %> Already in topic: - +
<% for(LGTopicSectionRelation relation : section.getTopicSectionRelation()) { %>
@@ -723,23 +756,23 @@
- + - - + + <% } %> <% } %> - + - - + + - - + + <% if(section.getBranches() != null && !section.getBranches().isEmpty()) { %> @@ -756,7 +789,7 @@ <% if (branch.hasContributor(sessionBean.getUser().getId())) { %> - + <% } else { %> <% } %> @@ -766,25 +799,25 @@ <% } %> - + <% } %> - - + + <% } %> - +
- + - - + +
<% } %> - +