From f86df60a550f6c8203e104f1dbbdb4afee2bc6b6 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Mon, 5 Sep 2011 16:22:54 +0200 Subject: Allow the cdate attribute to override that in the database. --- org/madore/damlengine/WeblogPopulate.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/org/madore/damlengine/WeblogPopulate.java b/org/madore/damlengine/WeblogPopulate.java index 0cc6620..c3b76b9 100644 --- a/org/madore/damlengine/WeblogPopulate.java +++ b/org/madore/damlengine/WeblogPopulate.java @@ -49,8 +49,10 @@ public final class WeblogPopulate { = conn.prepareStatement("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1) VALUES (?,?,?,?,?::xml,?::xml,?)"); final PreparedStatement insertCSt = conn.prepareStatement("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1,cdate) VALUES (?,?,?,?,?::xml,?::xml,?,?::timestamptz)"); - final PreparedStatement updateSt + final PreparedStatement updateNSt = conn.prepareStatement("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1)=(?,DEFAULT,?,?,?::xml,?::xml,?) WHERE id=?"); + final PreparedStatement updateCSt + = conn.prepareStatement("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1,cdate)=(?,DEFAULT,?,?,?::xml,?::xml,?,?::timestamptz) WHERE id=?"); final PreparedStatement clearCatSt = conn.prepareStatement("DELETE FROM incat WHERE id=?"); final PreparedStatement setCatSt @@ -97,13 +99,23 @@ public final class WeblogPopulate { conn.setAutoCommit(false); if ( exists ) { System.err.println("Updating entry "+id); + PreparedStatement updateSt; + if ( cdate == null ) + updateSt = updateNSt; + else + updateSt = updateCSt; updateSt.setString(1, date); updateSt.setString(2, lang); updateSt.setString(3, titleTxt); updateSt.setString(4, titleXml); updateSt.setString(5, content); updateSt.setString(6, digest); - updateSt.setInt(7, id); + if ( cdate != null ) { + updateSt.setString(7, cdate); + updateSt.setInt(8, id); + } else { + updateSt.setInt(7, id); + } updateSt.executeUpdate(); } else { System.err.println("Registering entry "+id); @@ -138,7 +150,8 @@ public final class WeblogPopulate { checkSt.close(); insertNSt.close(); insertCSt.close(); - updateSt.close(); + updateNSt.close(); + updateCSt.close(); clearCatSt.close(); setCatSt.close(); -- cgit v1.2.3