Mercurial > hg > LGServices
changeset 48:13555aff1f88
new: multiple full text searching. topics and tasks improvement.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 21 Jan 2016 11:56:30 +0100 |
parents | ef113c53629b |
children | 7c2e1b14b77d |
files | src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java src/main/java/de/mpiwg/web/jsp/JSPProxy.java src/main/java/de/mpiwg/web/jsp/TopicListPage.java src/main/java/de/mpiwg/web/jsp/TopicPage.java src/main/webapp/pages/branchPage.jsp src/main/webapp/pages/fullTextSearch.jsp src/main/webapp/pages/topicList.jsp src/main/webapp/resources/css/style.css |
diffstat | 10 files changed, 186 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java Thu Jan 21 11:56:30 2016 +0100 @@ -57,6 +57,8 @@ @Transient private boolean transientDataLoaded = false; + @Transient + private Integer numOfSections = 0; public boolean isEmpty() { @@ -217,8 +219,6 @@ } - - public void setContributorsList(List<Long> contributorsList) { this.contributorsList = contributorsList; } @@ -228,6 +228,27 @@ this.transientDataLoaded = transientDataLoaded; } + + + public Integer getNumOfSections() { + if (numOfSections == 0){ + // TODO get number of sections in this topic from db table TopicSectionRelation with topicId=this.topicId + Long topicId = this.getId(); + + this.setNumOfSections(DataProvider.getInstance().getNumberOfSectionInTopic(topicId)); + + } + + return numOfSections; + } + + public void setNumOfSections(Integer numOfSections) { + this.numOfSections = numOfSections; + } + + + + public DuplexKey<Long, Long> getKey(){ return new DuplexKey<Long, Long>(this.userId, this.id); } @@ -236,6 +257,9 @@ return nameEn + "(" + nameCh + ", " + namePinyin + ")"; } + + + @Override public String toString(){ return "LGTopic[nameEn=" + nameEn + ", nameCh=" + nameCh + ", namePinyin=" + namePinyin + "]";
--- a/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Thu Jan 21 11:56:30 2016 +0100 @@ -332,10 +332,16 @@ public List<LGTopic> getTopics(Long userId){ List<LGTopic> list = new ArrayList<LGTopic>(); for(LGTopic topic : getTopicMap().values()){ + /* if(topic.hasContributor(userId)){ list.add(topic); } + */ + + // add topic into list anyway, without checking the contributor role. + list.add(topic); } + return list; } @@ -496,6 +502,12 @@ } + public Integer getNumberOfSectionInTopic(Long topicId) { + List<LGTopicSectionRelation> topicSectionRelationList = getTopicSectionRelationMap().getValuesByAKey(topicId); + + return topicSectionRelationList.size(); + } + /* --- end topic --- */
--- a/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Thu Jan 21 11:56:30 2016 +0100 @@ -56,6 +56,8 @@ private String searchTerm = new String(); + private String batchSearchTerm = new String(); + private String dynastyFilter = new String(); private String adminTypeFilter = new String(); private String level1Filter = new String(); @@ -87,6 +89,8 @@ this.searchTerm = getParameter("searchTerm"); + this.batchSearchTerm = getParameter("batchSearchTerm"); + this.bookIdFilter = getParameter("bookIdFilter"); this.bookNameFilter = getParameter("bookNameFilter"); @@ -105,6 +109,57 @@ } + + public void searchBatch() { + + logger.debug("Batch Searching: " + this.batchSearchTerm); + + this.dynastyFilter = new String(); + this.level1Filter = new String(); + this.adminTypeFilter = new String(); + + + if(StringUtils.isNotEmpty(this.batchSearchTerm)){ + try { + + // parse different keyword set by delimiter ";" + + List<String> batchSearchKeywords = splitBatchSearchTerm(); + logger.debug("batchSearchKeywords: " + batchSearchKeywords); + + String countingMessage = new String(); + + for (String aKeywordSet: batchSearchKeywords) { + + this.setSearchTerm(aKeywordSet); + List<String> terms = splitTerms(); + + System.out.println("Full Text Search: " + terms.toString()); + + this.completeList = DBService.searchFullText(terms); + + if (this.completeList.size() != 0 ){ + // save none zero result + Collections.sort(this.completeList); + this.filter(); + + this.setFileName(this.getSearchTerm()); + this.save(); + + } + + countingMessage += this.completeList.size() + "\t" + terms + "<br>"; + } + this.setSearchMessage(countingMessage); + + } catch (Exception e) { + internalError(e); + } + } + + + } + public void search(){ logger.debug("Searching: " + this.searchTerm); @@ -182,7 +237,6 @@ } searchFile.setSearchTerms(this.searchTerm); - file = DataProvider.getInstance().saveLGFullTextSearchFile(this.getFilteredList(), userId, searchFile); addMsg("The table has been saved!"); @@ -264,6 +318,20 @@ } + private List<String> splitBatchSearchTerm() { + List<String> rs = new ArrayList<String>(); + + String[] array = this.batchSearchTerm.split(";"); + + for(String tmp : array){ + tmp = tmp.replace(" ", ""); + if(StringUtils.isNotEmpty(tmp)){ + rs.add(tmp); + } + } + return rs; + } + private List<String> splitTerms(){ List<String> rs = new ArrayList<String>(); @@ -343,6 +411,14 @@ } + public String getBatchSearchTerm() { + return batchSearchTerm; + } + + public void setBatchSearchTerm(String batchSearchTerm) { + this.batchSearchTerm = batchSearchTerm; + } + public String getSearchTerm() { return searchTerm; }
--- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Thu Jan 21 11:56:30 2016 +0100 @@ -236,8 +236,12 @@ getSessionBean().getFullTextSearchPage().removeFocusedContent(true); } else if(StringUtils.equals(action, "recoverFocusedContent")){ getSessionBean().getFullTextSearchPage().removeFocusedContent(false); + + // for searching in batch keywords + } else if(StringUtils.equals(action, "searchBatch")){ + getSessionBean().getFullTextSearchPage().searchBatch(); - + //PAGINATOR } else if(StringUtils.equals(action, "firstPage")){ getSessionBean().getFullTextSearchPage().firstPage();
--- a/src/main/java/de/mpiwg/web/jsp/TopicListPage.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/TopicListPage.java Thu Jan 21 11:56:30 2016 +0100 @@ -61,8 +61,8 @@ this.completeTopicList = new ArrayList<LGTopic>(); - if(getSessionBean().getUser() != null){ - for(LGTopic topic : DataProvider.getInstance().getTopics(getSessionBean().getUser().getId())){ + if(this.getSessionBean().getUser() != null){ + for(LGTopic topic : DataProvider.getInstance().getTopics(this.getSessionBean().getUser().getId())){ if (topic.isEmpty()) { logger.debug("topic doesn't exist anymore.");
--- a/src/main/java/de/mpiwg/web/jsp/TopicPage.java Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/TopicPage.java Thu Jan 21 11:56:30 2016 +0100 @@ -186,12 +186,13 @@ // all sections in the topic this.completeSectionList = DataProvider.getInstance().getAllSectionsInTopic(topic.getId()); + logger.info("completeSectionList.size=" + completeSectionList.size()); } catch (Exception e) { internalError(e); } - logger.info("completeSectionList.size=" + completeSectionList.size()); + } this.filter();
--- a/src/main/webapp/pages/branchPage.jsp Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/webapp/pages/branchPage.jsp Thu Jan 21 11:56:30 2016 +0100 @@ -286,7 +286,21 @@ <th><label class="tableTitle">Text</label></th> <th><label class="tableTitle">View in table</label></th> <th><label class="tableTitle">Text(to be published)</label></th> - <th><label class="tableTitle">Uploaded in LGDataverse?</label></th> + <th><label class="tableTitle">Upload to LGDataverse</label><br> + + <% LGFile lastFile = sessionBean.getBranchPage().getLastFile(); + if(lastFile.getDvId() == null) {%> + <button type="button" class="get-studies" data-file-id="<%=lastFile.getId()%>">Upload it</button> + <% } else if (lastFile.getFileIdInDv() == null) { %> + <label><i>Uploaded, but it's been deleted from <a href="<%=lastFile.getDatasetUrl() %>" target="_blank"><%= lastFile.getDatasetTitle() %></a></i></label> + <button type="button" class="get-studies" data-file-id="<%=lastFile.getId()%>">Re-upload it</button> + + <% } else { %> + <label>Already uploaded in <a href="<%=lastFile.getDatasetUrl() %>" target="_blank"><%= lastFile.getDatasetTitle() %></a></label> + + <% } %> + + </th> <th><label class="tableTitle">Delete</label></th> </tr> @@ -317,18 +331,15 @@ <img alt="Show text" src="<%=sessionBean.getApplicationBean().getShowImage()%>"/> </a> </td> - - - + <td> <% if(file.getDvId() == null) {%> - <button type="button" class="get-studies" data-file-id="<%=file.getId()%>">Upload it</button> + <% } else if (file.getFileIdInDv() == null) { %> - <label><i>Yes, but it's been deleted from <a href="<%=file.getDatasetUrl() %>" target="_blank"><%= file.getDatasetTitle() %></a></i></label> - <button type="button" class="get-studies" data-file-id="<%=file.getId()%>">Upload it</button> - + <label><i>(uploaded, then deleted)</i></label> + <% } else { %> - <label>Yes! in <a href="<%=file.getDatasetUrl() %>" target="_blank"><%= file.getDatasetTitle() %></a></label> + <label>uploaded in <a href="<%=file.getDatasetUrl() %>" target="_blank"><%= file.getDatasetTitle() %></a></label> <% } %> </td>
--- a/src/main/webapp/pages/fullTextSearch.jsp Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/webapp/pages/fullTextSearch.jsp Thu Jan 21 11:56:30 2016 +0100 @@ -186,9 +186,33 @@ onclick="setAction('search', 'fullTextSearchForm');" src="<%=sessionBean.getApplicationBean().getSearchImage()%>"/> </td> + </tr> + <!-- TODO batching querying --> + <!-- for batching, query keyword sets separated by ";" and within each keyword set, keywords separated by "," --> + <% if (StringUtils.equals(sessionBean.getUserName(), "zhong") || StringUtils.equals(sessionBean.getUserName(), "silk")) { %> + <tr> + <td> + <input + id="batchSearchTerm" + name="batchSearchTerm" + type="text" + class="searchInput" + value="<%=sessionBean.getFullTextSearchPage().getBatchSearchTerm() %>" /> + </td> + <td> + <input id="search" + type="image" + onclick="setAction('searchBatch', 'fullTextSearchForm');" + src="<%=sessionBean.getApplicationBean().getSearchImage()%>"/> + </td> + + + </tr> + <% } %> + <tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getFullTextSearchPage().getSearchMessage())) ? sessionBean.getFullTextSearchPage().getSearchMessage() : ""%></label></td></tr> <tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getFullTextSearchPage().getFilteringMessage())) ? sessionBean.getFullTextSearchPage().getFilteringMessage() : ""%></label></td></tr> <tr><td>
--- a/src/main/webapp/pages/topicList.jsp Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/webapp/pages/topicList.jsp Thu Jan 21 11:56:30 2016 +0100 @@ -269,20 +269,25 @@ </table> </td> <td><%=topic.getFomattedLastChange() %></td> - - + <td> - <a href="<%=sessionBean.getApplicationBean().getRootServer() %>/pages/topicPage.jsp?topicId=<%=topic.getId() %>" > - <img alt="Manage Topic" src="<%=sessionBean.getApplicationBean().getEditBranchImage()%>"/> - </a> + <%if(topic.hasContributor(sessionBean.getUser().getId())){ %> + <a href="<%=sessionBean.getApplicationBean().getRootServer() %>/pages/topicPage.jsp?topicId=<%=topic.getId() %>" > + <img alt="Manage Topic" src="<%=sessionBean.getApplicationBean().getEditBranchImage()%>"/> + </a> + <% } %> + + <label>(<%=topic.getNumOfSections().toString()%>/2000)</label> </td> <td> - <input type="image" - onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> deleteTopic('deleteTopic', 'topicListForm', '<%=topic.getId() %>');" - src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/> + <%if(topic.hasContributor(sessionBean.getUser().getId())){ %> + <input type="image" + onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> deleteTopic('deleteTopic', 'topicListForm', '<%=topic.getId() %>');" + src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/> + <% } %> + </td> - </tr> <% } %>
--- a/src/main/webapp/resources/css/style.css Mon Dec 28 12:54:55 2015 +0100 +++ b/src/main/webapp/resources/css/style.css Thu Jan 21 11:56:30 2016 +0100 @@ -291,7 +291,9 @@ background-color:yellow; } .removedContent { - opacity:0.3; + color:rgb(166, 166, 166); + /*opacity:0.3; color: transparent; - text-shadow: 0 0 3px rgba(0,0,0,0.8); + text-shadow: 0 0 3px rgba(0,0,0,1); + */ } \ No newline at end of file