# HG changeset patch # User Zoe Hong # Date 1462802552 -7200 # Node ID bc0219c2600b9248a46fd32791ad0ac6e817c09c # Parent b8ad346e39a0254d082408a24bb7ba607cc54ef9 new: minor improvements diff -r b8ad346e39a0 -r bc0219c2600b src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java --- a/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Mon May 02 12:03:30 2016 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Mon May 09 16:02:32 2016 +0200 @@ -20,6 +20,7 @@ import de.mpiwg.gazetteer.bo.LGFile; import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; import de.mpiwg.gazetteer.db.DBContents; +import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.utils.DBService; import de.mpiwg.gazetteer.utils.DataProvider; import de.mpiwg.gazetteer.utils.FileManager; @@ -576,7 +577,22 @@ } return rs; } + + public List suggestBookName(String term, int limit){ + List list = new ArrayList(); + for(DBContents content : this.completeList){ + String bookName = content.getSection().getBook().getName(); + if(!list.contains(bookName) && bookName.startsWith(term)){ + list.add(bookName); + } + if(limit == list.size()){ + break; + } + } + return list; + } + public List suggestDynasty(String term, int limit){ List list = new ArrayList(); for(DBContents content : this.completeList){ @@ -605,6 +621,20 @@ return list; } + public List suggestLevel2(String term, int limit){ + List list = new ArrayList(); + for(DBContents content : this.completeList){ + String level2 = content.getSection().getBook().getLevel2(); + if(!list.contains(level2) && level2.startsWith(term)){ + list.add(level2); + } + if(limit == list.size()){ + break; + } + } + return list; + } + public List suggestAdminType(String term, int limit){ List list = new ArrayList(); for(DBContents content : this.completeList){ @@ -619,6 +649,45 @@ return list; } + public List suggestPeriod(String term, int limit){ + List list = new ArrayList(); + for(DBContents content : this.completeList){ + String period = content.getSection().getBook().getPeriod(); + if(!list.contains(period) && period.startsWith(term)){ + list.add(period); + } + if(limit == list.size()){ + break; + } + } + return list; + } + public List suggestSectionName(String term, int limit){ + List list = new ArrayList(); + for(DBContents content : this.completeList){ + String sectionName = content.getSection().getName(); + if(!list.contains(sectionName) && sectionName.startsWith(term)){ + list.add(sectionName); + } + if(limit == list.size()){ + break; + } + } + return list; + } + public List suggestBookId(String term, int limit){ + List list = new ArrayList(); + for(DBContents content : this.completeList){ + String bookId = content.getSection().getBook().getId(); + if(!list.contains(bookId) && bookId.startsWith(term)){ + list.add(bookId); + } + if(limit == list.size()){ + break; + } + } + return list; + } public List getFileList() { diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchAdminTypeAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchAdminTypeAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestAdminType(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchBookIdAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchBookIdAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestBookId(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchBookNameAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchBookNameAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestBookName(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchDynastyAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchDynastyAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestDynasty(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchLevel1Autocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchLevel1Autocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestLevel1(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchLevel2Autocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchLevel2Autocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestLevel2(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchPeriodAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchPeriodAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestPeriod(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/methods/fullTextSearchSectionNameAutocomplete.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/fullTextSearchSectionNameAutocomplete.jsp Mon May 09 16:02:32 2016 +0200 @@ -0,0 +1,24 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> + + + +<% + + String term = request.getParameter("term"); + + List list = sessionBean.getFullTextSearchPage().suggestSectionName(term, 10); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/pages/branchPage.jsp --- a/src/main/webapp/pages/branchPage.jsp Mon May 02 12:03:30 2016 +0200 +++ b/src/main/webapp/pages/branchPage.jsp Mon May 09 16:02:32 2016 +0200 @@ -365,7 +365,7 @@ <% } %> - diff -r b8ad346e39a0 -r bc0219c2600b src/main/webapp/pages/fullTextSearch.jsp --- a/src/main/webapp/pages/fullTextSearch.jsp Mon May 02 12:03:30 2016 +0200 +++ b/src/main/webapp/pages/fullTextSearch.jsp Mon May 09 16:02:32 2016 +0200 @@ -61,6 +61,198 @@ dialogViewSavedResult.dialog( "open" ); }); + $("#bookIdFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchBookIdAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#bookNameFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchBookNameAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#level1Filter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchLevel1Autocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#level2Filter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchLevel2Autocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#dynastyFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchDynastyAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#periodFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchPeriodAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#adminTypeFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchAdminTypeAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); + $("#sectionNameFilter").autocomplete({ + source : function(request, response) { + $.ajax({ + url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchSectionNameAutocomplete.jsp", + type : "POST", + dataType : "json", + data : { + term : request.term + }, + success : function(data) { + response($.map(data, function(item) { + return { + label : item.name, + value : item.value, + } + })); + }, + error : function(error) { + alert('error: ' + error); + } + }); + }, + minLength : 0 + }); }); @@ -136,6 +328,9 @@ }; } + + +