changeset 59:bc0219c2600b

new: minor improvements
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 09 May 2016 16:02:32 +0200
parents b8ad346e39a0
children 90d5e86c157d
files src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java src/main/webapp/methods/fullTextSearchAdminTypeAutocomplete.jsp src/main/webapp/methods/fullTextSearchBookIdAutocomplete.jsp src/main/webapp/methods/fullTextSearchBookNameAutocomplete.jsp src/main/webapp/methods/fullTextSearchDynastyAutocomplete.jsp src/main/webapp/methods/fullTextSearchLevel1Autocomplete.jsp src/main/webapp/methods/fullTextSearchLevel2Autocomplete.jsp src/main/webapp/methods/fullTextSearchPeriodAutocomplete.jsp src/main/webapp/methods/fullTextSearchSectionNameAutocomplete.jsp src/main/webapp/pages/branchPage.jsp src/main/webapp/pages/fullTextSearch.jsp
diffstat 11 files changed, 457 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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<String> suggestBookName(String term, int limit){
+		List<String> list = new ArrayList<String>();
+		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<String> suggestDynasty(String term, int limit){
 		List<String> list = new ArrayList<String>();
 		for(DBContents content : this.completeList){
@@ -605,6 +621,20 @@
 		return list;
 	}
 	
+	public List<String> suggestLevel2(String term, int limit){
+		List<String> list = new ArrayList<String>();
+		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<String> suggestAdminType(String term, int limit){
 		List<String> list = new ArrayList<String>();
 		for(DBContents content : this.completeList){
@@ -619,6 +649,45 @@
 		return list;
 	}
 	
+	public List<String> suggestPeriod(String term, int limit){
+		List<String> list = new ArrayList<String>();
+		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<String> suggestSectionName(String term, int limit){
+		List<String> list = new ArrayList<String>();
+		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<String> suggestBookId(String term, int limit){
+		List<String> list = new ArrayList<String>();
+		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<LGFullTextSearchFile> getFileList() {
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+	
+	List<String> 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
--- /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"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+
+<%
+
+	String term = request.getParameter("term");
+
+	List<String> 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
--- 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 @@
 													<% } %>		
 												</td>												
 												<td>
-													<input type="image" title="Delete it"
+													<input type="image" title="Delete this version"
 														onclick="<%=sessionBean.getApplicationBean().getJSConfirmationDelete() %> setAction0('deleteFile', 'filesForm', 'fileId', <%=file.getId() %>);" 
 														src="<%=sessionBean.getApplicationBean().getDeleteImage()%>"/>
 												</td>
--- 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 @@
 			};
 		}
 		
+		
+		
+		
 	</script>
 </head>