changeset 317:824051dff018

When loading all artifacts fetch the name of the collections, too. artifacts/trunk@2453 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 02 Aug 2011 14:05:34 +0000
parents 0ca9b1073ccf
children 2ed77f7e1bab
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, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 02 13:10:56 2011 +0000
+++ b/ChangeLog	Tue Aug 02 14:05:34 2011 +0000
@@ -1,3 +1,16 @@
+2011-08-02	Sascha L. Teichmann	<teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java:
+	  Change the ArtifactLoadedCallback interface to take the name of the
+	  collection, too.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
+	  Fetches the collection name, too.
+
+	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
+	  artifact-database/src/main/resources/sql/org-postgresql-driver.properties:
+	  Adjusted SQL statements.
+
 2011-08-02	Sascha L. Teichmann	<teichmann@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUser.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Aug 02 13:10:56 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Aug 02 14:05:34 2011 +0000
@@ -1760,16 +1760,19 @@
                 prepareStatement(SQL_ALL_ARTIFACTS);
                 result = stmnt.executeQuery();
                 while (result.next()) {
-                    String userId       = result.getString(1);
-                    String collectionId = result.getString(2);
-                    String artifactId   = result.getString(3);
-                    String factoryName  = result.getString(4);
+                    String userId         = result.getString(1);
+                    String collectionId   = result.getString(2);
+                    String artifactId     = result.getString(3);
+                    String collectionName = result.getString(4);
+                    String factoryName    = result.getString(5);
 
                     Artifact artifact = alreadyLoaded.get(artifactId);
 
                     if (artifact != null) {
                         alc.artifactLoaded(
-                            userId, collectionId, artifactId, artifact);
+                            userId,
+                            collectionId, collectionName,
+                            artifactId, artifact);
                         continue;
                     }
 
@@ -1781,13 +1784,15 @@
                         continue;
                     }
 
-                    byte [] bytes = result.getBytes(5);
+                    byte [] bytes = result.getBytes(6);
 
                     artifact = factory.getSerializer().fromBytes(bytes);
 
                     if (artifact != null) {
                         alc.artifactLoaded(
-                            userId, collectionId, artifactId, artifact);
+                            userId,
+                            collectionId, collectionName,
+                            artifactId, artifact);
                     }
 
                     alreadyLoaded.put(artifactId, artifact);
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Aug 02 13:10:56 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Aug 02 14:05:34 2011 +0000
@@ -183,7 +183,9 @@
     UPDATE collections SET attribute = ? WHERE gid = ?
 
 all.artifacts = \
-    SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \
+    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 \
+    FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
                 INNER JOIN artifacts a         ON a.id = ci.artifact_id \
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Tue Aug 02 13:10:56 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Tue Aug 02 14:05:34 2011 +0000
@@ -172,7 +172,9 @@
     UPDATE collections SET attribute = ? WHERE gid = ?::uuid
 
 all.artifacts = \
-    SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \
+    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 \
+    FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
                 INNER JOIN artifacts a         ON a.id = ci.artifact_id \
--- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java	Tue Aug 02 13:10:56 2011 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java	Tue Aug 02 14:05:34 2011 +0000
@@ -277,6 +277,7 @@
         void artifactLoaded(
             String   userId,
             String   collectionId,
+            String   collectionName,
             String   artifactId,
             Artifact artifact);
     };

http://dive4elements.wald.intevation.org