diff src/main/webapp/pages/search.jsp @ 94:d0dcbe8254f5

New Feature: Add book year and edition year in section searching page, also prevent from book not existing exception
author Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
date Mon, 03 Jul 2017 23:43:44 +0200
parents 910cfd8521dd
children b27a99201cbe
line wrap: on
line diff
--- a/src/main/webapp/pages/search.jsp	Wed Jun 21 06:25:34 2017 +0200
+++ b/src/main/webapp/pages/search.jsp	Mon Jul 03 23:43:44 2017 +0200
@@ -1,6 +1,7 @@
 <%@page import="de.mpiwg.gazetteer.bo.LGBranch"%>
 <%@page import="de.mpiwg.gazetteer.bo.LGTopicSectionRelation"%>
 <%@page import="org.apache.commons.lang.StringUtils"%>
+<%@page import="de.mpiwg.gazetteer.db.DBBook"%>
 <%@page import="de.mpiwg.gazetteer.db.DBSection"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 
@@ -610,6 +611,70 @@
 											</tr>
 										</table>
 									</th>
+
+                                    <th>
+                                        <table class="sortTable">
+                                            <tr>
+                                                <td><label class="tableTitle">Book Year</label></td>
+                                                <td>
+                                                    <table>
+                                                        <tr><td>
+                                                            <input type="image"
+                                                                   onclick="setAction('sortByBookYearUp', 'searchForm');"
+                                                                   src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+                                                        </td></tr>
+                                                        <tr><td>
+                                                            <input type="image"
+                                                                   onclick="setAction('sortByBookYearDown', 'searchForm');"
+                                                                   src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
+                                                        </td></tr>
+                                                    </table>
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <td>
+                                                    <input type="text" class="filterInput" name="bookYearFilter" id="bookYearFilter" value="<%= sessionBean.getSearchPage().getBookYearFilter()%>"/>
+                                                </td>
+                                                <td>
+                                                    <input type="image"
+                                                           onclick="setAction('filter', 'searchForm');"
+                                                           src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+                                                </td>
+                                            </tr>
+                                        </table>
+                                    </th>
+                                    <th>
+                                        <table class="sortTable">
+                                            <tr>
+                                                <td><label class="tableTitle">Edition Year</label></td>
+                                                <td>
+                                                    <table>
+                                                        <tr><td>
+                                                            <input type="image"
+                                                                   onclick="setAction('sortByEditionYearUp', 'searchForm');"
+                                                                   src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+                                                        </td></tr>
+                                                        <tr><td>
+                                                            <input type="image"
+                                                                   onclick="setAction('sortByEditionYearDown', 'searchForm');"
+                                                                   src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>
+                                                        </td></tr>
+                                                    </table>
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <td>
+                                                    <input type="text" class="filterInput" name="editionYearFilter" id="editionYearFilter" value="<%= sessionBean.getSearchPage().getEditionYearFilter()%>"/>
+                                                </td>
+                                                <td>
+                                                    <input type="image"
+                                                           onclick="setAction('filter', 'searchForm');"
+                                                           src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+                                                </td>
+                                            </tr>
+                                        </table>
+                                    </th>
+
 									<th>
 										<table class="sortTable">
 											<tr>
@@ -708,25 +773,47 @@
 
 								<%
 								long userId = sessionBean.getUser().getId();
-		 					  long userDefaultTopicId = sessionBean.getTopicListPage().getDefaultTopicId(userId);
-		 					  String extractionInterfaceUrl = sessionBean.getApplicationBean().getExtractionInterfaceUrl();
+		 					    long userDefaultTopicId = sessionBean.getTopicListPage().getDefaultTopicId(userId);
+		 					    String extractionInterfaceUrl = sessionBean.getApplicationBean().getExtractionInterfaceUrl();
+		 					    DBBook aBook;
+		 					    String BookName;
 
 								for (DBSection section : sessionBean.getSearchPage().getDisplaySectionList()) {
+                                    aBook = section.getBook();
 								%>
 								<tr>
 									<td>
-										<a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=section.getBook().getId() %>&amp;count=100&amp;sessionId=<%= session.getId()%>" target="blank">
-											<%=section.getBook().getId()%>
+										<a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=section.getBookId() %>&amp;count=100&amp;sessionId=<%= session.getId()%>" target="blank">
+											<%=section.getBookId()%>
 										</a>
 										<img title="More Information" src="<%=sessionBean.getApplicationBean().getMoreInfoImage()%>" data-section-id="<%=section.getId()%>" class="moreInfo"/>
 									</td>
-									<td><%=section.getBook().getName()%></td>
-									<td><%=section.getBook().getLevel1()%></td>
-									<td><%=section.getBook().getLevel2()%></td>
-									<td><%=section.getBook().getDynasty()%></td>
-									<td><%=section.getBook().getPeriod()%></td>
-									<td><%=section.getBook().getAdmin_type() %></td>
-									<td><%=section.getBook().getSource() %></td>
+                                    <%if(aBook == null){
+                                        BookName = "";
+                                    %>
+
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                        <td></td>
+                                    <%} else {
+                                        BookName = aBook.getName();%>
+                                        <td><%=BookName%></td>
+                                        <td><%=aBook.getLevel1()%></td>
+                                        <td><%=aBook.getLevel2()%></td>
+                                        <td><%=aBook.getDynasty()%></td>
+                                        <td><%=aBook.getPeriod()%></td>
+                                        <td><%=aBook.getAdmin_type() %></td>
+                                        <td><%=aBook.getBookYear() %></td>
+                                        <td><%=aBook.getEditionYear() %></td>
+                                        <td><%=aBook.getSource() %></td>
+                                    <%}%>
+
 									<td><%=section.getName()%></td>
 									<td><%=section.getPages()%></td>
 
@@ -735,7 +822,7 @@
 									<td>
 										<a href="#"
 											title="Show Section in Extraction Interface"
-										 	onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBook().getId() %>', '<%=section.getBook().getName() %>', '<%=userDefaultTopicId %>', '<%=userId %>','<%=extractionInterfaceUrl%>');">
+										 	onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBookId() %>', '<%=BookName %>', '<%=userDefaultTopicId %>', '<%=userId %>','<%=extractionInterfaceUrl%>');">
 
 										 	<img title="Show Section in Extraction Interface" src="<%=sessionBean.getApplicationBean().getShowImage()%>">
 										</a>