Mercurial > hg > LGServices
changeset 14:3387d855a194
new: toc status in books page
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 29 May 2015 11:00:09 +0200 |
parents | 9c6e74761f60 |
children | d81a5401b9af |
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/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/pages/books.jsp src/main/webapp/resources/images/checkbox_checked.png src/main/webapp/resources/images/checkbox_unchecked.png src/main/webapp/resources/images/refresh.ico |
diffstat | 11 files changed, 140 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/db/DBBook.java Wed May 27 15:30:09 2015 +0200 +++ b/src/main/java/de/mpiwg/gazetteer/db/DBBook.java Fri May 29 11:00:09 2015 +0200 @@ -3,6 +3,8 @@ import java.sql.ResultSet; import java.sql.SQLException; +import com.sun.istack.internal.logging.Logger; + public class DBBook { private String id; @@ -23,8 +25,10 @@ private Integer start_year; private Integer end_year; private String comments; - private Integer toc_correction; + private int toc_correction; + + private DBSectionVersion currentSectionVersion; public DBBook(ResultSet rs) throws SQLException{ @@ -50,7 +54,16 @@ } + public Integer getToc_correction() { + return toc_correction; + } + + public void setToc_correction(Integer toc_correction) { + this.toc_correction = toc_correction; + } + + public String getId() { return id; } @@ -86,14 +99,8 @@ public void setComments(String comments){ this.comments = comments; } - public Integer getTocCorrection() { - return toc_correction; - } - public void setTocCorrection(Integer toc_correction) { - this.toc_correction = toc_correction; - } - + public String getPeriod() { return period; }
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Wed May 27 15:30:09 2015 +0200 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Fri May 29 11:00:09 2015 +0200 @@ -7,7 +7,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -20,8 +19,6 @@ import de.mpiwg.gazetteer.bo.DBEntry; import de.mpiwg.gazetteer.bo.LGBranch; import de.mpiwg.gazetteer.bo.LGFile; -import de.mpiwg.gazetteer.bo.SearchRulesFile; -import de.mpiwg.gazetteer.bo.Sequence; import de.mpiwg.gazetteer.db.DBBook; import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.db.DBSectionVersion; @@ -82,6 +79,13 @@ } public List<DBBook> getBooks(){ + try { + this.loadBookMap(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // getBookMap().values() returns a Collection. In this way, we can use List. return new ArrayList<DBBook>(getBookMap().values()); } @@ -117,7 +121,6 @@ while(rs.next()){ DBBook book = new DBBook(rs); - this.bookMap.put(book.getId(), book); } } catch (Exception e) { @@ -633,5 +636,26 @@ return section_version; } + + public void updateTocCorrection(String bookId, Integer finishedStatus) throws SQLException { + Connection conn = null; + Statement stmt = null; + try { + String query = "UPDATE books SET toc_correction='"+ finishedStatus + "' WHERE id='" + bookId + "'"; + conn = getNewConnection(); + stmt = conn.createStatement(); + int rs = stmt.executeUpdate(query); + + } catch (Exception e) { + e.printStackTrace(); + }finally{ + conn.close(); + } + + DBBook book = this.bookMap.get(bookId); + book.setToc_correction(finishedStatus); + + + } }
--- a/src/main/java/de/mpiwg/web/jsp/ApplicationBean.java Wed May 27 15:30:09 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/ApplicationBean.java Fri May 29 11:00:09 2015 +0200 @@ -139,6 +139,18 @@ return getRootServer() + "/resources/images/more_info_16.png"; } + public String getCheckboxCheckedImage(){ + return getRootServer() + "/resources/images/checkbox_checked.png"; + } + + public String getCheckboxUncheckedImage(){ + return getRootServer() + "/resources/images/checkbox_unchecked.png"; + } + + public String getRefreshImage(){ + return getRootServer() + "/resources/images/refresh.ico"; + } + public String getJSConfirmationDelete(){ return "if(!confirm('Do you really want to delete this?')){ return false; };"; }
--- a/src/main/java/de/mpiwg/web/jsp/BooksPage.java Wed May 27 15:30:09 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/BooksPage.java Fri May 29 11:00:09 2015 +0200 @@ -1,8 +1,6 @@ package de.mpiwg.web.jsp; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -24,10 +22,29 @@ public static String bean = "booksBean"; public static String page = "pages/books.jsp"; private List<DBBook> completeBookList; + + private Map<String, DBSectionVersion> sectionVersionMap = null; + private int bookNumber; + + private String tocBookId = new String(); + - private int bookNumber; + public void loadParameters(HttpServletRequest request, HttpServletResponse response){ + this.request = request; + this.response = response; + + this.tocBookId = getParameter("tocBookId"); + } + + public String getTocBookId() { + return tocBookId; + } + + public void setTocBookId(String tocBookId) { + this.tocBookId = tocBookId; + } public int getBookNumber() { return bookNumber; @@ -37,11 +54,6 @@ this.bookNumber = bookNumber; } - public void loadParameters(HttpServletRequest request, HttpServletResponse response){ - this.request = request; - this.response = response; - - } public List<DBBook> getCompleteBookList() { return completeBookList; @@ -58,10 +70,11 @@ this.loadSectionsVersion(); - logger.debug("loading book list"); this.completeBookList = new ArrayList<DBBook>(); if(getSessionBean().getUser() != null){ + logger.debug("loading book list"); // === load book table from db == + for(DBBook book : DBService.getInstance().getBooks()){ // set editor and date (current version) book.setCurrentSectionVersion(sectionVersionMap.get(book.getId())); @@ -70,9 +83,7 @@ } this.setBookNumber(this.completeBookList.size()); - logger.debug(this.getBookNumber()); - logger.debug(Integer.toString(this.getBookNumber())); - + } } @@ -92,7 +103,33 @@ } + public void setTocCorrection() { + String tocBookId = this.getTocBookId(); + logger.debug("tocFinishedBookId=" + tocBookId); + try { + DBService.getInstance().updateTocCorrection(tocBookId, 1); + }catch (Exception e) { + addMsg("There is an internal error: " + e.getLocalizedMessage()); + e.printStackTrace(); + } + //logger.debug("toc_correction:"+DBService.getInstance().getBook(tocBookId).getToc_correction()); + + } + + + public void unSetTocCorrection() { + String tocBookId = this.getTocBookId(); + logger.debug("tocFinishedBookId=" + tocBookId); + try { + DBService.getInstance().updateTocCorrection(tocBookId, 0); + }catch (Exception e) { + addMsg("There is an internal error: " + e.getLocalizedMessage()); + e.printStackTrace(); + } + + + }
--- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Wed May 27 15:30:09 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Fri May 29 11:00:09 2015 +0200 @@ -148,7 +148,19 @@ return SearchPage.page; - } + } else if(StringUtils.equals(bean, BooksPage.bean)){ + getSessionBean().getBooksPage().loadParameters(request, response); + + if(StringUtils.equals(action, "setTocCorrection")){ + getSessionBean().getBooksPage().setTocCorrection(); + } else if (StringUtils.equals(action, "unSetTocCorrection")){ + getSessionBean().getBooksPage().unSetTocCorrection(); + } else if (StringUtils.equals(action, "forceReloadBooks")) { + getSessionBean().getBooksPage().forceLoadBooks(); + } + + return BooksPage.page; + } }catch(Exception e){ e.printStackTrace();
--- a/src/main/resources/config.properties Wed May 27 15:30:09 2015 +0200 +++ b/src/main/resources/config.properties Fri May 29 11:00:09 2015 +0200 @@ -9,6 +9,7 @@ #toc_interface=http://localhost:1080/localgazetteers-dev/LGToc #extraction_interface=http://localhost:1080/localgazetteers-dev/extraction-interface + # currently stable one #localgazetteers-dev #dvn_server=http://localgazetteers-dev/dvn
--- a/src/main/resources/hibernate.cfg.xml Wed May 27 15:30:09 2015 +0200 +++ b/src/main/resources/hibernate.cfg.xml Fri May 29 11:00:09 2015 +0200 @@ -17,7 +17,7 @@ <property name="hibernate.connection.url">jdbc:mysql://localhost/LGServices?characterEncoding=UTF-8</property> <property name="hibernate.connection.username">root</property> - <property name="hibernate.connection.password">root</property> + <property name="hibernate.connection.password">admin</property> <property name="hibernate.connection.charSet">UTF-8</property> <!-- JDBC connection pool (use the built-in) -->
--- a/src/main/webapp/pages/books.jsp Wed May 27 15:30:09 2015 +0200 +++ b/src/main/webapp/pages/books.jsp Fri May 29 11:00:09 2015 +0200 @@ -152,6 +152,7 @@ }); }); + </script> </head> @@ -195,7 +196,11 @@ <td><label class="tableTitle">Start Year</label></td> <td><label class="tableTitle">Edit TOC</label></td> <!-- go to toc page --> - <td><label class="tableTitle">TOC Finished</label></td> <!-- finished or not --> + <td><label class="tableTitle">TOC Finished</label> + <input type="image" + onclick="setAction('forceReloadBooks', 'booksForm');" + src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/> + </td> <!-- finished or not --> <td><label class="tableTitle">Last Editor</label></td> <td><label class="tableTitle">Edit Time</label></td> @@ -214,12 +219,23 @@ <td><%=book.getDynasty() %></td> <td><%=book.getAdmin_type() %></td> <td><%=book.getStart_year() %></td> - - <!-- TODO --> <td><a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=book.getId() %>&count=100&sessionId=<%= session.getId()%>" target="blank"> Edit TOC</a></td> - <td>TODO<input type="checkbox" name="finished" value="0" <%= (book.getTocCorrection() == 1) ? "checked" : "" %>/><label>Finished</label></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');" + 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> </tr>