changeset 21:5b1856cd6b4f

bug fixed: 1.TOC Done display issue 2.issue in firefox
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 23 Jun 2015 14:20:36 +0200
parents 996f8f1b69db
children 2c6f44ef34ab
files src/main/java/de/mpiwg/gazetteer/db/DBBook.java src/main/java/de/mpiwg/gazetteer/utils/DBService.java src/main/java/de/mpiwg/web/books/SortBooksByTocCorrection.java src/main/java/de/mpiwg/web/jsp/ApplicationBean.java src/main/java/de/mpiwg/web/jsp/BooksPage.java src/main/java/de/mpiwg/web/jsp/JSPProxy.java src/main/resources/config.properties src/main/resources/hibernate.cfg.xml src/main/webapp/WEB-INF/web.xml src/main/webapp/pages/books.jsp
diffstat 10 files changed, 137 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/db/DBBook.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/gazetteer/db/DBBook.java	Tue Jun 23 14:20:36 2015 +0200
@@ -24,7 +24,7 @@
 	private Integer start_year;
 	private Integer end_year;
 	private String comments;
-	private Integer toc_correction;
+	private String toc_correction;
 	
 	
 
@@ -49,7 +49,8 @@
 		this.start_year = rs.getInt("start_year");
 		this.end_year = rs.getInt("end_year");
 		this.comments = rs.getString("comments");
-		this.toc_correction = rs.getInt("toc_correction");
+		//this.toc_correction = Integer.parseInt(rs.getString("toc_correction"));
+		this.toc_correction = rs.getString("toc_correction");
 		
 	}
 	
@@ -58,12 +59,12 @@
 		return this.getName().compareTo(o.getName());
 	}
 
-	public Integer getToc_correction() {
+	public String getTocCorrection() {
 		return toc_correction;
 	}
 
 
-	public void setToc_correction(Integer toc_correction) {
+	public void setTocCorrection(String toc_correction) {
 		this.toc_correction = toc_correction;
 	}
 
@@ -223,6 +224,7 @@
 	public void setCurrentSectionVersion(DBSectionVersion currentSectionVersion) {
 		this.currentSectionVersion = currentSectionVersion;
 	}
+
 	
 	
 }
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java	Tue Jun 23 14:20:36 2015 +0200
@@ -684,9 +684,10 @@
 		return section_version;
 	}
 
-	public void updateTocCorrection(String bookId, Integer finishedStatus) throws SQLException {
+	public void updateTocCorrection(String bookId, String finishedStatus) throws SQLException {
 		Connection conn = null;
 		Statement stmt = null;
+		
 		try {
 			String query = "UPDATE books SET toc_correction='"+ finishedStatus + "' WHERE id='" + bookId + "'";
 			conn = getNewConnection();
@@ -700,7 +701,7 @@
 		}
 		
 		DBBook book = this.bookMap.get(bookId);
-		book.setToc_correction(finishedStatus);
+		book.setTocCorrection(finishedStatus);
 	
 		
 	}
--- a/src/main/java/de/mpiwg/web/books/SortBooksByTocCorrection.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/web/books/SortBooksByTocCorrection.java	Tue Jun 23 14:20:36 2015 +0200
@@ -12,7 +12,7 @@
 			return o1.getName().compareTo(o2.getName());	
 		}
 		
-		return o1.getToc_correction().compareTo(o2.getToc_correction());
+		return o1.getTocCorrection().compareTo(o2.getTocCorrection());
 	}
 
 }
\ No newline at end of file
--- a/src/main/java/de/mpiwg/web/jsp/ApplicationBean.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/web/jsp/ApplicationBean.java	Tue Jun 23 14:20:36 2015 +0200
@@ -142,6 +142,10 @@
 	public String getCheckboxCheckedImage(){
 		return getRootServer() + "/resources/images/checkbox_checked.png";
 	}
+	public String getSaveImage(){
+		return getRootServer() + "/resources/images/save.png";
+	}
+	;
 	
 	public String getCheckboxUncheckedImage(){
 		return getRootServer() + "/resources/images/checkbox_unchecked.png";
--- a/src/main/java/de/mpiwg/web/jsp/BooksPage.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/web/jsp/BooksPage.java	Tue Jun 23 14:20:36 2015 +0200
@@ -66,7 +66,6 @@
 		this.response = response;
 		
 		this.tocBookId = getParameter("tocBookId");
-
 		this.bookNameFilter = getParameter("bookNameFilter");
 		this.dynastyFilter = getParameter("dynastyFilter");
 		this.adminTypeFilter = getParameter("adminTypeFilter");
@@ -105,7 +104,6 @@
 			this.paginator.resetNumberOfPages(filteredBookList.size());
 			this.updateCurrentBooks();
 		}else{
-			//this.searchMessage = "No sections found for the term(s): " + this.searchTerm;
 			this.filteredBookList = null;
 		}
 		
@@ -113,8 +111,7 @@
 	
 	
 	private void updateCurrentBooks() {
-		//this.displayBookList = this.filteredBookList;
-		// TODO: update displayBookList using paginator
+		// update displayBookList using paginator
 		
 		this.paginator.initCount();
 		int startRecord = this.paginator.getCurrentPage()
@@ -202,15 +199,12 @@
 	public void loadBooks(){
 		if(this.completeBookList == null){
 			this.forceLoadBooks();
-			sortByBookIdUp();//bookId ascend as default sorting
 			this.filteringMessage = null;
-			
 		} 
-		
 	}
 	
 	public void forceLoadBooks(){
-		logger.debug("loadBooks");
+		logger.debug("force loadBooks");
 
 		this.loadSectionsVersion();
 		
@@ -230,6 +224,12 @@
 			
 		}
 		
+		sortByBookIdUp();	//bookId ascend as default sorting
+		// Note that every sortXYZ() function has filter() in it, so it will also force reload filteredList and displayList
+		
+		
+	
+		
 	}
 	
 	private void loadSectionsVersion(){
@@ -251,13 +251,18 @@
 		String tocBookId = this.getTocBookId();		
 		logger.debug("tocFinishedBookId=" + tocBookId);
 		try {
-			DBService.getInstance().updateTocCorrection(tocBookId, 1);
+			// update toc correction status to DB
+			DBService.getInstance().updateTocCorrection(tocBookId, "1");
+	
+			// update toc correction status
+			DBService.getInstance().getBook(tocBookId).setTocCorrection("1");
+			
 		}catch (Exception e) {
 			addMsg("There is an internal error: " + e.getLocalizedMessage());
 			e.printStackTrace();
 		} 
 	
-		//logger.debug("toc_correction:"+DBService.getInstance().getBook(tocBookId).getToc_correction());
+		logger.debug("toc_correction:"+DBService.getInstance().getBook(tocBookId).getTocCorrection());
 		
 	}
 
@@ -266,15 +271,23 @@
 		String tocBookId = this.getTocBookId();
 		logger.debug("tocFinishedBookId=" + tocBookId);
 		try {
-			DBService.getInstance().updateTocCorrection(tocBookId, 0);
+			DBService.getInstance().updateTocCorrection(tocBookId, "0");
+			DBService.getInstance().getBook(tocBookId).setTocCorrection("0");
+			
 		}catch (Exception e) {
 			addMsg("There is an internal error: " + e.getLocalizedMessage());
 			e.printStackTrace();
-		}
+		}	
 		
-		
+	}	
+
+	public void saveComment() {
+		// TODO Auto-generated method stub
+		logger.debug("saveComment");
 	}
 
+	
+	
 	public void sortByBookIdUp() {
 		Collections.sort(this.completeBookList, new SortBooksByBookId());
 		filter();
@@ -506,4 +519,6 @@
 	}
 
 
+
+
 }
--- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java	Tue Jun 23 14:20:36 2015 +0200
@@ -1,12 +1,8 @@
 package de.mpiwg.web.jsp;
 
-import java.util.Map;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
-import de.mpiwg.gazetteer.utils.DBService;
-
 public class JSPProxy extends AbstractJSPPage {
 	
 	private static Logger logger = Logger.getLogger(JSPProxy.class);
@@ -156,12 +152,16 @@
 					getSessionBean().getBooksPage().setTocCorrection();
 				} else if (StringUtils.equals(action, "unSetTocCorrection")){
 					getSessionBean().getBooksPage().unSetTocCorrection();
+					
+				} else if(StringUtils.equals(action, "saveComment")){
+					getSessionBean().getBooksPage().saveComment();
 				
 				} else if (StringUtils.equals(action, "forceReloadBooks")) {
-					getSessionBean().getBooksPage().forceLoadBooks();
+					getSessionBean().getBooksPage().forceLoadBooks();		
 				} else if(StringUtils.equals(action, "filter")){
 					getSessionBean().getBooksPage().filter();
 					
+					
 					//PAGINATOR
 				} else if(StringUtils.equals(action, "firstPage")){
 					getSessionBean().getBooksPage().firstPage();
--- a/src/main/resources/config.properties	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/resources/config.properties	Tue Jun 23 14:20:36 2015 +0200
@@ -13,14 +13,14 @@
 
 # Production one:
 #localgazetteers-dev -> localgazetteers
-dvn_server=http://localgazetteers.mpiwg-berlin.mpg.de/dvn
-root_server=http://localgazetteers.mpiwg-berlin.mpg.de/LGServices
-toc_interface=http://localgazetteers.mpiwg-berlin.mpg.de/LGToc
-extraction_interface=http://localgazetteers.mpiwg-berlin.mpg.de/extraction-interface
+#dvn_server=http://localgazetteers.mpiwg-berlin.mpg.de/dvn
+#root_server=http://localgazetteers.mpiwg-berlin.mpg.de/LGServices
+#toc_interface=http://localgazetteers.mpiwg-berlin.mpg.de/LGToc
+#extraction_interface=http://localgazetteers.mpiwg-berlin.mpg.de/extraction-interface
 
 # Development one:
 #localgazetteers -> localgazetteers-test
-#dvn_server=http://localgazetteers-test.mpiwg-berlin.mpg.de/dvn
-#root_server=http://localgazetteers-test.mpiwg-berlin.mpg.de/LGServices
-#toc_interface=http://localgazetteers-test.mpiwg-berlin.mpg.de/LGToc
-#extraction_interface=http://localgazetteers-test.mpiwg-berlin.mpg.de/extraction-interface
\ No newline at end of file
+dvn_server=http://localgazetteers-test.mpiwg-berlin.mpg.de/dvn
+root_server=http://localgazetteers-test.mpiwg-berlin.mpg.de/LGServices
+toc_interface=http://localgazetteers-test.mpiwg-berlin.mpg.de/LGToc
+extraction_interface=http://localgazetteers-test.mpiwg-berlin.mpg.de/extraction-interface
\ No newline at end of file
--- a/src/main/resources/hibernate.cfg.xml	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/resources/hibernate.cfg.xml	Tue Jun 23 14:20:36 2015 +0200
@@ -5,7 +5,7 @@
 		<!-- hibernate.cfg.xml -->
 		<property name="c3p0.min_size">5</property>
 		<property name="c3p0.max_size">20</property>
-		<property name="c3p0.timeout">1800</property>
+		<property name="c3p0.timeout">7200</property>
 		<property name="c3p0.max_statements">50</property>
 		<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
 
--- a/src/main/webapp/WEB-INF/web.xml	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/webapp/WEB-INF/web.xml	Tue Jun 23 14:20:36 2015 +0200
@@ -42,7 +42,7 @@
 	</servlet-mapping>
 	
 	<session-config>
-	    <session-timeout>30</session-timeout>
+	    <session-timeout>120</session-timeout>
 	</session-config>	
 
 
--- a/src/main/webapp/pages/books.jsp	Fri Jun 19 16:23:16 2015 +0200
+++ b/src/main/webapp/pages/books.jsp	Tue Jun 23 14:20:36 2015 +0200
@@ -12,19 +12,43 @@
 
 	<jsp:include page="../componentes/headContent.jsp"/>	
 
-
+<script>
+	// TODO delete this function
+	function setTocComment(t) {
+		var notes = t.value;
+		var bookId = t.name;
+		console.log(notes);
+		console.log(bookId);
+		$.ajax({
+			url: "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/setTocComment.jsp",
+			type: 'POST',
+			dataType : 'json',
+			data : {
+				bookId : bookId,
+				notes : notes
+			},
+			success: function(data){
+	        	console.log("You've updated the comments of book: " + data);
+	        },
+	        error: function(error) {
+	        	console.log("error to update toc comments"+ error);
+	        	alert('You have NOT updated the status of book. If this issue remains, please contact us. Thanks.');
+	        }
+		});
+	}
+	
+</script>
 </head>
 
 <body>
-
-
-
 	<jsp:include page="../componentes/template.jsp"/>
-
-
-
 	<div id="page">
-	
+		<form name="booksForm"
+				action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
+				method="post"
+				class="contentForm">
+		<input name="bean" type="hidden" value="booksBean" /> 
+					
 		<% if(sessionBean.getUser() == null) { %>
 			<label>You must login!</label>
 		<% } else {
@@ -36,23 +60,22 @@
 		%>
 		
 		<div class="subTitel">List of Books
+			<input type="image"
+					onclick="setAction('forceReloadBooks', 'booksForm');"
+			src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/>
+			
 			<p class="label"><%= sessionBean.getBooksPage().getBookNumber() %> books in Chinese localgazetteers</p>
-			<p class="label"><%= (StringUtils.isNotEmpty(sessionBean.getBooksPage().getFilteringMessage())) ? sessionBean.getBooksPage().getFilteringMessage() : ""%></p>
+			<p class="label"><%= (StringUtils.isNotEmpty(sessionBean.getBooksPage().getFilteringMessage())) ? sessionBean.getBooksPage().getFilteringMessage() : ""%> </p>
 		</div>
-		<form name="booksForm"
-			action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
-			method="post"
-			class="contentForm">
-			<input name="bean" type="hidden" value="booksBean" /> 
-				
+		
 				<jsp:include page="../componentes/paginator.jsp">
 					<jsp:param name="formName" value="booksForm"/>
 				</jsp:include> 
 				
 				<table style="width: 90%; margin-left: auto;margin-right: auto;" class="pageTable">
 					<tr>
-					<td>
-						<table class="sortTable">
+						<td>
+							<table class="sortTable">
 								<tr>
 									<td><label class="tableTitle">Book ID</label></td>
 									<td>
@@ -317,9 +340,7 @@
 							<table class="sortTable">
 								<tr>
 									<td><label class="tableTitle">TOC Done
-										<input type="image"
-										onclick="setAction('forceReloadBooks', 'booksForm');"
-										src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/>
+										
 										</label>
 									</td>
 									<td>
@@ -382,11 +403,20 @@
 								</tr>
 							</table>
 						</td>
+						<td>
+							<table class="sortTable">
+								<tr>
+									<td><label class="tableTitle">Comments</label></td>
+									
+								</tr>
+							</table>
+						</td>
+					
 						
 					</tr>	
-				
-					<% //for(DBBook book : sessionBean.getBooksPage().getCompleteBookList() ) { 
-						for (DBBook book : sessionBean.getBooksPage().getDisplayBookList() ) {%>
+					
+					
+					<% for (DBBook book : sessionBean.getBooksPage().getDisplayBookList() ) {%>
 					
 					<tr>
 						<!-- books info -->
@@ -399,25 +429,39 @@
 						<td><%=book.getDynasty() %></td>
 						<td><%=book.getAdmin_type() %></td>
 						<td><%=book.getStart_year() %></td>
-						<td><a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=book.getId() %>&amp;count=100&amp;sessionId=<%= session.getId()%>" target="blank">
+						<td><a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=book.getId() %>&amp;count=10000&amp;sessionId=<%= session.getId()%>" target="blank">
 						Edit TOC</a></td>
 						
 						<td>						
-						<% if (book.getToc_correction() == 1) { %>
-							<input type="image" name="tocBookId" value="<%=book.getId()%>"
-								onclick="setAction('unSetTocCorrection', 'booksForm');"
-								src="<%=sessionBean.getApplicationBean().getCheckboxCheckedImage()%>" width="20" height="20"/>	
-						<% } else { %>
 						
-							<input type="image" name="tocBookId" value="<%=book.getId()%>"
-								onclick="setAction('setTocCorrection', 'booksForm');"
+						<% if ( book.getTocCorrection().equals("1") ) { %>
+							<input type="image"	onclick="setAction0('unSetTocCorrection', 'booksForm', 'tocBookId', '<%=book.getId() %>');"	
+								src="<%=sessionBean.getApplicationBean().getCheckboxCheckedImage()%>" width="20" height="20"/>
+							
+						<% } else { %>
+							<input type="image" onclick="setAction0('setTocCorrection', 'booksForm', 'tocBookId', '<%=book.getId() %>');"	
 								src="<%=sessionBean.getApplicationBean().getCheckboxUncheckedImage()%>" width="20" height="20"/>
-								
+						
 						<% } %>
+						
 						</td>
 						
 						<td><%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getEditor() %></td>
 						<td><%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getDate() %></td>
+						
+						<td>
+							<!--
+							<div>  
+								<textarea rows="2" cols="15" maxlength="100" name=<%=book.getId() %> > <%= book.getComments() %></textarea>
+								
+								<input type="image" alt="save comments" 
+									onclick="setAction0('saveComment', 'booksForm', 'bookId', '<%=book.getId()%>');" 
+									src="<%=sessionBean.getApplicationBean().getSaveImage()%>" width="20" height="20"/>
+								
+							</div>
+							-->
+						</td>
+						
 					</tr>
 					
 					<% } %>
@@ -427,8 +471,11 @@
 					<jsp:param name="formName" value="booksForm"/>
 				</jsp:include>
 				
-			</form>
+		
+		
+					
 		<% } %>
+		</form>
 	</div>
 	
 </body>