changeset 320:b46c5b13ac94

Extract the collection and artifact creation times when doing the initial, too. artifacts/trunk@2482 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 10 Aug 2011 14:18:33 +0000
parents 61017c6031b8
children ce62ae504d22
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java
diffstat 5 files changed, 33 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 08 13:06:05 2011 +0000
+++ b/ChangeLog	Wed Aug 10 14:18:33 2011 +0000
@@ -1,3 +1,14 @@
+2011-08-10	Sascha L. Teichmann	<teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
+	  Extract the collection and artifact creation times when doing the initial
+	  scan, too.
+
+	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
+	  artifact-database/src/main/resources/sql/org-postgresql-driver.properties:
+	  Adjusted the SQL statements.
+
 2011-08-08	Sascha L. Teichmann	<teichmann@intevation.de>
 
 	* artifact-database/src/main/resources/sql/org-h2-driver.properties:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Mon Aug 08 13:06:05 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Wed Aug 10 14:18:33 2011 +0000
@@ -1760,11 +1760,15 @@
                 prepareStatement(SQL_ALL_ARTIFACTS);
                 result = stmnt.executeQuery();
                 while (result.next()) {
-                    String userId         = result.getString(1);
-                    String collectionId   = result.getString(2);
-                    String collectionName = result.getString(3);
-                    String artifactId     = result.getString(4);
-                    String factoryName    = result.getString(5);
+                    String userId         = result.getString("u_gid");
+                    String collectionId   = result.getString("c_gid");
+                    String collectionName = result.getString("c_name");
+                    String artifactId     = result.getString("a_gid");
+                    String factoryName    = result.getString("factory");
+                    Date collectionCreated =
+                        new Date(result.getTimestamp("c_creation").getTime());
+                    Date artifactCreated =
+                        new Date(result.getTimestamp("a_creation").getTime());
 
                     Artifact artifact = alreadyLoaded.get(artifactId);
 
@@ -1772,7 +1776,8 @@
                         alc.artifactLoaded(
                             userId,
                             collectionId, collectionName,
-                            artifactId, artifact);
+                            collectionCreated,
+                            artifactId, artifactCreated, artifact);
                         continue;
                     }
 
@@ -1784,15 +1789,15 @@
                         continue;
                     }
 
-                    byte [] bytes = result.getBytes(6);
+                    byte [] bytes = result.getBytes("data");
 
                     artifact = factory.getSerializer().fromBytes(bytes);
 
                     if (artifact != null) {
                         alc.artifactLoaded(
                             userId,
-                            collectionId, collectionName,
-                            artifactId, artifact);
+                            collectionId, collectionName, collectionCreated,
+                            artifactId, artifactCreated, artifact);
                     }
 
                     alreadyLoaded.put(artifactId, artifact);
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Mon Aug 08 13:06:05 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Wed Aug 10 14:18:33 2011 +0000
@@ -183,8 +183,8 @@
     UPDATE collections SET attribute = ? WHERE gid = ?
 
 all.artifacts = \
-    SELECT u.gid AS u_gid, c.gid AS c_gid, c.name as name, \
-           a.gid AS a_gid, a.factory AS factory, a.data AS data \
+    SELECT u.gid AS u_gid, c.gid AS c_gid, c.name AS c_name, c.creation as c_creation, \
+           a.gid AS a_gid, a.factory AS factory, a.creation AS a_creation, a.data AS data \
     FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Mon Aug 08 13:06:05 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Wed Aug 10 14:18:33 2011 +0000
@@ -172,8 +172,8 @@
     UPDATE collections SET attribute = ? WHERE gid = ?::uuid
 
 all.artifacts = \
-    SELECT u.gid AS u_gid, c.gid AS c_gid, c.name as name, \
-           a.gid AS a_gid, a.factory AS factory, a.data AS data \
+    SELECT u.gid AS u_gid, c.gid AS c_gid, c.name AS c_name, c.creation as c_creation, \
+           a.gid AS a_gid, a.factory AS factory, a.creation AS a_creation, a.data AS data \
     FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java	Mon Aug 08 13:06:05 2011 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java	Wed Aug 10 14:18:33 2011 +0000
@@ -13,6 +13,8 @@
 
 import org.w3c.dom.Document;
 
+import java.util.Date;
+
 /**
  * Interface of an artifact managing database.
  *
@@ -278,7 +280,9 @@
             String   userId,
             String   collectionId,
             String   collectionName,
+            Date     collectionCreated,
             String   artifactId,
+            Date     artifactCreated,
             Artifact artifact);
     };
 

http://dive4elements.wald.intevation.org