Mercurial > hg > LGServices
changeset 12:d57fe2179f61
Improvement of book page
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Tue, 26 May 2015 18:02:03 +0200 |
parents | f15b0214cc1c |
children | 9c6e74761f60 |
files | src/main/java/de/mpiwg/gazetteer/utils/DBService.java src/main/java/de/mpiwg/web/jsp/BooksPage.java src/main/resources/config.properties src/main/resources/hibernate.cfg.xml src/main/webapp/pages/books.jsp |
diffstat | 5 files changed, 27 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Tue May 26 14:59:37 2015 +0200 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Tue May 26 18:02:03 2015 +0200 @@ -610,7 +610,12 @@ con = getNewConnection(); Statement stmt = con.createStatement(); - String query = ""; + String query = "SELECT * FROM sections_versions s1 " + + "JOIN ( " + + "SELECT books_id, MAX(version) AS version " + + "FROM sections_versions " + + "GROUP BY books_id) AS s2 " + + "ON s1.books_id = s2.books_id AND s1.version = s2.version"; ResultSet rs = stmt.executeQuery(query); while(rs.next()){
--- a/src/main/java/de/mpiwg/web/jsp/BooksPage.java Tue May 26 14:59:37 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/BooksPage.java Tue May 26 18:02:03 2015 +0200 @@ -38,26 +38,29 @@ } public void loadBooks(){ + if(this.completeBookList == null){ + this.forceLoadBooks(); + } + } + + public void forceLoadBooks(){ logger.debug("loadBooks"); this.loadSectionsVersion(); - if(this.completeBookList == null){ - logger.debug("loading book list"); - this.completeBookList = new ArrayList<DBBook>(); - if(getSessionBean().getUser() != null){ - // === load book table from db == - for(DBBook book : DBService.getInstance().getBooks()){ - // TODO: get editor and date by book id + logger.debug("loading book list"); + this.completeBookList = new ArrayList<DBBook>(); + if(getSessionBean().getUser() != null){ + // === load book table from db == + for(DBBook book : DBService.getInstance().getBooks()){ + // TODO: get editor and date by book id - book.setCurrentSectionVersion(sectionVersionMap.get(book.getId())); - - this.completeBookList.add(book); - } - } - } else { - // book list already been loaded + book.setCurrentSectionVersion(sectionVersionMap.get(book.getId())); + + this.completeBookList.add(book); + } } + } private void loadSectionsVersion(){
--- a/src/main/resources/config.properties Tue May 26 14:59:37 2015 +0200 +++ b/src/main/resources/config.properties Tue May 26 18:02:03 2015 +0200 @@ -1,5 +1,5 @@ db_gazetter_username=root -db_gazetter_password=root +db_gazetter_password=admin db_gazetter_name=Gazetteer files_root=/gazetteer-server/data
--- a/src/main/resources/hibernate.cfg.xml Tue May 26 14:59:37 2015 +0200 +++ b/src/main/resources/hibernate.cfg.xml Tue May 26 18:02:03 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 Tue May 26 14:59:37 2015 +0200 +++ b/src/main/webapp/pages/books.jsp Tue May 26 18:02:03 2015 +0200 @@ -217,8 +217,8 @@ <!-- TODO --> <td>TODO<input type="submit" value="edit" onclick="setAction('editToc', 'booksForm');"/></td> <td>TODO<input type="checkbox" name="finished" value="0" <%= (book.getTocCorrection() == 1) ? "checked" : "" %>/><label>Finished</label></td> - <td>TODO:last editor</td> - <td>TODO:edit time</td> + <td><%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getEditor() %></td> + <td><%= (book.getCurrentSectionVersion() == null) ? "" : book.getCurrentSectionVersion().getDate() %></td> </tr> <% } %>