# HG changeset patch # User Zoe Hong # Date 1432890009 -7200 # Node ID 3387d855a194c160b06592233845c70805ea8f61 # Parent 9c6e74761f60d65aa80e3b0b4a683557cb52885a new: toc status in books page diff -r 9c6e74761f60 -r 3387d855a194 src/main/java/de/mpiwg/gazetteer/db/DBBook.java --- 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; } diff -r 9c6e74761f60 -r 3387d855a194 src/main/java/de/mpiwg/gazetteer/utils/DBService.java --- 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 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(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); + + + } } diff -r 9c6e74761f60 -r 3387d855a194 src/main/java/de/mpiwg/web/jsp/ApplicationBean.java --- 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; };"; } diff -r 9c6e74761f60 -r 3387d855a194 src/main/java/de/mpiwg/web/jsp/BooksPage.java --- 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 completeBookList; + + private Map 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 getCompleteBookList() { return completeBookList; @@ -58,10 +70,11 @@ this.loadSectionsVersion(); - logger.debug("loading book list"); this.completeBookList = new ArrayList(); 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(); + } + + + } diff -r 9c6e74761f60 -r 3387d855a194 src/main/java/de/mpiwg/web/jsp/JSPProxy.java --- 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(); diff -r 9c6e74761f60 -r 3387d855a194 src/main/resources/config.properties --- 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 diff -r 9c6e74761f60 -r 3387d855a194 src/main/resources/hibernate.cfg.xml --- 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 @@ jdbc:mysql://localhost/LGServices?characterEncoding=UTF-8 root - root + admin UTF-8 diff -r 9c6e74761f60 -r 3387d855a194 src/main/webapp/pages/books.jsp --- 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 @@ }); }); + @@ -195,7 +196,11 @@ - + + + @@ -214,12 +219,23 @@ <%=book.getDynasty() %> <%=book.getAdmin_type() %> <%=book.getStart_year() %> - - Edit TOC - TODO/> + + <% if (book.getToc_correction() == 1) { %> + + <% } else { %> + + + + <% } %> + + <%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getEditor() %> <%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getDate() %> diff -r 9c6e74761f60 -r 3387d855a194 src/main/webapp/resources/images/checkbox_checked.png Binary file src/main/webapp/resources/images/checkbox_checked.png has changed diff -r 9c6e74761f60 -r 3387d855a194 src/main/webapp/resources/images/checkbox_unchecked.png Binary file src/main/webapp/resources/images/checkbox_unchecked.png has changed diff -r 9c6e74761f60 -r 3387d855a194 src/main/webapp/resources/images/refresh.ico Binary file src/main/webapp/resources/images/refresh.ico has changed