Mercurial > hg > LGServices
diff src/main/java/de/mpiwg/gazetteer/utils/DBService.java @ 27:3b3e2963c8f7 dev_dataverse4
new: rewrite LGServices for LGDataverse with the new dataverse, dataverse4.0
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Sep 2015 16:33:31 +0200 |
parents | ce2e3f2814c0 |
children | 2e1662afc81c |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Tue Jun 30 14:31:29 2015 +0200 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Tue Sep 08 16:33:31 2015 +0200 @@ -464,7 +464,7 @@ } rs.close(); - } catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); @@ -472,6 +472,43 @@ return section; } + public static DBSection getDeprecatedSectionWithContent(Long sectionId) throws SQLException { + + Connection conn = null; + Statement stmt = null; + DBSection section = null; + + String query = "SELECT * FROM sections_revisions WHERE sections_id = '" + sectionId + "'"; + + try { + Class.forName(JDBC_DRIVER); + conn = getNewConnection(); + stmt = conn.createStatement(); + + ResultSet rs = stmt.executeQuery(query); + rs.next(); + //while (rs.next()) { + + section = new DBSection(rs); + + String content = getContent(conn, section); + section.setText(content); + + DBBook book = DBService.getInstance().getBook(section.getBookId()); + section.setBook(book); + + //} + rs.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + conn.close(); + } + return section; + } + + + public static String fixToNewline(String orig){ char[] chars = orig.toCharArray(); StringBuilder sb = new StringBuilder(100); @@ -494,8 +531,7 @@ //private static String getContent(Connection conn, String bookId, Integer startLine, Integer endLine) throws Exception{ private static String getContent(Connection conn, DBSection section) throws Exception{ String query = "SELECT content, line FROM contents WHERE books_id = '" + section.getBookId() + "' AND line >= '" + section.getStart_page() + "' AND line <= '" + section.getEnd_page() + "'"; - - logger.debug(query); + //logger.debug(query); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); @@ -727,5 +763,6 @@ } + }