From 4e7ceb1dde219d03e577c7c038e19f977c9abc29 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 12 Oct 2014 17:59:13 +0200 Subject: Separate the "has_cut" property from "do_single_page". Note: the following SQL should be used to upgrade the database: ALTER TABLE entries ADD COLUMN has_cut boolean NOT NULL DEFAULT FALSE ; UPDATE entries SET has_cut = (array_length(xpath('.//d:cut-here', content, ARRAY[ARRAY['d', 'http://www.madore.org/~david/NS/daml/']]), 1) NOTNULL) ; -- Check that the following returns nothing: SELECT edate , id FROM entries WHERE has_cut != ( do_single_page NOTNULL ) ; --- org/madore/damlengine/WeblogSummary.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'org/madore/damlengine/WeblogSummary.java') diff --git a/org/madore/damlengine/WeblogSummary.java b/org/madore/damlengine/WeblogSummary.java index 4819017..662c1d2 100644 --- a/org/madore/damlengine/WeblogSummary.java +++ b/org/madore/damlengine/WeblogSummary.java @@ -15,16 +15,18 @@ public final class WeblogSummary { String lang; String title; String titleXml; String doSinglePage; + boolean hasCut; HashSet catSet; public EntrySummary(int id, String date, String lang, String title, String titleXml, - String doSinglePage) { + String doSinglePage, boolean hasCut) { this.id = id; this.date = date; this.lang = lang; this.title = title; this.titleXml = titleXml; this.doSinglePage = doSinglePage; + this.hasCut = hasCut; this.catSet = null; } } @@ -49,7 +51,7 @@ public final class WeblogSummary { singleton.obtainedTime = System.currentTimeMillis(); final Connection conn = WeblogDatabaseConnection.getConnection(); final PreparedStatement selSt - = conn.prepareStatement("SELECT id , edate , lang , title , title_xml , do_single_page FROM entries"); + = conn.prepareStatement("SELECT id , edate , lang , title , title_xml , do_single_page , has_cut FROM entries"); final ResultSet selRes = selSt.executeQuery(); while ( selRes.next() ) { int id = selRes.getInt(1); @@ -58,7 +60,8 @@ public final class WeblogSummary { String title = selRes.getString(4); String titleXml = selRes.getString(5); String doSinglePage = selRes.getString(6); - singleton.entries.put(id, new EntrySummary(id, date, lang, title, titleXml, doSinglePage)); + boolean hasCut = selRes.getBoolean(7); + singleton.entries.put(id, new EntrySummary(id, date, lang, title, titleXml, doSinglePage, hasCut)); } final PreparedStatement catSt = conn.prepareStatement("SELECT id , code FROM incat"); -- cgit v1.2.3