changeset 193:949d69ad3756

Fixed issue with outdating an artifact if it is removed from a collection. artifacts/trunk@1423 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 08 Mar 2011 10:13:45 +0000
parents dad6071c9072
children fde2f193e846
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
diffstat 4 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 08 09:10:55 2011 +0000
+++ b/ChangeLog	Tue Mar 08 10:13:45 2011 +0000
@@ -1,3 +1,12 @@
+2011-03-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
+	  Fixed issue with outdating artifact if it is removed from a collection.
+
+	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
+	  artifact-database/src/main/resources/sql/org-postgresql-driver.properties:
+	  Fixed statements.
+
 2011-03-08  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Mar 08 09:10:55 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Tue Mar 08 10:13:45 2011 +0000
@@ -1321,6 +1321,7 @@
                 prepareStatement(SQL_COLLECTION_ITEM_OUTDATE_ARTIFACT);
                 stmnt.setInt(1, aid);
                 stmnt.setInt(2, cid);
+                stmnt.setInt(3, cid);
                 stmnt.execute();
                 reset();
 
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Mar 08 09:10:55 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Mar 08 10:13:45 2011 +0000
@@ -62,16 +62,17 @@
             WHERE c.gid = ? AND a.gid = ?)
 
 collection.item.id.cid.aid= \
-    SELECT ci.id, c.collection_id, c.artifact_id FROM collection_items ci \
-        INNER JOIN collection c ON ci.collection_id = c.id \
-        INNER JOIN attributes a ON ci.artifact_id = a.id \
+    SELECT ci.id, ci.collection_id, ci.artifact_id FROM collection_items ci \
+        INNER JOIN collections c ON ci.collection_id = c.id \
+        INNER JOIN artifacts a ON ci.artifact_id = a.id \
         WHERE c.gid = ? AND a.gid = ?
 
 collection.item.outdate.artifact= \
     UPDATE artifacts \
     SET last_access = DATEADD('MILLISECOND', -2, CURRENT_TIMESTAMP), ttl = 1 \
     WHERE id = ? AND \
-    NOT EXSITS (SELECT id FROM collection_items WHERE <> collection_id = ?)
+    NOT EXSITS \
+    (SELECT id FROM collection_items WHERE collection_id <> ? AND artifact_id = ?)
 
 collection.item.delete=DELETE FROM collection_items WHERE id = ?
 
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Tue Mar 08 09:10:55 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Tue Mar 08 10:13:45 2011 +0000
@@ -62,16 +62,17 @@
             WHERE c.gid = ?::uuid AND a.gid = ?::uuid)
 
 collection.item.id.cid.aid= \
-    SELECT ci.id, c.collection_id, c.artifact_id FROM collection_items ci \
-        INNER JOIN collection c ON ci.collection_id = c.id \
-        INNER JOIN attributes a ON ci.artifact_id = a.id \
+    SELECT ci.id, ci.collection_id, ci.artifact_id FROM collection_items ci \
+        INNER JOIN collections c ON ci.collection_id = c.id \
+        INNER JOIN artifacts a ON ci.artifact_id = a.id \
         WHERE c.gid = ?::uuid AND a.gid = ?::uuid
 
 collection.item.outdate.artifact= \
     UPDATE artifacts \
     SET last_access = CURRENT_TIMESTAMP - '2 microseconds'::interval, ttl = 1 \
     WHERE id = ? AND \
-    NOT EXSITS (SELECT id FROM collection_items WHERE <> collection_id = ?)
+    NOT EXSITS \
+    (SELECT id FROM collection_items WHERE collection_id <> ? AND artifact_id = ?)
 
 collection.item.delete=DELETE FROM collection_items WHERE id = ?
 

http://dive4elements.wald.intevation.org